Repository navigation
feat(session-flow): keep the away report current from the Stop hook - #17436
Conversation
During an absence the Stop hook now rewrites the report's refused-actions and external-actions blocks itself before it checks the report. Hooks run outside the Bash sandbox, so the session no longer has to run `away.py refresh` from a sandboxed command that cannot write the state. The watched-folder file scan stays with `end` and `refresh --files`, out of the Stop hook's 60 s timeout. The Stop note no longer asks for a refresh, and a hook error still leaves the stop silent. Refs: #17388 Co-authored-by: Claude Opus 5.5 <[email protected]>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7d90475c9b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…otcha The skill body stated that hooks run unsandboxed, an upstream behavior the skill-bodies rule says to leave to the pointer beside it. Keep only our decision that the Stop hook keeps the report current. Refs: #17388 Co-authored-by: Claude Opus 5.5 <[email protected]>
|
claude-security-review reviewed Security review: PR #17436, incremental
|
|
claude-review reviewed Code review: Stop hook keeps the away report current (#17436), incremental, blocking onlyThis lane has already reviewed earlier heads of this PR, so this pass reports blocking findings only. It covers the change from No blocking findings. What changed:
The owner's reply on the
Closing issue: the PR says Loosened checks: Verification: I ran nothing. The suite count of 549 passed is the author's claim and I have not checked it. Verifier dropped 0 of 0 candidates. |
Review fixes for the Stop hook's report rewrite: - Refuse to rewrite the report when its folder resolves elsewhere than the one recorded at start, or the report is not a regular file, so a link a sandboxed command plants cannot redirect the unsandboxed hook's write or copy a linked file into the report. - A failed rewrite is logged and the Stop hook still runs its report check, so open task items keep holding the run. - Drop the due-time file scan, which nothing triggers now that the session runs no refresh during an absence; the scan stays with end and refresh --files. - go-with-recommendations no longer runs refresh during an absence. Refs: #17388 Co-authored-by: Claude Opus 5.5 <[email protected]>
|
Review round 1 on 7d90475, fixed in fb42d7d and 1bd807a:
session-flow scripts suite: 548 passed. ruff clean. |
An absence started before report_dir existed compared the report folder's realpath with its abspath, which differ on any symlinked path, so every rewrite was refused and end died with a traceback after moving the state to ended. With no recorded folder the check now falls back to the folder's realpath, keeping the regular-file check. An OSError from a command now prints as an error and exits 1. Refs: #17388 Co-authored-by: Claude Opus 5.5 <[email protected]>
Post-merge mutation testingKilled 6, survived 1, timeout 0, no coverage 0, invalid 0, not run 0.
Surviving mutants
The run's summary has the full report. |
Refs: #17388
Summary
With the Bash sandbox on, a sandboxed
away.py refreshcannot write the away state under the plugin data directory, so during an absence the report's refused-actions and external-actions blocks went stale with no error. Hooks run outside the sandbox (sandboxing, Filesystem isolation), so the Stop hook now writes those blocks itself. This is option A of the approach comment on #17388, which the owner chose. The state location, the hooks' read path and the trust boundary are unchanged.Fix
on_stop(active absence) records the transcript path, then rewrites the refused and external-action blocks (refresh(..., files=False)) before it checks the report. It hashes the report after that rewrite, so the existing "no progress since the last block, let it stop" check still ends a loop.SCAN_BUDGET_SECONDS, 60 s, equal to the Stop hook's 60 s timeout) runs only atendand onrefresh --files. The old due-time scan on the firstrefreshafter report-by is removed, since nothing triggers it now.startrecordsreport_dir, the realpath of the report's folder.write_blocksrefuses a report whose folder now resolves elsewhere or that is not a regular file, so a link planted by a sandboxed command cannot redirect the hook's write. A state from before this change has noreport_dir, so it gets only the regular-file check. A command that hits the refusal prints it and exits 1.blockor nothing;grep -c '"allow"' plugins/session-flow/scripts/away.pyprints 0.refresh. Whenblocks_freshfails, it says to keep each away marker once.SKILL.mdandreference/rules.md, plus go-with-recommendations: norefreshwhile the person is away.start,endanddeliverrun outside the sandbox while the person is present. Re-read the report before editing it.Verification
uvx --with pytest pytest plugins/session-flow/scripts/tests -q: 549 passed. New tests cover six things. The Stop hook lists a new refusal itself, with no refresh. It lists transcript external actions and auto mode denials and leaves the agent's sections untouched. It runs no file scan, whichendstill runs. A report it cannot write still blocks on open items. A link planted at the report or its folder is never written through, andendreports it with exit 1. An absence recorded beforereport_direxisted, through a symlinked folder, still ends. Each of these tests except the file-scan one failed before its fix; the file-scan test guards behaviour that already held.Cost per Stop, against the 60 s Stop hook timeout. The test was 7 timed runs of the whole
away.py hook Stopprocess, on one WSL2 Linux host. Input was a real 21 MB session transcript plus 31 MB of subagent transcripts (657 tool uses), read in place, never copied or committed. The absence start was backdated so every record counts. That is the worst case: the whole session falls inside the absence.main(no rewrite)The change adds about 224 ms per Stop at the median. The run listed 36 external actions, which shows the full scan ran.
scripts/run-ruff.sh checkclean;check-skill.shon session-flow skills passes, 0 errors;validate-cases.pyon session-flow evals: no FAIL; the pre-pushcheck-affectedpassed.Remaining
These done-when items of #17388 are not covered here. The owner's choice of option A leaves them as written:
away.pykeeps its state in a location writable inside the Bash sandbox (or has a documented fallback)": the state stays under the plugin data directory.startandrefreshrun without leaving the sandbox, shown by a live run":start,endanddeliverstill run outside the sandbox while the person is present.refreshis no longer needed during an absence. No live sandboxed run was made.Related
SKILL.mdstep 6. With its option A,startis always attended.🤖 Generated with Claude Code