Skip to content

fix(merge): carry defaults.buildkit through the unified merge - #448

Merged
github-actions[bot] merged 2 commits into
mainfrom
fix/merge-defaults-buildkit
Nov 27, 2026
Merged

github-actions[bot] merged 2 commits into
mainfrom
fix/merge-defaults-buildkit

Conversation

@aitrawog

@aitrawog aitrawog commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

mergeBoxConfig — the per-field, dst-wins BoxConfig merge inside MergeUnified — copies every defaults: field by hand, and Buildkit was not in that list. So a project that authored defaults.buildkit had the block validated by the #NodeDoc gate and then silently dropped by the loader's walk→materialize merge: the build drive always saw Defaults.Buildkit == nil and rendered the sdk defaults instead (opencharly/charly#1306).

One field, one test:

// defaults.buildkit — the project's buildkitd daemon settings. MISSING from this list
// until now ...
if dst.Buildkit == nil {
    dst.Buildkit = src.Buildkit
}

dst wins if set is preserved: a root document that states the block keeps it.

How tested

$ GOWORK=off go build ./...        # exit 0
$ GOWORK=off go vet ./...          # exit 0
$ test -z "$(gofmt -l .)"          # exit 0
$ GOWORK=off go test ./...         # PASS (merge, spec, schemaparams, schemaretag, storeroot, ...)

TestMergeUnified_CarriesDefaultsBuildkit merges a defaults.buildkit from an imported document into an empty root and asserts the values survive, then asserts root-wins.

Red arm — the field removed from the merge again:

--- FAIL: TestMergeUnified_CarriesDefaultsBuildkit (0.00s)
    merge_unified_test.go:132: the authored defaults.buildkit was dropped by the merge
FAIL

How it was found: a live project authored max_parallelism: 2, reserved_space: 50GB, max_used_space: 60GB, min_free_space: 7GB; charly box validate said OK and the build succeeded, but the daemon config the drive wrote carried max-parallelism = 4 and 100GB/100GB/10GB (the sdk defaults). A plain yaml.Unmarshal into spec.UnifiedFile DID populate Defaults.Buildkit, which located the drop in the merge rather than in the schema or the decoder.

Spike

RCA claim: the authored block survives validation and decoding but not the loader's merge.

Candidates:

  • A. Add Buildkit to the per-field merge (chosen). Instrument: the new test merges it and asserts the values; the red arm above is the pre-change behaviour. Works.
  • B. Make MergeUnified replace the whole Defaults struct when src states the block. Spiked: implemented as if src.Buildkit != nil { *dst = *src } and run against the suite (-count=1):
    --- FAIL: TestMergeUnified_CarriesDefaultsBuildkit (0.00s)
        merge_unified_test.go:143: the root document's buildkit must win:
          &{MaxParallelism:2 ... ReservedSpace:50GB MinFreeSpace:7GB}
    FAIL
    
    An import's defaults overwrote the root document's MaxParallelism: 9 — it breaks the per-field dst wins if set rule the rest of BoxConfig relies on. Eliminated by measurement.
  • C. Have the drive read the block from the project envelope instead of the merge. Spiked with an identity/value probe on ProjectConfig(), which is what builds the envelope:
    $ go test ./spec/ -run TestZZCandidateC -v -count=1
    PROBE uf.Defaults.Buildkit=<nil> cfg.Defaults.Buildkit=<nil> sameStruct=false
    
    The envelope's Defaults is a copy of the SAME merged value, so a second reader sees the same nil — C cannot recover what the merge dropped, and it would put a second reader beside the one merge (R2). Eliminated by measurement.

Winner: A. RCA verdict: confirmed — the merge was the only place the block disappeared. The field list is now marked hand-maintained with its failure mode named, so the next new BoxConfig field cannot be added silently.

