gunk-dev/the-valley
the-valley:oc-d994dc4outcomedone

The restacker publishes families, writes reports and recovers

State
done
Created
2026-10-17 by contributor
Source
2026-10-17, restacker slice 5 split after the 5a brief critique
Blocked by
Blocks

Body

Publication, reports and recovery on top of the planner. Notes from the 5a brief critique (Codex, 2026-10-17), to carry into its brief:

- rebase AppendVersion derives the title from the commit subject, but the hook requires the previous recorded title under restack authority: preserve it. Check exact branch, requests and landing evidence before each append; do not use AppendAll blindly.
- The report format records absence only for branch_tip, holds recorded changes only (no plain branches), and allows at most 64 layers: keep full observations in the local journal, report recorded changes with bounded refusal details, and define oversized families without a schema change.
- Bound every subprocess: rebase/prepare.go cleanup and Release use context.WithoutCancel, and network subprocess groups differ in rebase/git.go.
- Race tests need deterministic transport barriers that delegate to the real receive-pack and rendered hook (valley-ready.sh relies on a post-rewrite hook the controller disables); adapt rebase_test.go dropped-acknowledgement helper for lost responses.
- Run valley-ready and integrator-e2e too.

Comments

  1. contributor2026-10-18 13:46 UTC
    From the planner (wslz, 2026-10-18): its e2e injects every integrator outcome with update-ref and wires no verifier keys, so a landing proved only by integrator evidence and a real reject (signed wrong-kind evidence) are untested. The publication slice must cover both with the real integrator and a fixture that has verifier keys, since it is the one that pushes.
  2. contributor2026-10-19 11:54 UTC
    Brief for this slice, prepared 2026-10-19:
    
    # the-valley: the restacker publishes families, writes reports and recovers
    
    ## Why
    
    The restacker keeps ready changes based on `main`: after `main` moves, it rebases every eligible change family through the host hook, as its own principal, and reports conflicts. Its read-only planner has landed (`valley-restacker once --report-only`, module `restack/`). This slice makes it act: publish the planned families, append versions, write reports, and recover from interruption. The loop mode and the NixOS service are the next slice; don't build them.
    
    ## Read first
    
    - The design: `valley knot show oc-adc7b2b` in this repository (its body is the design, rev 2; its comments hold the coordinator's review). Sections 3–5 and the threat model are this slice.
    - This slice's own notes: `valley knot show oc-d994dc4` (the body and comments hold findings from earlier critiques that this slice must address).
    - What exists: `restack/` (the planner: selection, families, request holds, capacity), `rebase/` (Capture, Prepare, Publish, Append, structured results, ReadReport), `composed/` (the composed-policy reader and the cap), `change/report.go` and `valleyhook/report.go` (the report format and the hook's rules for it), `valleyhook/record.go` (the `restack` transition), `docs/architecture.md` ("The restacker", "Restack reports").
    
    ## Build
    
    1. **`valley-restacker once` without `--report-only` publishes**, for each family the planner would restack: Prepare → one atomic leased branch push (Publish) → append versions one change at a time, lower layers first. Before each append, re-check exactly: the branch equals the prepared head; the record is ready with the captured active head; no related integration request appeared that might still land; the change hasn't been submitted. Stop the family's remaining appends on any mismatch and report `partial`. Don't use `AppendAll` blindly.
    2. **Preserve the title.** Under `restack` authority the hook requires the new version to keep the active version's branch and title (`valleyhook/record.go`), but `rebase.AppendVersion` derives the title from the commit subject. Fix the library so a restack append carries the active version's title, without changing the manual paths' behaviour.
    3. **Reports.** After each family's outcome, push a report to `refs/the-valley/restack/main/<change-id>` for each recorded change in it: `conflict`, `blocked`, `partial`, `complete` or `superseded`, with what `change/report.go` can record (observed refs including absence, published heads, bounded conflict paths and refusal details). Plain branches aren't report layers. Keep the full observations in the local journal. A family over the report format's 64-layer limit is held and reported on its bottom recorded change, without a format change. Don't push a report whose observations and result equal the change's current one.
    4. **Journal and recovery.** A journal in the state directory, flushed before phase 1: captured refs, old and new heads, leases, and each layer's result. On start, and after an unknown push result: re-read origin; determine which branches moved and which versions appended; retry only appends whose branch still equals the prepared head and whose record is still ready at the captured head; re-check requests and landing evidence; stop on author movement, withdrawal, submission or incompatible target history. Transient failures back off within a bound. A lost journal produces a report of the mismatch, never an inferred repair.
    5. **Bound every subprocess.** `rebase/prepare.go`'s cleanup and `Release` use `context.WithoutCancel`, which drops deadlines; give them a bounded context. Make sure network commands (`ls-remote`, `fetch`, `push`) are bounded too.
    
    ## Tests
    
    End to end through real pushes and the rendered host hook, extending `restack-e2e`:
    - **A fixture with verifier keys and request authority**, and the **real integrator**, so that a landing proved only by integrator evidence is recognised as submitted, and a real `reject` (the signed wrong-kind evidence scenario) is classified from a real outcome. The planner's tests injected every outcome; this slice publishes, so it must not.
    - Publishing: a linear stack and a shared lower layer each restack and gain one version per change, titles preserved; a conflict moves nothing and reports `conflict`; an unchanged conflict isn't re-reported.
    - Races, with deterministic transport barriers that delegate to the real `receive-pack` and the rendered hook (the controller disables git hooks, so `valley-ready.sh`'s post-rewrite trigger can't be reused): an author push between capture and publish loses the lease cleanly; a request filed between branch publication and the appends yields `partial`.
    - Recovery: killed before publication, after branch publication, and after each append; a dropped push acknowledgement (adapt `rebase_test.go`'s helper); each completes idempotently on restart or stops safely; a lost journal is reported.
    - Capacity: a change at its lifetime cap is held, and the count includes this principal's earlier uploads.
    
    Checks, each one at a time with `nix build --no-link .#checks.x86_64-linux.<name> -L`: `restack-unit`, `restack-e2e`, `rebase-unit`, `valleyhook-unit`, `protect-e2e`, `integrator-unit`, `integrator-e2e`, `valley-ready`, `valley-status`, `valley-go-unit`, `own-policy`, `prose-format`, and any check the policy requires for the paths you change. Never `nix flake check`.
    
    ## Constraints
    
    - **No schema, policy-format or report-format change.** A schema field used in the same change blocks every landing until the tools are bumped (bug `bd-5859932`). If you think one is needed, stop and report.
    - Platform logic in Go; Bash only as thin glue in tests. No new third-party Go dependencies.
    - Never run a tmux command against the shared server; if a test needs tmux, use `env -u TMUX tmux -S <a socket under your scratch dir>`. Don't leave `go build` output in module directories.
    - Docs: extend "The restacker" and "Restack reports" in `docs/architecture.md`, present tense; keep to those sections (a docs restructuring is in flight elsewhere).
    - Vocabulary: a change is ready, approved, submitted; it requires checks. No attribution lines in commits.
    
    ## Delivery
    
    Push your topic branch to origin; never push main. Report: what publishing does step by step, the title fix, the journal format, which scenarios use the real integrator, each check's result, and anything in the design you couldn't follow and why.
  3. contributor2026-10-19 11:56 UTC
    Critique of the first publishing brief (Codex, 2026-10-19). The foundations it asks for are now knot-tracked separately; what remains for this slice: recheck eligibility (new requests, submission, target movement) immediately before branch publication and acknowledge the residual race; persist durable intent for each write before pushing and keep the journal until reports are confirmed; bounded fallback reports when change/report.go limits (requests, name lengths, control characters, 64 KiB total) would overflow, with omitted observations kept locally and tested with unusual filenames; publish as the restacker principal, not requester. Full critique:
    
    The brief correctly builds on Capture, Prepare, Publish, per-layer Append, structured results, and ReadReport rather than proposing another rebase engine. It also correctly identifies the title mismatch and preserves the distinction between atomic branch publication and separate record appends.
    
    Both knot commands failed on SSH configuration permissions, and no local refs/the-valley/knots ref exists. Supply pinned knot bodies and comments with the brief; their requirements could not be verified here.
    
    The scratch repository lacks a commit identity. restack/main.go:161 disables global configuration, while rebase/record.go:44 invokes commit-tree without supplying one; preparation also needs a committer. Explicitly configure the controller’s identity and test with all inherited identity variables absent.
    
    The existing fixture uses requester, whose request grant bypasses the restack-specific restrictions (valleyhook/record.go:264). Run publication as the distinct restacker principal, file requests separately as requester, and give a change a title different from its commit subject so the title regression is actually exercised.
    
    The real-integrator scenarios need more fixture work than stated. nix/checks/restack.nix supplies neither the integrator nor signing tools, and hosts.nix:120 points the hook at an unavailable verifier file. Require a sandbox verifier path shared by hook and controller, signing keys, and the policy/evaluator fixtures from integrator/e2e/run.sh:520 for the wrong-kind rejection.
    
    The last eligibility check is too late. rebase/publish.go’s revalidate checks record movement, but not new requests, submission, or target movement; the brief adds those checks only before appending. Recheck eligibility immediately before branch publication, and explicitly acknowledge the remaining race because those refs are outside its leases.
    
    “Re-check exactly” overstates what AppendVersion guarantees. rebase/record.go:321 accepts a prepared head anywhere in the branch’s ancestry, and only the record update is leased. Add an explicit restack append mode with branch equality checked internally; document that a client-side check cannot make branch equality atomic with the record push.
    
    Recovery needs durable intent for each write, not merely a journal before phase 1. AppendVersion constructs and pushes the record before returning its commit ID (rebase/record.go:359), so interruption can precede recording that identity. Separate construction from pushing, persist the expected record/report commits and leases first, and retain the journal until reports are confirmed.
    
    Concurrent invocations and state reuse are unspecified. scratchRepo rewrites origin on every invocation (restack/main.go:183), so another once can redirect recovery or race its journal. Lock the state directory across the operation and bind journals to repository, target, and principal.
    
    Bounding rebase cleanup and network calls does not bound every subprocess. composed/composed.go:200 and :222 use context-free exec.Command, while restack/main.go:193 lacks output-wait bounds. Include policy composition and local Git helpers in the timeout work, with hanging-child tests.
    
    The report overflow rule covers only layers. change/report.go also limits requests, request-name length, control characters, and total blob size; individually valid fields can exceed 64 KiB. Define bounded fallback reports, retain omitted observations locally, and test overflow and unusual filenames.
    
    The single most useful change is to split this oversized slice: first land the restack append contract, bounded subprocess APIs, and authenticated integrator/transport fixtures; then implement publication, journaling, recovery, and reports together. Keep crash recovery in the same slice that first enables writes.
    
    [exited with code 0]
  4. contributor2026-10-19 13:16 UTC
    From the foundations fix run (wuom v2, 2026-10-19), left for this slice: the controller scratch repository still inherits GIT_DIR, GIT_WORK_TREE and similar variables that point git at another repository; strip every git location and config-injection variable from the subprocess environment before the controller writes anything. Also: if stderr is blocked as well as stdout, the final error message can hang the process (after the lock is released).
  5. contributor2026-10-20 12:04 UTC
    Critique of the second publishing brief (Codex, 2026-10-20); its split now governs: oc-562c2c6 builds everything without pushing; this slice then enables publication, report pushes and recovery together.
    
    The brief correctly builds on the landed append APIs, report writer, state lock, and authenticated fixtures. Keeping publication and recovery together avoids shipping writes that cannot be reconciled after interruption.
    
    The inherited instructions conflict on oversized families. The earlier brief in oc-d994dc4 says families over 64 layers are held and reported only on their bottom recorded change; this brief says publish every planner-eligible family and report each change. Fix: explicitly supersede that rule or retain it, and specify the corresponding test.
    
    Request matching does not fully implement the referenced design. restack/plan.go:111 collects active heads only; historical versions contribute branch names but not heads, so an arbitrarily named request for an older version can escape the hold. Fix: include every historical version head in exact-head and range matching, with regression tests.
    
    “Keep the full observation” cannot use the current conflict result unchanged. rebase/prepare.go:150 truncates conflict paths to 20, defined in rebase/family.go:456, before returning. Fix: preserve the complete conflict observation separately from the bounded report and test more than 100 conflicting paths.
    
    The foundations’ persistence form covers only pending versions and reports, not branch publication (rebase/pending.go:28). Prepared also contains pointer-keyed heads and private retention refs (rebase/prepare.go:25). Fix: explicitly require a validated branch-operation journal representation and durable object retention; clarify that new local journal formats are allowed by “no schema change.”
    
    Report equality is underspecified. Reports contain an operation identifier (change/report.go:136), so rebuilding an identical observation under a new operation makes literal equality fail. Fix: define semantic deduplication that excludes attempt identity and preserves enough local observation data to distinguish truncated fallbacks.
    
    Some required reports cannot land. If an authorized principal deletes a change record during recovery, valleyhook/report.go:80 rejects its report permanently, contradicting unconditional retention “until reports are confirmed.” Fix: define a terminal local failure for deleted records, retain its diagnostic evidence, and allow unrelated families to proceed.
    
    “On start” recovery can conflict with the push-free --report-only requirement. Fix: explicitly prohibit recovery pushes in that mode and test it against a journal containing pending branch, record, and report writes.
    
    The read-first scope also imports completed review work: design §5 includes the clean comparison and review interaction, beyond this controller slice. Fix: explicitly exclude those subsections and identify historical critiques as context where foundations already satisfy them.
    
    This is still too large for one reliable agent run. The single most useful change is to split off environment hardening, complete observation capture, and nonpublishing journal/report construction with recovery-state tests; then enable publication, report pushes, and recovery together in the following slice.
  6. contributor2026-10-21 01:10 UTC
    From sxup v2 (2026-10-21): plain branch names and request names that are not UTF-8 still cannot round-trip through the journal (they appear in layer names, reasons, request names and the rebase engine kept form of the branch). Encode them losslessly, as sxup did for conflict paths, before this slice enables pushes.
  7. contributor2026-10-27 17:19 UTC
    Landed with change wozu v7 (c2a5c586) on 2026-10-27.