session-runner: a stale dedicated checkout never refreshes its own entrypoint when every queued ticket is skipped (hosts ran the pre-#302 runner for a week) #319

Closed
opened 2026-10-30 17:20:51 +00:00 by ben · 3 comments
Owner

Symptom

The Floor's Queue showed 14 ready-for-session tickets (matou-app ×6, coa ×7, pregnancy-navigator ×1) for days while every session-runner tick on matou-workstation logged, per ticket:

session-runner: #371 lands by PR (landing-pr label or pr-default repo) — skipped for an interactive session to open the PR by hand (#165, not an attempt)

That is the pre-#302 rule. #302 (f41fd76, 2026-10-22) lets the session work a pr-mode ticket and open the PR itself, and it is inside the 2cf3a38 pin matou-app and pregnancy-navigator adopted on 2026-10-25. The hosts kept running the old script.

Cause

The host crontab runs the runner from its own dedicated checkout:

7-59/10 * * * * … /home/dev/session-runner/matou-app/.sandcastle/session-runner.sh

but session-runner.sh only refreshes that checkout (git fetch + reset --hard origin/main + clean -fd, lines ~544–546) after a ticket is picked. A script version that skips every ticket in the queue never picks, never resets, and therefore never replaces itself. The checkout stays frozen on whatever the last session left (matou-app: agent/issue-761 @ a2dc353 since 2026-10-21; coa: agent/issue-135 @ 87e1b55 since 2026-09-25; pregnancy-navigator: main @ 87e1b55 since 2026-10-08). A behaviour change to the runner's pick/skip rules can never reach a host whose queue consists only of tickets the old rule skips — exactly the case #302 was built for.

idss and dev-factory checkouts stayed current only because they kept picking push-mode tickets.

Fix wanted

Refresh the entrypoint before the pick loop, not after. Options, in order of preference:

  1. The generated crontab line (onboarding/host-state-lib.sh) invokes the swarm workdir's vendored copy (<swarm-checkout>/.sandcastle/session-runner.sh, which the swarm legs keep at origin/main) and passes the dedicated session checkout as SESSION_RUNNER_CHECKOUT — the runner script is then never read from a checkout it only resets after picking.
  2. Or: session-runner.sh does git fetch origin && git reset --hard origin/main on its own checkout at the top (under the existing per-checkout lock, before the queue read) and re-execs itself if .sandcastle/session-runner.sh changed.

Either way: a test in tests/ (or onboarding/tests/) proving a stale checkout whose script skips everything still converges on origin/main within one tick, a GOTCHAS body + index row keyed by this ticket, and a journal entry.

Hand work already done (2026-10-30)

Reset ~/session-runner/{matou-app,coa,pregnancy-navigator} on matou-workstation to origin/main by hand (no live session, nothing unpushed). matou-app and pregnancy-navigator now run the #302 runner. coa's own main still pins a2dc353 (pre-#302), so its 7 session tickets stay skipped until coa bumps FACTORY_REF — a pull-only human step, not this ticket. bens-mac-04 was unreachable (no route to host) and its session checkouts were not inspected.

#165 (the skip this replaced), #302 (the behaviour that never arrived), #289 / GOTCHAS 78 (another silent-host hazard). The Floor shows these tickets as waiting-tick, which hides the runner's skip reason — a separate, smaller Floor follow-up.

## Symptom The Floor's Queue showed 14 `ready-for-session` tickets (matou-app ×6, coa ×7, pregnancy-navigator ×1) for days while every session-runner tick on matou-workstation logged, per ticket: ``` session-runner: #371 lands by PR (landing-pr label or pr-default repo) — skipped for an interactive session to open the PR by hand (#165, not an attempt) ``` That is the pre-#302 rule. #302 (f41fd76, 2026-10-22) lets the session work a pr-mode ticket and open the PR itself, and it is inside the `2cf3a38` pin matou-app and pregnancy-navigator adopted on 2026-10-25. The hosts kept running the old script. ## Cause The host crontab runs the runner from its own dedicated checkout: ``` 7-59/10 * * * * … /home/dev/session-runner/matou-app/.sandcastle/session-runner.sh ``` but `session-runner.sh` only refreshes that checkout (`git fetch` + `reset --hard origin/main` + `clean -fd`, lines ~544–546) **after** a ticket is picked. A script version that skips every ticket in the queue never picks, never resets, and therefore never replaces itself. The checkout stays frozen on whatever the last session left (matou-app: `agent/issue-761` @ a2dc353 since 2026-10-21; coa: `agent/issue-135` @ 87e1b55 since 2026-09-25; pregnancy-navigator: `main` @ 87e1b55 since 2026-10-08). A behaviour change to the runner's pick/skip rules can never reach a host whose queue consists only of tickets the old rule skips — exactly the case #302 was built for. idss and dev-factory checkouts stayed current only because they kept picking push-mode tickets. ## Fix wanted Refresh the entrypoint before the pick loop, not after. Options, in order of preference: 1. The generated crontab line (onboarding/host-state-lib.sh) invokes the **swarm workdir's** vendored copy (`<swarm-checkout>/.sandcastle/session-runner.sh`, which the swarm legs keep at `origin/main`) and passes the dedicated session checkout as `SESSION_RUNNER_CHECKOUT` — the runner script is then never read from a checkout it only resets after picking. 2. Or: `session-runner.sh` does `git fetch origin && git reset --hard origin/main` on its own checkout at the top (under the existing per-checkout lock, before the queue read) and re-execs itself if `.sandcastle/session-runner.sh` changed. Either way: a test in `tests/` (or `onboarding/tests/`) proving a stale checkout whose script skips everything still converges on `origin/main` within one tick, a GOTCHAS body + index row keyed by this ticket, and a journal entry. ## Hand work already done (2026-10-30) Reset `~/session-runner/{matou-app,coa,pregnancy-navigator}` on matou-workstation to `origin/main` by hand (no live session, nothing unpushed). matou-app and pregnancy-navigator now run the #302 runner. **coa's own `main` still pins `a2dc353` (pre-#302)**, so its 7 session tickets stay skipped until coa bumps `FACTORY_REF` — a pull-only human step, not this ticket. bens-mac-04 was unreachable (no route to host) and its session checkouts were not inspected. ## Related #165 (the skip this replaced), #302 (the behaviour that never arrived), #289 / GOTCHAS 78 (another silent-host hazard). The Floor shows these tickets as `waiting-tick`, which hides the runner's skip reason — a separate, smaller Floor follow-up.

swarm-claim host=matou-dev-server-01 run=25420
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=matou-dev-server-01 run=25420 (automated multi-host claim — lowest live claim id works this ticket)

⏩ independent reviewer for #319 — verdict unauthenticated

review JSON
{
  "verdict": "unauthenticated",
  "findings": []
}
:fast_forward: **independent reviewer** for #319 — verdict `unauthenticated` <details><summary>review JSON</summary> ```json { "verdict": "unauthenticated", "findings": [] } ``` </details>

close-report for #319 — status success

✅ close-report gates passed — every claim verified against the pushed worker branch sandcastle/worker/20261030-172321-20db0e (pre-land — the host promotes it to main only after its post-run verify, #193/#283); issue closed.

envelope
{
  "issue": 319,
  "status": "success",
  "commits": [
    "a2f2379d9aea3ed22e7b7722fd39347c60f9e5ef"
  ],
  "changed_files": [
    "session-runner.sh",
    "tests/session-runner-test.sh",
    "docs/GOTCHAS.md",
    "docs/gotchas/319-session-runner-stale-checkout-never-refreshes-on-skip-everything.md",
    "docs/journal/2026-10-30-319-session-runner-self-refresh.md"
  ],
  "tests": [
    {
      "command": "bash tests/session-runner-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash tests/docs-budget-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash onboarding/tests/vendor-manifest-coverage-test.sh",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Refresh the entrypoint before the pick loop, not after": "session-runner.sh: new sr_self_refresh runs clone+fetch+reset --hard origin/main+clean+core.hooksPath at the top of the tick (right after the per-checkout owner lock, before the queue read); the old post-pick checkout block is removed.",
    "Implemented via option 2 (session-runner.sh refreshes its own checkout at the top under the per-checkout lock and re-execs if the entrypoint changed)": "session-runner.sh sr_self_refresh does fetch + reset --hard origin/main under the owner lock; it is a function (parsed into memory before git reset rewrites the running file), and re-execs the fresh checkout copy when its sha1 differs from the running entrypoint, dropping the outer/owner lock fds first.",
    "A test proving a stale checkout whose script skips everything still converges on origin/main within one tick": "tests/session-runner-test.sh group 26: a nothing-workable (deferred + dep-blocked) queue still logs 'fetch -q origin' and 'reset -q --hard origin/main' in GIT_LOG; group 27 proves the changed-entrypoint re-exec; group 18a still proves an owned checkout runs NO git.",
    "A GOTCHAS body + index row keyed by this ticket": "docs/gotchas/319-session-runner-stale-checkout-never-refreshes-on-skip-everything.md (body) + '#319' index row appended to docs/GOTCHAS.md (docs-budget-test green).",
    "A journal entry": "docs/journal/2026-10-30-319-session-runner-self-refresh.md (dated **Last updated lead, prior head 2026-10-29-301-idss-pinned.md)."
  },
  "summary": "session-runner now refreshes its dedicated checkout to origin/main at the top of the tick (under the owner lock, before the pick) and re-execs the fresh entrypoint if it changed, so a skip-everything queue no longer freezes the runner on a stale script.",
  "blockers": []
}
**close-report** for #319 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against the pushed worker branch `sandcastle/worker/20261030-172321-20db0e` (pre-land — the host promotes it to `main` only after its post-run verify, #193/#283); issue closed. <details><summary>envelope</summary> ```json { "issue": 319, "status": "success", "commits": [ "a2f2379d9aea3ed22e7b7722fd39347c60f9e5ef" ], "changed_files": [ "session-runner.sh", "tests/session-runner-test.sh", "docs/GOTCHAS.md", "docs/gotchas/319-session-runner-stale-checkout-never-refreshes-on-skip-everything.md", "docs/journal/2026-10-30-319-session-runner-self-refresh.md" ], "tests": [ { "command": "bash tests/session-runner-test.sh", "exit_code": 0 }, { "command": "bash tests/docs-budget-test.sh", "exit_code": 0 }, { "command": "bash onboarding/tests/vendor-manifest-coverage-test.sh", "exit_code": 0 } ], "criteria": { "Refresh the entrypoint before the pick loop, not after": "session-runner.sh: new sr_self_refresh runs clone+fetch+reset --hard origin/main+clean+core.hooksPath at the top of the tick (right after the per-checkout owner lock, before the queue read); the old post-pick checkout block is removed.", "Implemented via option 2 (session-runner.sh refreshes its own checkout at the top under the per-checkout lock and re-execs if the entrypoint changed)": "session-runner.sh sr_self_refresh does fetch + reset --hard origin/main under the owner lock; it is a function (parsed into memory before git reset rewrites the running file), and re-execs the fresh checkout copy when its sha1 differs from the running entrypoint, dropping the outer/owner lock fds first.", "A test proving a stale checkout whose script skips everything still converges on origin/main within one tick": "tests/session-runner-test.sh group 26: a nothing-workable (deferred + dep-blocked) queue still logs 'fetch -q origin' and 'reset -q --hard origin/main' in GIT_LOG; group 27 proves the changed-entrypoint re-exec; group 18a still proves an owned checkout runs NO git.", "A GOTCHAS body + index row keyed by this ticket": "docs/gotchas/319-session-runner-stale-checkout-never-refreshes-on-skip-everything.md (body) + '#319' index row appended to docs/GOTCHAS.md (docs-budget-test green).", "A journal entry": "docs/journal/2026-10-30-319-session-runner-self-refresh.md (dated **Last updated lead, prior head 2026-10-29-301-idss-pinned.md)." }, "summary": "session-runner now refreshes its dedicated checkout to origin/main at the top of the tick (under the owner lock, before the pick) and re-execs the fresh entrypoint if it changed, so a skip-everything queue no longer freezes the runner on a stale script.", "blockers": [] } ``` </details>
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#319
No description provided.