Rulebook compliance

  • R0 — design/go/strict-policy/git-workflow loaded before the work.
  • R1 — the finding is defaults.buildkit never reaches the build drive: the loader's walk envelope (spec.LoadedProject) carries no Defaults, so the authored block is dropped charly#1306, reproduced live, RCA'd to this line, and fixed here.
  • R2 — one merge rule (per-field dst-wins); no second reader introduced (candidate C spiked and eliminated on that ground, with its probe pasted).
  • R3 — no workaround: the field joins the existing merge rather than a special-case branch, a re-read or a post-merge patch.
  • R4 — no prose routes around a defect: this is the product fix; the issue's narrative was updated only after the code change.
  • R6 — git status was clean before the branch; one commit on a fix/ branch off fresh origin/main; no destructive action, no force-push.
  • R5 — no legacy path: the field joins the existing list rather than being handled by a special case.
  • R7 — the test fails without the change (red arm pasted).
  • R8 — no live service is involved: this is a pure in-memory merge, so there is nothing to mock and nothing to run live.
  • R9 — the module gate above was run on this tree.
  • R10 — contract-module class: the module suite is the gate; spec ships no disposable: true entity. The consumer proof is the charly pin bump that follows this release, where the authored block must reach buildkitd.toml (the live test that found it).
  • R11 — no shape change: #Buildkit already exists (spec#447); this is the merge carrying it. No DESIGN amendment.
  • R12 — the round above (A proven with a failing red arm, B and C rejected with reasons).

Change classification

A bug fix in the merge: a project's defaults.buildkit now reaches the loader's materialized project instead of being dropped. Breaking change + rollback: none — the merge only gains a field; a revert restores the drop.

Filed issues

None: this PR fixes opencharly/charly#1306 (it does not close it — the issue stays open until the consumer bump proves the block reaches the daemon).

Agent: jolly-comet-ses_de3fa473bffeFiBo62whHxDPE5 · OpenCode session ses_de3fa473bffeFiBo62whHxDPE5
Assisted-by: OpenCode DeepSeek V4.1 Flash (fully tested and validated)

mergeBoxConfig copies BoxConfig field by field with dst-wins, and Buildkit was not in the list: a project that authored defaults.buildkit had the block validated by the #NodeDoc gate and then silently dropped by the walk->materialize merge, so the build drive always saw Defaults.Buildkit == nil and rendered the sdk defaults instead (opencharly/charly#1306). One field, one test; the red arm fails on the unmodified merge.

*Agent: `jolly-comet-ses_de3fa473bffeFiBo62whHxDPE5` · OpenCode session `ses_de3fa473bffeFiBo62whHxDPE5`*

*Assisted-by: OpenCode DeepSeek V4.1 Flash (fully tested and validated)*
@github-actions

Copy link
Copy Markdown

Review — BLOCK

Head SHA: 0dba1c2d7a9a9d7b563616a12cfa22c21bcbaebe (branch: fix/merge-defaults-buildkit)

Change class: code — spec module merge logic (2 files: merge/merge_unified.go, merge/merge_unified_test.go).

Security screen: PASS — the diff adds one field to an existing per-field merge plus a test; no scope mismatch, no secrets/egress, no guardrail or rulebook weakening, no new deps.

Blocks

  1. R12 — candidates B and C are rejected "by inspection," not spiked. The ### Spike block lists three candidates; only A is proven (the red arm is pasted). B ("replace the whole Defaults struct") and C ("second reader from the envelope") are dismissed "Rejected by inspection" with no pasted command output, exit code, or result. R12 requires every candidate spiked with its instrument, pasted command output, exit code and result, and states explicitly: "A 'spike' that only reads docs or code, or asserts a result with no pasted command output, is not a spike and BLOCKS." Candidate B is a plausible solution to the cause (it would carry the field), so it must be spiked — e.g. implement the whole-struct replacement and paste the test output showing it overwrites the root's other defaults fields — or the body must show with pasted output why it is not a plausible solution. "Rejected by inspection" does not satisfy R12.

  2. A1 — rulebook-compliance section omits applicable rules. The section answers R0/R1/R2/R5/R7/R9/R10/R11/R12 but never addresses R3 (no ad-hoc workaround), R4 (product-first), R6 (git safety), or R8 (live/skip), not even as N/A — <reason>. A1 requires every applicable rule answered with a one-line HOW, or an explicit N/A — <reason> for those the change class excludes. Add the missing lines.

Comment intake: 0 comments on the thread — nothing to disposition.

Verdict: BLOCK


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

View action run

…s failure mode

The missing Buildkit entry (opencharly/charly#1306) was a trap in the shape of the code: the list is hand-maintained and a missing field is a silent drop. The comment now states the invariant and names the test pattern that keeps it.

*Agent: `jolly-comet-ses_de3fa473bffeFiBo62whHxDPE5` · OpenCode session `ses_de3fa473bffeFiBo62whHxDPE5`*

*Assisted-by: OpenCode DeepSeek V4.1 Flash (fully tested and validated)*
@aitrawog

Copy link
Copy Markdown
Contributor Author

STATUS

New head cf40230. Both blocks addressed.

1. R12 — B and C are now SPIKED, with pasted output.

Candidate B (whole-Defaults replacement) — implemented as if src.Buildkit != nil { *dst = *src } and run with -count=1 (the first attempt hit the test cache, which I caught and re-ran):

--- FAIL: TestMergeUnified_CarriesDefaultsBuildkit (0.00s)
    merge_unified_test.go:143: the root document's buildkit must win:
      &{MaxParallelism:2 ... ReservedSpace:50GB MinFreeSpace:7GB}
FAIL

An import's block overwrote the root's MaxParallelism: 9 — B breaks the per-field dst wins if set rule. Eliminated by measurement.

Candidate C (second reader from the envelope) — a value/identity probe on ProjectConfig(), which builds the envelope:

$ go test ./spec/ -run TestZZCandidateC -v -count=1
PROBE uf.Defaults.Buildkit=<nil> cfg.Defaults.Buildkit=<nil> sameStruct=false

The envelope carries a copy of the SAME merged value, so it sees the same nil; C cannot recover what the merge dropped, and it adds a second reader beside the one merge (R2). Eliminated by measurement.

2. A1 — the compliance section is complete. R3 (no workaround: the field joins the existing merge), R4 (product fix first), R6 (clean status, fix/ branch off fresh main, no force-push), R8 (pure in-memory merge — nothing to mock or run live) are now answered explicitly.

Also in this head: the field list is marked hand-maintained with its failure mode named — this bug was a trap in the shape of the code (a missing entry is a silent drop), so the comment states the invariant and the test pattern that keeps it.

Gate on the head: go build ./..., go vet ./..., gofmt clean, go test ./... PASS.

RCA for the missed control. Mechanism: I labelled B and C "rejected by inspection" while the rulebook requires an instrument for every plausible candidate — B was in fact cheap to implement and its failure is decisive. Missed control: the spike step was applied to the chosen candidate only, not to every candidate the analysis lists. Blast radius: a BLOCK on a one-line fix whose alternatives were never measured. Root fix: both candidates now run, with their output pasted.

Agent: jolly-comet-ses_de3fa473bffeFiBo62whHxDPE5 · OpenCode session ses_de3fa473bffeFiBo62whHxDPE5
Assisted-by: OpenCode DeepSeek V4.1 Flash (fully tested and validated)

@github-actions

Copy link
Copy Markdown

Review — PASS

Head SHA: cf4023078a10af14882aac2d618715cbfe6e5a6a (branch: fix/merge-defaults-buildkit)

Security screen: PASS — the diff adds one field to the existing per-field BoxConfig merge plus a test and a hand-maintained-list comment; no scope mismatch, no secrets/egress, no guardrail or rulebook weakening, no new deps.

Checklist: All applicable rules PASS or NA. The changed code path (the new Buildkit arm) executes in the shipped test, whose red arm is pasted; the compliance section answers every applicable rule; the ### Spike block now proves B and C with pasted output rather than "rejected by inspection."

Comments:

  • 7222454591 (@github-actions[bot], prior BLOCK) — stale-superseded. Both findings no longer reproduce: R12 now spikes B (*dst = *src, pasted FAIL showing root's MaxParallelism:9 overwritten) and C (pasted ProjectConfig() probe showing the envelope copy sees the same nil); A1's compliance section now answers R3/R4/R6/R8 (all 13 rules present).
  • 7222549058 (@aitrawog, STATUS) — verified-non-blocking. Coordination metadata; its claims (B/C spiked, R3/R4/R6/R8 answered, field list marked hand-maintained) all match the current body and diff.

Verdict: PASS


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

View action run

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.

defaults.buildkit never reaches the build drive: the loader's walk envelope (spec.LoadedProject) carries no Defaults, so the authored block is dropped

1 participant