push landing: the worker rebases on live main and re-runs the seam before its close report #383

Open
opened 2026-11-20 14:06:43 +00:00 by ben · 2 comments
Owner

The change

In a LANDING=push repo, the worker rebases its branch on the live origin/main and re-runs the repo's test seam before it posts its close report. If the rebase conflicts, the worker settles the conflict itself, with the ticket still open and the whole task still in its head, and the reviewer sees the rebased result.

Ruled by Ben on 20 November 2026, as the answer to machinery: a push run strands verified work when two tickets each add a docs/GOTCHAS.md entry.

Why

Today the worker closes against the base it started from. The host then tries to push, finds main has moved, rebases, and if one hunk conflicts it parks the work on a rescue branch and reopens the ticket. The whole ticket is then built again from nothing.

On Matou/policy-generators, 20 November 2026, three reviewed tickets were thrown away this way, each for a single one-hunk conflict:

Run Ticket Run length File that conflicted Shape
809 #71 the operator page 40 min docs/GOTCHAS.md two entries appended with the same number
872 #66 tailoring 73 min server/src/policies/sections.ts two tickets each added a field to one return value
977 #75 the quiet period 99 min server/src/index.ts two tickets each added a registration line

The healer's write-ups are on that ticket and its two comments. The same signature (e9d7ba086503) appears in all three.

Repo conventions cannot close this. merge=union and one-file-per-entry only help append lists. Two of the three conflicts were in code, where keeping both sides would land broken TypeScript. Only a rebase done while the work is still open covers every shape.

What it would look like

  1. Before close-report, the worker (or the harness on its behalf) fetches origin/main and rebases the worker branch on it.
  2. A clean rebase: re-run the seam on the rebased tree. The close report's evidence is from that run.
  3. A conflict: the worker resolves it as part of the task, then re-runs the seam. The independent reviewer reviews the rebased diff.
  4. The host's own push-time rebase stays as the last line, for the short window between the close and the push. It should now almost never conflict.

What to weigh

  • A long seam run widens the window again. On policy-generators the seam takes a few minutes and runs are 40 to 100 minutes, so the window shrinks by more than ten times, but it does not reach zero.
  • A worker may be at its turn or usage limit when the rebase is due. The step must fail safe: no close, ticket left open with a clear note.
  • This overlaps push landing: close a ticket only after the host has verified its work is on main, which is held. That ticket makes "closed" true of main; this one makes the land succeed. They touch the same landing files, so they should be planned together.
  • Whether the rebase belongs in the worker prompt, in close-report.sh, or in a harness step between the two.

Also wanted: keep the resolver's log

All three healer write-ups say the same thing: the conflict resolver (landing_resolve_classified) ran, did not finish a hunk a person settles in ten seconds, and its log is rm -f'd on every path, so nobody can say why. Keep that log on a failed resolve (in the run's evidence directory), so the next failure can be read. This is small and can land on its own.

Checks

  • Offline test: in push mode, a worker branch behind origin/main is rebased before the close report, and the seam evidence in the report is from the rebased tree.
  • Offline test: a conflicting rebase does not close the ticket; the worker is given the conflict to resolve.
  • Offline test: a rebase step that cannot run (limit reached, fetch failed) leaves the ticket open with a note, and closes nothing.
  • Offline test: a failed resolve at the host's push-time rebase leaves its log in the run's evidence.
  • Offline test: PR mode behaves as before.

Not known

  • Why the resolver fails on these hunks. The log that would say is deleted.
  • How often a second conflict would appear in the short window that remains.

Filed by an interactive session in Matou/policy-generators, 2026-11-20, on Ben's ruling.

