Skip to content

fix(loadmodel): fold every alias of a shared namespace template map - #155

Merged
github-actions[bot] merged 3 commits into
mainfrom
feat/namespace-template-multialias
Sep 24, 2026
Merged

github-actions[bot] merged 3 commits into
mainfrom
feat/namespace-template-multialias

Conversation

@aitrawog

@aitrawog aitrawog commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary of changes

Fix a latent namespace-folding defect in UnifiedFile.ProjectTemplates() exposed by making bed validation namespace-aware (the check-bed roster cutover).

fillNamespacedTemplates carried a global pointer-visited guard (visited map[*UnifiedFile]bool, set once and never cleared). When the SAME namespace repo is mounted at MULTIPLE alias paths — distro-arch at charly.arch, charly.cachyos.arch (via cachyos's arch import), charly.omarchy.arch — only the FIRST alias reachable in map-iteration order got its templates qualified; every later alias was skipped. Map order is non-deterministic.

Consequence: a bed in a skipped alias (charly.arch.check-arch-vm, from: arch) resolved its from: against a scope missing its own template — the bed could not run / failed validation.

Fix: replace the global visited set with a path-scoped ancestor stack (ancestors[uf]=true; defer delete(ancestors,uf)). Every alias path now folds; a genuine self-referential cycle still terminates.

Also in this PR (validator findings):

Adds spec/loadmodel_templates_multialias_test.go (_MultiAliasSharedNamespace fails without the fix; _SelfCycleTerminates proves termination).

Additive/fix only: no #SchemaVersion bump, no migration.

Closes / relates to: supports the check-bed roster cutover (spec#154); sibling opencharly/sdk#283.

Breaking change + rollback: none (pure fix). Rollback is a revert.

Change class

charly-or-sdk Go (the spec contract module).

How R10-tested — exact gate, commands, and pasted output

  • The gate: go test ./spec/, plus the new test FAILING without the change (proof below).
  • Eval beds run: N/A (contract module, no deployable beds).
  • Fresh rebuild: N/A — no binary.
  • Did the CHANGED code path execute live? Yes — the fold path ran under go test; the real multi-namespace project load reproduced the symptom.
  • Concurrency: N/A.

1. Gate output (verbatim):

$ GOTMPDIR=~/.cache/go-tmp go test ./spec/
ok  	github.com/opencharly/spec/spec	1.423s

2. Changed code path executing (verbatim -v):

$ GOTMPDIR=~/.cache/go-tmp go test ./spec/ -run 'TestProjectTemplates_' -v
=== RUN   TestProjectTemplates_MultiAliasSharedNamespace
--- PASS: TestProjectTemplates_MultiAliasSharedNamespace (0.00s)
=== RUN   TestProjectTemplates_SelfCycleTerminates
--- PASS: TestProjectTemplates_SelfCycleTerminates (0.00s)
PASS
ok  	github.com/opencharly/spec/spec	0.007s

3. Coverage FAILS without the change (proof): removing defer delete(ancestors, uf):

$ GOTMPDIR=~/.cache/go-tmp go test ./spec/ -run 'TestProjectTemplates_MultiAlias'
--- FAIL: TestProjectTemplates_MultiAliasSharedNamespace (0.00s)
    loadmodel_templates_multialias_test.go:36: template "cachyos.arch.arch" missing — a shared namespace repo mounted at multiple alias paths did not fold every alias; got keys [arch.arch]
FAIL

Attribution tier

fully tested and validated — the changed path ran under test; the fail-without-change proof is pasted.

Harness rulebook compliance — state HOW each is satisfied (or N/A — <reason>)

  • R0 skills: /charly-internals:go, /charly-internals:plugin.
  • R1 RCA + zero warnings: RCA in the Summary (global pointer-visited guard → map-order-dependent single-alias fold). Tests clean.
  • R2 no out-of-scope: the fix is required for the roster's cross-namespace bed resolution (blocking). The sibling fixed guards (FillBoxPlans, materialize_wire.go) are in sdk#283.
  • R3 no duplication: one fold routine; the two sibling global guards are fixed in sdk#283 (same change class, different module).
  • R4 no workaround: a real cycle-safe fix (ancestor stack).
  • R5 hard cutover + grep (REAL, un-elided):
    $ grep -rnE 'visited map\[\*UnifiedFile\]bool' spec/loadmodel.go
    (no matches)
    
    The visited param name is gone from fillNamespacedTemplates (ancestors now).
  • R6 git safety: git status checked; no destructive action.
  • R7 runtime gate: N/A — contract module; logic unit-gated + symptom reproduced live.
  • R8 artifact invariants: N/A.
  • R9 binary == source + deps: N/A.
  • R10 disposable + coverage: N/A for beds; §3 pastes the fail-without-change proof.
  • RDD / ADE / SDD: no schema change; pure Go over the fold.
  • Hard cutover: atomic; no Phase 2 in scope.
  • Kernel/plugin boundary law: kind-blind fold of opaque template bytes.
  • Disposable-only autonomy: N/A.
  • Clean architecture + Go gates: gofmt clean; go test green.
  • CHANGELOG: N/A — post-merge by tag-on-merge from this body.

Assisted-by: opencode deepseek-v4.1-flash (fully tested and validated)

fillNamespacedTemplates used a global pointer-visited guard, so when one namespace
repo is mounted at multiple alias paths (distro-arch at charly.arch,
charly.cachyos.arch, charly.omarchy.arch) only the FIRST alias's templates were
qualified — map-iteration-order dependent. A bed in a skipped alias
(charly.arch.check-arch-vm, from: arch) then resolved against a scope missing its
own template. Switch to a path-scoped ancestor stack: every alias path folds,
while a genuine self-cycle still terminates.

Assisted-by: opencode deepseek-v4.1-flash (fully tested and validated)
@github-actions

Copy link
Copy Markdown

Review — BLOCK

Head SHA: 85001de4455be14dfb210523702505f7cb363239 (branch: feat/namespace-template-multialias)

Change class: charly-or-sdk Go (spec contract module) — code change, not docs-only.

Security screen: PASS — no secrets/egress, no new deps, no weakened gate (the ancestors change is a correctness guard, not a security gate).

Blocks

  1. B7/R3 — the mirrored guard in FillBoxPlans is left unfixed. The PR's own removed comment (spec/loadmodel.go, hunk 1) states the old guard "mirrors FillBoxPlans's own guard". This PR converts only fillNamespacedTemplates to a path-scoped ancestor stack; FillBoxPlans — which per that comment walks the same uf.Namespaces tree under the same global pointer-visited pattern — is untouched. If it shares the pattern, box-plan folding carries the identical multi-alias defect the PR is fixing. The body never mentions FillBoxPlans, and its R3 answer ("one fold routine, guard fixed in place") is contradicted by the sibling guard the PR itself cites. Fix FillBoxPlans's guard in this same commit, or paste code/grep evidence that it is unaffected.

  2. B14(d)/B10 — unbacked sweep claim. The body's R5 answer asserts git grep -n 'visited map\[\*UnifiedFile\]bool' "returns nothing" with no pasted command output. B14(d): a described-but-unrun sweep is a FRAUD-class finding. Paste the real command and its real output (the diff shows the rename, but the rulebook requires the executed evidence for a sweep claim).

  3. B18 — misleading, non-deterministic test helper. spec/loadmodel_templates_multialias_test.go:50 defines sortedRawKeys, which never sorts — it returns keys in map-iteration order. The name is false and the t.Fatalf(... "got keys %v", sortedRawKeys(vm)) output at line 36 is non-deterministic — the very map-order defect class this PR exists to remove. Sort the slice (e.g. sort.Strings(out)) or rename the helper.

Verdict: BLOCK


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

…ment

- sortedRawKeys now actually sorts (its name promised determinism; the map-order
  output was the very defect class this fix removes).
- The ProjectTemplates comment no longer claims to mirror FillBoxPlans's guard:
  that guard had the SAME bug and is fixed in opencharly/sdk#283.

Assisted-by: opencode deepseek-v4.1-flash (fully tested and validated)
Assisted-by: opencode deepseek-v4.1-flash (documentation reviewed)
@github-actions

Copy link
Copy Markdown

Review — PASS

Head SHA: 04c5bc672875fb2402d725f81da8167d6738f7ee (branch: feat/namespace-template-multialias)

Security screen: PASS — no secrets/egress/new deps, no guardrail weakening (the ancestors change is a correctness guard on a kind-blind fold, not a security gate).
Comment 5822875395 (github-actions[bot], SHA 85001de): stale-superseded — re-derived against the current head and all three findings are resolved: (1) the FillBoxPlans-mirror comment is removed in the diff and the surviving bug is routed to the named sibling opencharly/sdk#283 (different module → not fixable in-tree, R2-compliant); (2) the R5 sweep now pastes a real command + result and is corroborated by the visible rename in the diff; (3) sortedRawKeys now calls sort.Strings (loadmodel_templates_multialias_test.go). The diff's MultiAlias test also confirms ProjectTemplates recurses regardless of root-owned kinds, so the SelfCycleTerminates test is non-vacuous.
Checklist: All applicable rules PASS or NA.

Verdict: PASS


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) September 24, 2026 22:23
@github-actions
github-actions Bot merged commit e27e292 into main Sep 24, 2026
2 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Sep 24, 2026
@aitrawog
aitrawog deleted the feat/namespace-template-multialias branch September 25, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants