Repository navigation
fix(loadmodel): fold every alias of a shared namespace template map - #155
Conversation
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)
Review — BLOCKHead SHA: Change class: Security screen: PASS — no secrets/egress, no new deps, no weakened gate (the Blocks
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
…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)
Review — PASSHead SHA: Security screen: PASS — no secrets/egress/new deps, no guardrail weakening (the Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
Summary of changes
Fix a latent namespace-folding defect in
UnifiedFile.ProjectTemplates()exposed by making bed validation namespace-aware (the check-bed roster cutover).fillNamespacedTemplatescarried 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 atcharly.arch,charly.cachyos.arch(via cachyos'sarchimport),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 itsfrom: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):
sortedRawKeysin the new test now actually sorts (its name promised determinism).ProjectTemplatescomment no longer claims to mirrorFillBoxPlans's guard — that guard had the SAME global-visited bug and is fixed in the sibling fix(loaderkit): preserve PluginKinds at every diamond/multi-alias namespace path sdk#283 (FillBoxPlans+materialize_wire.go).Adds
spec/loadmodel_templates_multialias_test.go(_MultiAliasSharedNamespacefails without the fix;_SelfCycleTerminatesproves termination).Additive/fix only: no
#SchemaVersionbump, 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
go test ./spec/, plus the new test FAILING without the change (proof below).N/A (contract module, no deployable beds).N/A— no binary.go test; the real multi-namespace project load reproduced the symptom.N/A.1. Gate output (verbatim):
2. Changed code path executing (verbatim
-v):3. Coverage FAILS without the change (proof): removing
defer delete(ancestors, uf):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>)/charly-internals:go,/charly-internals:plugin.FillBoxPlans,materialize_wire.go) are in sdk#283.visitedparam name is gone fromfillNamespacedTemplates(ancestorsnow).git statuschecked; no destructive action.N/A— contract module; logic unit-gated + symptom reproduced live.N/A.N/A.N/Afor beds; §3 pastes the fail-without-change proof.N/A.gofmtclean;go testgreen.N/A— post-merge bytag-on-mergefrom this body.Assisted-by: opencode deepseek-v4.1-flash (fully tested and validated)