## The change In a `LANDING=push` repo, the worker rebases its branch on the live `origin/main` and re-runs the repo's test seam **before** it posts its close report. If the rebase conflicts, the worker settles the conflict itself, with the ticket still open and the whole task still in its head, and the reviewer sees the rebased result. Ruled by Ben on 20 November 2026, as the answer to [machinery: a push run strands verified work when two tickets each add a docs/GOTCHAS.md entry](https://git.matou.nz/Matou/policy-generators/issues/117). ## Why Today the worker closes against the base it started from. The host then tries to push, finds `main` has moved, rebases, and if one hunk conflicts it parks the work on a rescue branch and reopens the ticket. The whole ticket is then built again from nothing. On `Matou/policy-generators`, 20 November 2026, three reviewed tickets were thrown away this way, each for a single one-hunk conflict: | Run | Ticket | Run length | File that conflicted | Shape | |---|---|---|---|---| | [809](https://git.matou.nz/Matou/policy-generators/actions/runs/809) | #71 the operator page | 40 min | `docs/GOTCHAS.md` | two entries appended with the same number | | [872](https://git.matou.nz/Matou/policy-generators/actions/runs/872) | #66 tailoring | 73 min | `server/src/policies/sections.ts` | two tickets each added a field to one return value | | [977](https://git.matou.nz/Matou/policy-generators/actions/runs/977) | #75 the quiet period | 99 min | `server/src/index.ts` | two tickets each added a registration line | The healer's write-ups are on that ticket and its two comments. The same signature (`e9d7ba086503`) appears in all three. Repo conventions cannot close this. `merge=union` and one-file-per-entry only help append lists. Two of the three conflicts were in code, where keeping both sides would land broken TypeScript. Only a rebase done while the work is still open covers every shape. ## What it would look like 1. Before `close-report`, the worker (or the harness on its behalf) fetches `origin/main` and rebases the worker branch on it. 2. A clean rebase: re-run the seam on the rebased tree. The close report's evidence is from that run. 3. A conflict: the worker resolves it as part of the task, then re-runs the seam. The independent reviewer reviews the rebased diff. 4. The host's own push-time rebase stays as the last line, for the short window between the close and the push. It should now almost never conflict. ## What to weigh - A long seam run widens the window again. On `policy-generators` the seam takes a few minutes and runs are 40 to 100 minutes, so the window shrinks by more than ten times, but it does not reach zero. - A worker may be at its turn or usage limit when the rebase is due. The step must fail safe: no close, ticket left open with a clear note. - This overlaps [push landing: close a ticket only after the host has verified its work is on main](https://git.matou.nz/Matou/dev-factory/issues/361), which is held. That ticket makes "closed" true of `main`; this one makes the land succeed. They touch the same landing files, so they should be planned together. - Whether the rebase belongs in the worker prompt, in `close-report.sh`, or in a harness step between the two. ## Also wanted: keep the resolver's log All three healer write-ups say the same thing: the conflict resolver (`landing_resolve_classified`) ran, did not finish a hunk a person settles in ten seconds, and its log is `rm -f`'d on every path, so nobody can say why. Keep that log on a failed resolve (in the run's evidence directory), so the next failure can be read. This is small and can land on its own. ## Checks - Offline test: in push mode, a worker branch behind `origin/main` is rebased before the close report, and the seam evidence in the report is from the rebased tree. - Offline test: a conflicting rebase does not close the ticket; the worker is given the conflict to resolve. - Offline test: a rebase step that cannot run (limit reached, fetch failed) leaves the ticket open with a note, and closes nothing. - Offline test: a failed resolve at the host's push-time rebase leaves its log in the run's evidence. - Offline test: PR mode behaves as before. ## Not known - Why the resolver fails on these hunks. The log that would say is deleted. - How often a second conflict would appear in the short window that remains. Filed by an interactive session in `Matou/policy-generators`, 2026-11-20, on Ben's ruling.

This was generated by AI during triage.

Ruled by agent under ADR 0174 — veto anytime.

Category: enhancement. State: ready-for-session (not ready-for-agent).

Ruling

This is landing-architecture work in the push-mode land seam. Two things keep it out of the swarm-worker lane:

  1. It may edit a protected path. The issue leaves open where the pre-close rebase lives — "the worker prompt, close-report.sh, or a harness step between the two." The worker-prompt option is prompts/prompt.md, a prompt skeleton (live text for every future worker), which a swarm worker must never touch (per docs/agents/triage-labels.md, the ready-for-session role). Deciding where it lives is itself part of the work, and one of the three candidates is a protected path — so the decision belongs to an interactive session.
  2. It must be planned together with held #361. The issue states it overlaps #361 ("close a ticket only after the host has verified its work is on main") and that "they touch the same landing files, so they should be planned together." #361 is currently no-triage + priority — held for an interactive session, invisible to the swarm queue. A swarm worker claiming #383 in isolation (list-ready-tasks.sh reads only ready-for-agent) cannot honor "plan together" with a held ticket, and would risk landing a landing-architecture change the #361 session then has to work around. An interactive session can hold both in head and sequence them.

