Skip to content

fix(hosts): the handoff report can adopt an earlier live run and name its run_id (#1101) - #1105

Merged
Birfy merged 1 commit into
mainfrom
agent/1101-handoff-run-epoch
Nov 16, 2026
Merged

Birfy merged 1 commit into
mainfrom
agent/1101-handoff-run-epoch

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Fixes #1101

What changed

Before: a handoff into a reused store reported an earlier run that was still
going
. scripts/dsh-superagent-run.sh snapshotted each status.json by
mtime+size, and runstore rewrites a running run's file every round
(runstore.py:445-455), so the earlier file moved in the window exactly like
this launch's new one. The report then carried the earlier run_id, round and
run_dir, and the page's §6 read-back polled a run this handoff did not start.
Measured at base f5cc52ef: row B (old-run live, this launch writes
new-run at +1.2 s) → found=True run_id='old-run' round=3; row B with a child
that writes nothing → found=True run_id='old-run' where the page promises
found: false.

After: the snapshot carries the launch epoch (time.time() at snapshot time),
and the poll accepts a changed file only when its started is numeric and no
older than that epoch. A file absent from the snapshot still counts, so a fresh
run directory and a caller-owned run directory behave as before. At the tip the
same rows give: A new-run, B new-run, B-silent found=False, C new-run.

  • scripts/dsh-superagent-run.sh — one field in the snapshot JSON, one
    comparison (plus a four-line started_at reader) in the poll. No new flag, no
    extra wait: the poll still runs under the same WAIT deadline.
  • docs/dsh-super-agent.md:165-172 — the reused-store paragraph now says the
    wrapper reports a file that appears after the launch or changes with a
    started no older than it, and that a file whose started predates the launch
    is never reported.
  • tests/test_dsh_superagent_run.py — one gated row after the reused-store row:
    an earlier live run rewriting its status.json every 200 ms, a child that
    writes nothing (report found: false) and a child that writes new-run at
    +1.2 s (report names new-run, and the read-back follows it).
  • changelog.d/1101-handoff-run-epoch.md — one Fixed fragment.

Non-goals, per the issue: the two-wrapper waiting.json handshake, #1096's exit
code and waiting state, the session-name scheme, and a --run-id flag.

Verification at the tip

Tip SHA: 021d2e0

Branch agent/1101-handoff-run-epoch carries one commit on base
f5cc52efe41750633ac37876fc2d2894a8a6f9f3, rebased from the earlier
09492927 base; the patch is byte-identical to the pre-rebase one
(git diff 09492927 989b3e76 | sha256sum = git diff f5cc52ef 021d2e09 | sha256sum = 21867cea…), and no file this PR touches moved on main.

Red at base f5cc52ef (clean tree, only the new test row added):
AGENTDESCENT_LONG_RUN_SMOKE=1 pytest -q tests/test_dsh_superagent_run.py -k live_earlier → 1 failed, 5 deselected, assert report["found"] is False with
AssertionError: {'command': 'sleep 1', 'driver': 'tmux', 'found': True, …} /
assert True is False. The same shape's report at that base names
run_id='old-run' round=3 run_dir='old-run', for both the ticking earlier run
and the silent-child row.

Ran, at this tip:

  • pytest -q tests/test_dsh_superagent_run.py with
    AGENTDESCENT_LONG_RUN_SMOKE=1 → 6 passed
  • pytest -q tests/test_dsh_superagent_run.py without the flag → 2 passed,
    4 skipped
    (the gated group, as CI runs it)
  • four-row probe at the tip and at base → A/C new-run both, B new-run at
    the tip and old-run round=3 at base, B-silent found=False at the tip and
    old-run round=3 at base
  • pytest -q -n 8 (full offline suite) → 7492 passed, 59 skipped, 20
    failed
    in 616.88s; the 20 are the host-only legs this box cannot run (no
    Docker daemon: 12 test_sandbox_container; host toolchains: 6
    test_era_srbench, 2 test_genesis_example), the same three modules that
    are red here on main, and none in a file this PR touches
  • pytest -q tests/test_docs_links.py tests/test_site_navigation.py tests/test_repo_hygiene.py → 26 passed
  • python -m tools.gen_api_docs --check → docs/api.md is up to date
  • python -m tools.changelog_fragments check → 47 changelog fragment(s) OK
  • bash -n scripts/dsh-superagent-run.sh → clean; the only remaining sleep in
    the wrapper is the existing time.sleep(0.2) poll tick, under the same
    WAIT deadline

Not run:

  • mkdocs build --strict — mkdocs is not installed in this clone's venv;
    CI's build job is the line

Size: 4 files, +122/−6 against base f5cc52ef. T2 by
.github/agent/risk-rules.json (scripts/** is a T2 path).

Claim-Id: #1101

@HugoXK

HugoXK commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

Label state declaration (Lead), before the write: agent-pr, bug, area:cli.

  • bug and area:cli mirror the issue's own labels — this is a behaviour fix in the hosts wrapper, nothing user-facing is added.
  • agent-pr is required of our PRs by AGENTS.md:101-102.
  • risk:T* is not ours: the controller sets the tier from .github/risk/rules.json (scripts/** = T2) and the declaration above does not touch it.
  • No assignee and no requested_reviewers: our PRs carry neither, review is Birfy's sweep.

@HugoXK HugoXK added agent-pr Pull request opened by an agent area:cli The agentdescent command line (cli.py, doctor, plan/evolve/status/apply) bug Something isn't working labels Nov 16, 2026
@github-actions github-actions Bot added the risk:T2 Risk tier T2 (package code or an unnamed path), set by the controller from the diff label Nov 16, 2026
The mtime/size snapshot cannot tell a live earlier run apart from this
launch's new one: runstore rewrites a running run's status.json every round, so
a reused store's older run looked fresh and the report carried its run_id. Take
the launch epoch with the snapshot and accept a changed file only when its
started is numeric and no older than that epoch; a file absent from the
snapshot still counts, so a fresh or caller-owned run dir is unchanged.
@HugoXK

HugoXK commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

Review request — one ask, at 021d2e091068ef20cfd707c3a7dfc27c77f22f2e.

Head equals the sha above; base f5cc52ef; 4 files +122/−6; Fixes #1101. The base red and the tip probe rows are in the body under "Verification at the tip" — the wrapper now snapshots a launch epoch and only accepts a changed status.json whose started is no older than it, so a handoff into a reused store no longer names an earlier live run.

Checks at this tip: build, test (3.9), (3.10), (3.11), (3.12), (3.13), risk tier — success. reviewed tip reads cancelled: that is this workflow's own concurrency: cancel-in-progress closing the run from the pre-rebase tip, not a failing leg, and there is no stale run whose output is being read here. mergeable_state is unstable because of that same cancelled non-blocking check; the git report at this sha is clean.

Tier: risk:T2 from the controller — scripts/** is T2 and no T3 path or T3 diff pattern matches the diff. T2 policy is a PASS at this tip plus Danyang's merge click.

Out of scope for this PR, so a round need not be spent on them: the two-wrapper waiting.json handshake, #1096's exit code and waiting state, the session-name scheme, and a --run-id flag.

@Birfy Birfy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review (Birfy)

Tip SHA: 021d2e0
Ran:

  • AGENTDESCENT_LONG_RUN_SMOKE=1 pytest -q tests/test_dsh_superagent_run.py at this tip → 6 passed
  • The new live_earlier test copied onto unmodified main f5cc52e (wrapper unchanged) → 1 failed, found: True for the ticking earlier run where the page promises found: false, matching the claimed red
  • After #1110 landed on main (3a526ae), this patch still applies cleanly; the combined wrapper (argv handoff + launch-epoch filter) has 8 passed under the same flag
  • bash -n scripts/dsh-superagent-run.sh → clean
  • python -m tools.changelog_fragments check → pass
  • .github/scripts/risk_gate.py --pr 1105 → T2
  • CI at this tip → required checks green (build, test 3.9–3.13); deploy skipped; risk tier report-only SUCCESS; reviewed tip (report only) cancelled, not a required check
    Not run:
  • mkdocs build --strict — docs/dsh-super-agent.md changed; the CI build job is green at this tip
  • Full offline suite locally — the CI test matrix is the line
  • Ark real-model run — no model path changed
    Findings:
  • none
    Verdict: PASS

@Birfy

Birfy commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Review (Birfy)

Tip SHA: 021d2e0
Ran:

  • AGENTDESCENT_LONG_RUN_SMOKE=1 pytest -q tests/test_dsh_superagent_run.py at this tip → 6 passed
  • The new live_earlier test copied onto unmodified main f5cc52e (wrapper unchanged) → 1 failed, found: True for the ticking earlier run where the page promises found: false, matching the claimed red
  • After fix(hosts): hand the log path to the driver as an argument, not shell syntax (#1109) #1110 landed on main (3a526ae), this patch still applies cleanly; the combined wrapper (argv handoff + launch-epoch filter) has 8 passed under the same flag
  • bash -n scripts/dsh-superagent-run.sh → clean
  • python -m tools.changelog_fragments check → pass
  • .github/scripts/risk_gate.py --pr 1105 → T2
  • CI at this tip → required checks green (build, test 3.9–3.13); deploy skipped; risk tier report-only SUCCESS; reviewed tip (report only) cancelled, not a required check
    Not run:
  • mkdocs build --strict — docs/dsh-super-agent.md changed; the CI build job is green at this tip
  • Full offline suite locally — the CI test matrix is the line
  • Ark real-model run — no model path changed
    Findings:
  • none
    Verdict: PASS

@Birfy
Birfy merged commit 5048349 into main Nov 16, 2026
9 of 10 checks passed
@Birfy
Birfy deleted the agent/1101-handoff-run-epoch branch November 16, 2026 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-pr Pull request opened by an agent area:cli The agentdescent command line (cli.py, doctor, plan/evolve/status/apply) bug Something isn't working risk:T2 Risk tier T2 (package code or an unnamed path), set by the controller from the diff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(hosts): the handoff report can adopt an earlier live run and name its run_id

2 participants