Documentation
¶
Overview ¶
directives.go — the loaderkit-local WALK-only directives: MaxIncludeDepth, namespaceAliasRe, and validateNamespaceAlias. The kind-blind document directives (ImportList/ImportEntry, DiscoverConfig/ScanSpec, anchorScanSpecs, docShape/classifyDoc) relocated to sdk/kit (loader_directives.go + loader_classify.go) so charly core AND sdk/loaderkit share ONE copy (R3) — see kit.ImportList / kit.DiscoverConfig / kit.AnchorScanSpecs / kit.ClassifyDoc.
discover.go — the K1 port of charly/unified.go's discover walk (ApplyDiscover / applyDiscoveredManifest): scans each `discover:` spec for directories carrying its manifest (via the shared kit.FindEntityDirs primitive) and PARSES every document each discovered manifest contains into a spec.DiscoveredManifest. Faithful port, MINUS the host-only candy-image lazy-ref registration + normalizeNodeInto fold (materialize — the registry-coupled kind-decode the host keeps, boundary law) — this file only WALKS + PARSES, exactly like the rest of loaderkit.
Package loaderkit is the importable form of charly's unified-config PARSE — the parse half of LoadUnified relocated out of charly core (P6). It decomposes one node-form YAML document into the generic, sdk-expressible spec.ParsedProject the host MATERIALIZES into the typed *UnifiedFile. Shared by the loader plugin candy (candy/plugin-loader, its OpLoad) and, during the transition, by charly core — the SAME parse, one copy (R3), the way sdk/kit is the one copy of the check walk.
The parse consults ONLY spec vocabulary (CUE-sourced) + yaml + host-threaded kind-recognition DATA (Threaded) — never the provider registry directly. The registry is core fabric; the host snapshots which words it recognizes (kinds / deploy substrates / structural / scalar-sugar primaries) into Threaded before the parse, and the re-entrant connect-then-reload re-parses with an updated snapshot. That keeps the parse a kind-blind mechanism (boundary law clause D).
walk.go — the K1 port of charly's unified-config loader ORCHESTRATION: the kind-blind WALK+PARSE half of LoadUnified (charly/unified.go) relocated out of charly core. Walk drives the import queue + discover + namespaced-import mounts and PARSES every document (via the existing loaderkit.ParseDoc, P6) into a generic spec.LoadedProject envelope — it does NO materialize (registry kind-decode) and NO merge (root-wins field folding) into a typed *UnifiedFile; the host replays materialize+merge over the returned spec.LoadedProject to reconstruct that, exactly as it did inline before.
Everything registry-coupled or host-coupled (the parse pre-scan + connect-declared-kind-plugins side effects, the #NodeDoc CUE validate-before-execute gate, remote-ref resolution + the project-repo cache, and the repo-identity cycle-break) is a SEAM CALLBACK the host supplies via spec.WalkSeams (#46 — the seam contract lives in sdk/spec, not here, so charly core references it without importing this package) — Walk itself calls the seam and never does the coupled work directly (boundary law clause D: Walk consults host-threaded DATA, never the provider registry).
Faithful-port mapping (see charly/unified.go + charly/ns_identity.go):
LoadUnified (the walk portion only) → Walk loadUnifiedInto → (*walker).walkFile mergeUnifiedDocs (the parse portion) → (*walker).parseDocs (materialize/mergeUnified excluded) loadNamespaceCached → (*walker).walkNamespace the per-project "load + discover" body → (*walker).walkProject ApplyDiscover/… → discover.go
The kind-blind document DIRECTIVES (kit.ImportList/kit.DiscoverConfig/kit.ClassifyDoc/ kit.FindEntityDirs/…) live in sdk/kit (loader_directives.go/loader_classify.go/ loader_discover.go), shared with charly core (R3) — this package keeps only its own walk-scoped namespace-alias validation (directives.go).
Index ¶
- Constants
- func GitRemoteIdentity(dir string) string
- func NormalizeGitRemoteURL(raw string) string
- func NormalizeRepoIdentity(s string) string
- func NormalizeRepoSpec(spc string) (repoPath, version string)
- func ParseDoc(doc *yaml.Node, t spec.Threaded) (directives map[string]*yaml.Node, pp spec.ParsedProject, err error)
- func QualifyRemoteSiblingDeps(repoPath, subPathPrefix string, refs *spec.CandyRefs)
- func RepoIdentity(ref, baseDir string) string
- func RootRepoIdentity(dir string) string
- func ScanCandyManifest(path, name, manifestName string, ...) (spec.CandyModel, spec.CandyView, spec.CandyRefs, error)
- func ScanInlineCandy(name, sourceDir string, ly *spec.CandyYAML) (spec.CandyModel, spec.CandyView, spec.CandyRefs)
- func ScanRemoteCandy(repoDir, repoPath string, wantRefs map[string]bool, ...) (map[string]spec.ScannedCandy, error)
- func Walk(rootDir string, rootData []byte, rootIdentity string, seams spec.WalkSeams) (spec.LoadedProject, error)
Constants ¶
const MaxIncludeDepth = 8
MaxIncludeDepth caps recursive include resolution. A cycle or excessive depth raises a clear error with the offending file path.
Variables ¶
This section is empty.
Functions ¶
func GitRemoteIdentity ¶ added in v0.2026198.2057
GitRemoteIdentity returns the normalized `host/owner/repo` identity of dir's git `origin` remote, or "" when dir is not a git repo / has no origin / git is unavailable.
func NormalizeGitRemoteURL ¶ added in v0.2026198.2057
NormalizeGitRemoteURL strips the scheme / `git@` / `.git` decorations from a git remote URL, leaving `host/owner/repo`. scp-style (`git@host:owner/repo`) and scheme URLs (`https://`, `ssh://`, `git://`, with optional `user@`) are both handled. A value already in `host/owner/repo` (or bare `owner/repo`) form passes through unchanged.
func NormalizeRepoIdentity ¶ added in v0.2026198.2057
NormalizeRepoIdentity normalizes an explicit `repo:` value (which may be a full git URL, an scp-style ref, or a bare `owner/repo`) to the `host/owner/repo` form ParseRemoteRef produces — so an explicit declaration and a remote `@`-ref compare equal. Reuses NormalizeRepoSpec's bare-`owner/repo` → github.com rule.
func NormalizeRepoSpec ¶ added in v0.2026198.2057
NormalizeRepoSpec turns a user-supplied --repo spec into a (repoPath, version) pair suitable for a repo-cache download. Spec formats:
"default" → (spec.DefaultProjectRepo, "")
"owner/repo" → ("github.com/owner/repo", "")
"owner/repo@ref" → ("github.com/owner/repo", "ref")
"host/owner/repo[@ref]" → used literally
An empty version means "resolve to default branch at lookup time".
func ParseDoc ¶
func ParseDoc(doc *yaml.Node, t spec.Threaded) (directives map[string]*yaml.Node, pp spec.ParsedProject, err error)
ParseDoc decomposes a node-form document mapping into its reserved directives + the generic spec.ParsedProject (its top-level entity nodes, each with the opaque JSON body the host materializes). Faithful port of core's parseNodeTree + genericNodeToParsed.
func QualifyRemoteSiblingDeps ¶ added in v0.2026198.2057
QualifyRemoteSiblingDeps records, for a freshly-scanned remote candy, the fully-qualified "<repo>/<subpathprefix><dep>" map key of each plain-name require:/candy:/bake_plugin: dep — the same form the fetched-sibling scan keys under. It sets each ref's resolved key (CandyRefEntry.Resolved) and leaves CandyRefEntry.Raw intact, so the graph resolves on .Bare() (qualified) while the transitive fetch loop still keys on the original .Raw plain name. @-ref deps are left untouched — their bare path already resolves directly. Ported verbatim from the pre-move charly/layers.go qualifyRemoteSiblingDeps, retargeted at the CandyRefs carrier (the live *Candy's Require/IncludedCandy/BakePlugin fields this mutated in place pre-move).
func RepoIdentity ¶ added in v0.2026198.2057
RepoIdentity returns the canonical repo identity of an import ref, or "" when it can't be determined (in which case the loader degrades to version-keyed behavior). A remote `@host/org/repo[/sub]:ver` ref yields `host/org/repo` directly (no fetch, no git); a local path yields the git `origin` identity of the target directory.
func RootRepoIdentity ¶ added in v0.2026198.2057
RootRepoIdentity determines the local root project's own repo identity for cycle-break registration. An explicit `repo:` field in charly.yml is authoritative; otherwise it falls back to the `git remote origin` identity of the working tree. Returns "" when neither is available (the loader then behaves exactly as before — version-keyed, no self-identity short-circuit).
func ScanCandyManifest ¶ added in v0.2026198.2057
func ScanCandyManifest(path, name, manifestName string, parseDoc func(path string) (*spec.CandyYAML, error)) (spec.CandyModel, spec.CandyView, spec.CandyRefs, error)
ScanCandyManifest scans a single candy DIRECTORY (the `from:`-directory / legacy-discovered-candy path) and returns its two resolved envelope views. Named distinctly from the ESTABLISHED exported charly.ScanCandy(dir) (the whole-project scan-all-candies entry point) to avoid confusion between the two similarly-shaped-but-different scans while both exist side by side during the cutover. parseDoc is the injected per-document parse seam (charly's parseCandyYAML — registry-coupled, so it stays host-side; see the CandyScanner interface doc in sdk/spec/loader_seam.go).
func ScanInlineCandy ¶ added in v0.2026198.2057
func ScanInlineCandy(name, sourceDir string, ly *spec.CandyYAML) (spec.CandyModel, spec.CandyView, spec.CandyRefs)
ScanInlineCandy builds the two resolved envelope views + the rich pre-qualification refs for a candy declared INLINE in a unified charly.yml (no separate manifest file — ly is already the parsed body). sourceDir is the charly.yml's own directory (an inline candy's SourceDir always equals its declaring file's dir). Mirrors the pre-move charly/unified.go synthesizeInlineCandy, which called the SAME populateCandyFromYAML + fs-probe pair scanCandy did — the two paths can never drift because they share this one function.
func ScanRemoteCandy ¶ added in v0.2026198.2057
func ScanRemoteCandy(repoDir, repoPath string, wantRefs map[string]bool, parseDoc func(path string) (*spec.CandyYAML, error)) (map[string]spec.ScannedCandy, error)
ScanRemoteCandy scans specific candies out of a downloaded remote repository directory — only the bare refs in wantRefs (each "github.com/org/repo/candy/name" form, keyed by that same bare ref in the returned map). Ported verbatim from the pre-move charly/layers.go ScanRemoteCandy: for each wanted ref, ScanCandyManifest the candy dir, then set the resulting CandyView's Remote/RepoPath/SubPathPrefix (the post-scan "construct-then-mutate" step scan-time cannot do itself — a candy doesn't know it's REMOTE until the fetch layer resolves it there) and qualify its plain-name sibling deps (QualifyRemoteSiblingDeps) so the dependency graph + validator can resolve a remote candy's transitive deps against siblings pulled from the same repo, without per-call-site repo-path plumbing.
func Walk ¶ added in v0.2026194.1400
func Walk(rootDir string, rootData []byte, rootIdentity string, seams spec.WalkSeams) (spec.LoadedProject, error)
Walk walks a project rooted at rootDir and returns its kind-blind parse envelope. rootData is the (possibly bootstrap-transformed) bytes of the root charly.yml — used for the root file instead of re-reading; pass nil for a namespace child (read from disk). rootIdentity is the root project's own repo identity (the host's rootRepoIdentity), seeded into the cycle-break so a transitive self-import resolves to the in-progress root — mirrors LoadUnified seeding loadingRepos[rootRepoIdentity(dir)] = merged BEFORE the walk starts.
Types ¶
This section is empty.