Neither crosses the ready-for-human bar (no Ben's-hands, no Ben's-eyes, no one-way door): the whole change is revertible landing code provable by offline tests. So it is a session ticket, not a human ticket.

Why this is a two-way door

It is a label change — fully revertible. If you want a swarm worker to take it instead, relabel ready-for-agent. The underlying work is ordinary landing-lib / close-report code behind the landing_mode_for / landing_* seam, reverted by a later commit.

What proves it

The existing offline landing seam — tests/landing-lib-test.sh (shimmed git/claude/curl, no network) — plus the five offline checks the issue already lists. No live door is needed to prove any leg of this.


Session brief

Category: enhancement
Summary: In LANDING=push, rebase the worker branch on live origin/main and re-run the test seam before the close report, so reviewed work is not thrown away by a one-hunk conflict at the host's post-close push.

Current behavior (verified in code):

  • The worker runs its close report against the base it started from. The host's post-run reconcile (landing-lib.sh, the git push origin HEAD:main → fetch → git rebase origin/main ladder) is the first place main's movement is seen. A clean rebase pushes; a conflict routes through landing_resolve_classified → landing_land_resolved_conflict, which parks the resolved commits on a sandcastle/rescue-* branch as a PR and reopens the ticket — the whole ticket is then rebuilt from nothing. On Matou/policy-generators, 2026-11-20, three reviewed tickets were discarded this way, each for a single one-hunk conflict (signature e9d7ba086503).
  • The rebase resolver's log is rm -f'd on every classified path (resolved / refused / unusable / failed), so a resolver that ran-but-could-not-finish leaves no record of why. (Confirmed: four rm -f "$log" sites in landing-lib.sh's reconcile.)

Desired behavior:

  1. In push mode, before the close report, fetch origin/main and rebase the worker branch on it.
  2. Clean rebase → re-run the repo's test seam on the rebased tree; the close report's evidence comes from that run.
  3. Conflict → the worker resolves it as part of the task (the whole task still in its head, ticket still open), re-runs the seam, and the independent reviewer reviews the rebased diff.
  4. The host's existing push-time rebase stays as the last line, for the short window between close and push — it should now almost never conflict.
  5. Fail-safe: a rebase step that cannot run (usage/turn limit reached, fetch failed) closes nothing — ticket left open with a clear note.
  6. PR mode (landing_mode_for ≠ push) is unchanged.

Severable sub-task — keep the resolver's log (small, can land on its own): on a failed/unresolved host-side resolve, write the resolver log into the run's evidence directory instead of deleting it (reuse the evidence seam, cf. evidence-lib.sh). The resolved-path deletion may stay. This has no overlap with #361 and no protected-path exposure — if the session wants, file it as its own ready-for-agent ticket so a worker can land it while the main rebase design is still being planned.

Design decisions for the session (do not pre-commit):

  • Where the pre-close rebase lives: worker prompt skeleton (protected — session-only) vs close-report.sh/close-report-lib.sh vs a new harness step. Prefer the lowest-blast-radius home that keeps the fail-safe guarantees; justify if the prompt skeleton is chosen (it re-renders into every consumer).
  • Sequencing with #361 (they share the land seam).
  • The seam-window trade-off: a long seam re-widens the race; it shrinks but never reaches zero.

Acceptance criteria (all offline, extend tests/landing-lib-test.sh):

  • Push mode: a worker branch behind origin/main is rebased before the close report, and the report's seam evidence is from the rebased tree.
  • A conflicting rebase does not close the ticket; the worker is given the conflict to resolve.
  • A rebase step that cannot run (limit reached / fetch failed) leaves the ticket open with a note and closes nothing.
  • A failed host-side resolve leaves its log in the run's evidence directory.
  • PR mode behaves exactly as before.
  • Every lib change ships its test update in the same commit; the full offline suite stays green.

Out of scope: diagnosing why the resolver fails these specific hunks (the log change is what makes that investigable later); any change to PR-mode landing; any product-repo change (pull-only topology).

> *This was generated by AI during triage.* **Ruled by agent under ADR 0174 — veto anytime.** **Category:** enhancement. **State:** `ready-for-session` (not `ready-for-agent`). ## Ruling This is landing-architecture work in the push-mode land seam. Two things keep it out of the swarm-worker lane: 1. **It may edit a protected path.** The issue leaves open *where* the pre-close rebase lives — "the worker prompt, `close-report.sh`, or a harness step between the two." The worker-prompt option is `prompts/prompt.md`, a prompt skeleton (live text for every future worker), which a swarm worker must never touch (per `docs/agents/triage-labels.md`, the `ready-for-session` role). Deciding *where* it lives is itself part of the work, and one of the three candidates is a protected path — so the decision belongs to an interactive session. 2. **It must be planned together with held #361.** The issue states it overlaps [#361](https://git.matou.nz/Matou/dev-factory/issues/361) ("close a ticket only after the host has verified its work is on `main`") and that "they touch the same landing files, so they should be planned together." #361 is currently `no-triage` + `priority` — held for an interactive session, invisible to the swarm queue. A swarm worker claiming #383 in isolation (`list-ready-tasks.sh` reads only `ready-for-agent`) cannot honor "plan together" with a held ticket, and would risk landing a landing-architecture change the #361 session then has to work around. An interactive session can hold both in head and sequence them. Neither crosses the `ready-for-human` bar (no Ben's-hands, no Ben's-eyes, no one-way door): the whole change is revertible landing code provable by offline tests. So it is a session ticket, not a human ticket. ### Why this is a two-way door It is a **label change** — fully revertible. If you want a swarm worker to take it instead, relabel `ready-for-agent`. The underlying work is ordinary landing-lib / close-report code behind the `landing_mode_for` / `landing_*` seam, reverted by a later commit. ### What proves it The existing offline landing seam — `tests/landing-lib-test.sh` (shimmed `git`/`claude`/`curl`, no network) — plus the five offline checks the issue already lists. No live door is needed to prove any leg of this. --- ## Session brief **Category:** enhancement **Summary:** In `LANDING=push`, rebase the worker branch on live `origin/main` and re-run the test seam **before** the close report, so reviewed work is not thrown away by a one-hunk conflict at the host's post-close push. **Current behavior (verified in code):** - The worker runs its close report against the base it started from. The host's post-run reconcile (`landing-lib.sh`, the `git push origin HEAD:main` → `fetch` → `git rebase origin/main` ladder) is the *first* place `main`'s movement is seen. A clean rebase pushes; a **conflict** routes through `landing_resolve_classified` → `landing_land_resolved_conflict`, which parks the resolved commits on a `sandcastle/rescue-*` branch as a PR and **reopens** the ticket — the whole ticket is then rebuilt from nothing. On `Matou/policy-generators`, 2026-11-20, three reviewed tickets were discarded this way, each for a single one-hunk conflict (signature `e9d7ba086503`). - The rebase resolver's log is `rm -f`'d on **every** classified path (`resolved` / `refused` / `unusable` / failed), so a resolver that ran-but-could-not-finish leaves no record of why. (Confirmed: four `rm -f "$log"` sites in `landing-lib.sh`'s reconcile.) **Desired behavior:** 1. In push mode, before the close report, fetch `origin/main` and rebase the worker branch on it. 2. Clean rebase → re-run the repo's test seam on the rebased tree; the close report's evidence comes from that run. 3. Conflict → the worker resolves it as part of the task (the whole task still in its head, ticket still open), re-runs the seam, and the independent reviewer reviews the rebased diff. 4. The host's existing push-time rebase stays as the last line, for the short window between close and push — it should now almost never conflict. 5. **Fail-safe:** a rebase step that cannot run (usage/turn limit reached, fetch failed) **closes nothing** — ticket left open with a clear note. 6. PR mode (`landing_mode_for` ≠ push) is unchanged. **Severable sub-task — keep the resolver's log (small, can land on its own):** on a **failed/unresolved** host-side resolve, write the resolver log into the run's evidence directory instead of deleting it (reuse the evidence seam, cf. `evidence-lib.sh`). The `resolved`-path deletion may stay. This has no overlap with #361 and no protected-path exposure — if the session wants, file it as its own `ready-for-agent` ticket so a worker can land it while the main rebase design is still being planned. **Design decisions for the session (do not pre-commit):** - Where the pre-close rebase lives: worker prompt skeleton (protected — session-only) vs `close-report.sh`/`close-report-lib.sh` vs a new harness step. Prefer the lowest-blast-radius home that keeps the fail-safe guarantees; justify if the prompt skeleton is chosen (it re-renders into every consumer). - Sequencing with #361 (they share the land seam). - The seam-window trade-off: a long seam re-widens the race; it shrinks but never reaches zero. **Acceptance criteria (all offline, extend `tests/landing-lib-test.sh`):** - Push mode: a worker branch behind `origin/main` is rebased before the close report, and the report's seam evidence is from the rebased tree. - A conflicting rebase does **not** close the ticket; the worker is given the conflict to resolve. - A rebase step that cannot run (limit reached / fetch failed) leaves the ticket open with a note and closes nothing. - A failed host-side resolve leaves its log in the run's evidence directory. - PR mode behaves exactly as before. - Every lib change ships its test update in the same commit; the full offline suite stays green. **Out of scope:** diagnosing *why* the resolver fails these specific hunks (the log change is what makes that investigable later); any change to PR-mode landing; any product-repo change (pull-only topology).

Agent session — #383 Part B landed; Part A routed ready-for-human

Ruled by agent under ADR 0174 — veto anytime.

Part B — "keep the resolver's log" — LANDED on main

The push-time rebase-conflict resolver's log was rm -f'd on every arm of landing_push_main_with_rescue's conflict switch, including the failed arm (claude RAN but could not finish the merge) — the one case whose log carries the diagnosis. That is exactly why the three policy-generators strands (runs 809 / 872 / 977, same e9d7ba086503 signature) could not be read.

What landed (landing-lib.sh): a new landing_keep_resolve_log moves the log into the run evidence dir (LANDING_RESOLVE_LOG_DIR, default ${TMPDIR:-/tmp}) and echoes the kept path (best-effort — an unwritable dir falls back to the still-present original, so the log is never lost). The failed arm now keeps the log and names it in a :mag: park notice; the resolved/refused/unusable arms still remove theirs (self-explaining).

  • Commit: 251850b on main.
  • Proof: tests/landing-lib-test.sh (+5, red-before-green): a failed resolve keeps a landing-resolve-* log carrying the resolver's output, the park alarm names where, and the rescue park is unchanged; a refused (usage-limit) resolve keeps no log. 199 checks green; docs-budget-test green; full offline suite green.
  • Owed: re-vendor (GOTCHAS 4) — reaches the .sandcastle/ self-copy and consumers only at the next FACTORY_REF bump.
  • Covers the ticket's Check 4 ("a failed resolve at the host's push-time rebase leaves its log in the run's evidence"). Journal: docs/journal/2026-11-20-383.md.

Why human — Part A (the main change) needs a design ruling, planned with #361

Part A — the worker rebases its branch on live origin/main and re-runs the seam before its close report, resolving any conflict in-session — is not a two-way door at the altitude this ticket sets it, so I am stopping that part (ADR 0174 rule 2) rather than landing it unattended in push mode:

  1. It reverses the landed #193/#217 decision, fleet-wide. #193 deliberately moved push-mode landing off the sandbox: the worker pushes only its per-run branch and the HOST owns the rebase. Part A puts a rebase back in the worker. The reversal is encoded not just in prose but in a dedicated guard test, worker-conflict-retest-prompt-test.sh, which currently asserts "the worker does NOT rebase main in the sandbox". Reversing it rewrites policy_landing_guidance — the {{LANDING_RULES}} skeleton rendered into every push consumer — plus that test plus the rendered-prompt fixtures. Push mode means it reaches main (and, at the next pin bump, every consumer) with no human review in between.
  2. It is entangled with close-report's envelope-SHA gate. A rebase rewrites the commit SHAs the close-report envelope claims; gate 1 checks those SHAs against the pushed worker branch. So the worker must re-push (force) its own branch and re-report post-rebase SHAs — the mechanism has to be designed across the prompt and close-report.sh, not dropped into one.
  3. The filer explicitly says to plan it with the HELD #361. "They touch the same landing files, so they should be planned together." #361 is on hold; landing Part A against that hold is the call I should not make alone. The filer also left the placement ("worker prompt vs close-report.sh vs a harness step") an open design question.

Human residue: rule on Part A's placement and whether to reverse #193 now, together with #361 — then it can be built (TDD against the ticket's Checks 1/2/3/5). Part B above is done and independent of that ruling.

Relabelling ready-for-session → ready-for-human.

## Agent session — #383 Part B landed; Part A routed `ready-for-human` Ruled by agent under ADR 0174 — veto anytime. ### Part B — "keep the resolver's log" — LANDED on `main` The push-time rebase-conflict resolver's log was `rm -f`'d on **every** arm of `landing_push_main_with_rescue`'s conflict switch, including the `failed` arm (claude RAN but could not finish the merge) — the one case whose log carries the diagnosis. That is exactly why the three `policy-generators` strands (runs 809 / 872 / 977, same `e9d7ba086503` signature) could not be read. **What landed** (`landing-lib.sh`): a new `landing_keep_resolve_log` moves the log into the run evidence dir (`LANDING_RESOLVE_LOG_DIR`, default `${TMPDIR:-/tmp}`) and echoes the kept path (best-effort — an unwritable dir falls back to the still-present original, so the log is never lost). The `failed` arm now keeps the log and names it in a `:mag:` park notice; the `resolved`/`refused`/`unusable` arms still remove theirs (self-explaining). - **Commit:** `251850b` on `main`. - **Proof:** `tests/landing-lib-test.sh` (+5, red-before-green): a `failed` resolve keeps a `landing-resolve-*` log carrying the resolver's output, the park alarm names where, and the rescue park is unchanged; a `refused` (usage-limit) resolve keeps no log. 199 checks green; `docs-budget-test` green; full offline suite green. - **Owed:** re-vendor (GOTCHAS 4) — reaches the `.sandcastle/` self-copy and consumers only at the next `FACTORY_REF` bump. - Covers the ticket's **Check 4** ("a failed resolve at the host's push-time rebase leaves its log in the run's evidence"). Journal: `docs/journal/2026-11-20-383.md`. ### Why human — Part A (the main change) needs a design ruling, planned with #361 Part A — *the worker rebases its branch on live `origin/main` and re-runs the seam **before** its close report, resolving any conflict in-session* — is **not a two-way door** at the altitude this ticket sets it, so I am stopping that part (ADR 0174 rule 2) rather than landing it unattended in push mode: 1. **It reverses the landed #193/#217 decision, fleet-wide.** #193 deliberately moved push-mode landing *off* the sandbox: the worker pushes only its per-run branch and the **HOST** owns the rebase. Part A puts a rebase back in the worker. The reversal is encoded not just in prose but in a dedicated guard test, `worker-conflict-retest-prompt-test.sh`, which currently asserts *"the worker does NOT rebase `main` in the sandbox"*. Reversing it rewrites `policy_landing_guidance` — the `{{LANDING_RULES}}` skeleton **rendered into every push consumer** — plus that test plus the rendered-prompt fixtures. Push mode means it reaches `main` (and, at the next pin bump, every consumer) with no human review in between. 2. **It is entangled with close-report's envelope-SHA gate.** A rebase rewrites the commit SHAs the close-report envelope claims; gate 1 checks those SHAs against the pushed worker branch. So the worker must re-push (force) its own branch and re-report post-rebase SHAs — the mechanism has to be designed across the prompt *and* `close-report.sh`, not dropped into one. 3. **The filer explicitly says to plan it with the HELD #361.** "They touch the same landing files, so they should be planned together." #361 is on hold; landing Part A against that hold is the call I should not make alone. The filer also left the placement ("worker prompt vs `close-report.sh` vs a harness step") an open design question. **Human residue:** rule on Part A's placement and whether to reverse #193 now, together with #361 — then it can be built (TDD against the ticket's Checks 1/2/3/5). Part B above is done and independent of that ruling. Relabelling `ready-for-session` → `ready-for-human`.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/dev-factory#383
No description provided.