Skip to content

session-flow: keep away.py state in a location the Bash sandbox can write #17388

Closed

Description

@kyle-sexton

Problem

With the Bash sandbox on, the state directory away.py uses under the plugin data dir is read-only inside the sandbox, so every away.py write runs outside the sandbox. In a permission mode where that prompts, refresh during an absence is refused and the report goes stale. The hooks keep working, so the failure is quiet.

A state location the sandbox can write would remove this.

This is design-bearing: it changes where the hooks read their state.

Done looks like

  • away.py keeps its state in a location writable inside the Bash sandbox (or has a documented fallback), chosen with the hooks' read path in mind.
  • The hooks read state from the same location.
  • With the sandbox on, start and refresh run without leaving the sandbox, shown by a live run.
  • Existing tests pass; the state location is covered by a test.

Refs: #17337

Activity

  1. added
    needs-triage
    on Nov 19, 2026
  2. github-actions commented on Nov 19, 2026

    @github-actions
    Contributor

    Size: Medium
    Complexity: Medium
    Uncertainty: Knowable
    Flags: none
    Blocked by: none
    Blast radius: plugins/session-flow (away.py, the Stop hook, the refresh prompt and rules.md) and anyone who runs the step-away flow with the Bash sandbox on.
    Reversible: yes; revert the change. State location and read path stay as they are.
    Open questions: none

    The decision below settles the open questions. It picks option (a): the hooks do the writes during the absence, the refresh prompt is dropped, and the watched-folder scan moves to end. The state location is unchanged. It also accepts that start, end and deliver still run outside the sandbox, but only while the person is present. The earlier refinement questions about a .work/away location and a hooks fallback no longer apply. The per-Stop transcript scan cost is to be measured in the PR.

    Decision recorded.

    Question (Q229, hub morning report 2026-11-19): where should away.py state live so it works with the Bash sandbox on? Options: (a) the hooks do the writes during the absence (Stop hook regenerates the refused and external-action blocks, the refresh prompt is dropped, the watched-folder scan moves to end), state location and security surface unchanged; (b) state under the git-ignored <launch checkout>/.work/away/<session>/ (trust-boundary change); (c) a documented sandbox.filesystem.allowWrite entry for the data directory (loosens a sandbox control). Recommendation: (a).

    Owner answer (2026-11-19, 9:5x AM EST, in the hub session): "go w/ recomendations"

    Decision: (a). The owner accepts the changed criterion: start, end and deliver still run outside the sandbox, but only while the person is present (under Q228 (a), start is always attended). The per-Stop transcript scan cost is to be measured in the PR.

    Decision comment: #17388 (comment)

    Automated triage. A maintainer reviews it.

  3. removed
    needs-triage
    on Nov 19, 2026
  4. melodic-automation-lanes commented on Nov 19, 2026

    @melodic-automation-lanes
    Contributor

    Not admitted to the issue lane: no trusted-human acceptance criteria: a listed human must put the confirmed - [ ] criteria in the body or post them as their own comment, or, on an issue a listed human filed, intake's newest refinement comment must hold them unedited. Admission takes the issue once each of those is met, when intake triages it again (.github/actions/resolve-config/admission-rules.json).

  5. kyle-sexton commented on Nov 19, 2026

    @kyle-sexton
    MemberAuthor

    Recommended approach (draft for the owner's decision)

    Facts: a sandboxed command can write only to the working directory, the per-user temp directory and added directories, and hooks run outside the sandbox (sandboxing, Filesystem isolation). State lives in <plugin data>/away/<session>/ (away.py:225). refresh fails because it appends refused.jsonl and takes the lock there (away.py:862-869).

    A. Hooks do the writes during the absence (recommended). The Stop hook regenerates the refused and external-action blocks, and the prompt to run refresh is dropped (away.py:1086, rules.md:81).

    B. State under <launch checkout>/.work/away/<session>/ when ignored. This is the same rule choose_report_path uses (away.py:468-475). Hooks would locate it through CLAUDE_PROJECT_DIR, which is exported to hooks (plugins-reference), and fall back to the data directory.

    • It meets every criterion. But state.json becomes writable by any sandboxed command with no prompt, so a command could switch the refusals off.
    • It could also redirect report_path, which an unsandboxed end writes (away.py:946-948). Every path read from state must be confined.
    • Trust-boundary change: owner decides.

    C. Document a sandbox.filesystem.allowWrite entry for the data directory. No code changes. It loosens a sandbox control in user settings, with B's tamper exposure. Owner decides.

    Rejected: $TMPDIR. Sandboxed and unsandboxed commands resolve it to different directories (Temporary directories).

  6. melodic-automation-lanes commented on Nov 19, 2026

    @melodic-automation-lanes
    Contributor

    Refinement. A read-only run explored this repository, searched its issues and pull requests, and read the allowed docs to draft what follows. On an issue a listed human filed, it counts as the issue's spec once posted, while unedited; it is still model text, so check it.

    Intended outcome: away.py keeps its per-session state in a sandbox-writable location (most likely the project's .work/away), the hooks read it from there with the old plugin-data path as fallback, and a test covers the location.

    Related work

    Open questions

    1. Which sandbox-writable location should hold away state: the project working directory (e.g. .work/away/<session>, beside the report that choose_report_path already puts there) or a per-user TMPDIR path?
      RECOMMENDED: Project .work/away/<session>. The working directory is writable by default in the sandbox, while TMPDIR is per-user and may differ between a sandboxed command and a hook. Basis: https:/​/code.claude.com/docs/en/sandboxing; plugins/session-flow/scripts/away.py:468
    2. How should the hooks find state in the new location, and should the old plugin-data path stay as a read fallback?
      RECOMMENDED: Hooks look under the hook payload's cwd first, then fall back to the old data root in hook_state, so already-running absences stay readable. The old path is the documented fallback when the new one is not writable. Basis: plugins/session-flow/scripts/away.py:1127
    3. Should this wait for #​17383 (shared plugin_paths.py move), or land first with the new root helper added in plugin_paths.py?
      RECOMMENDED: Add the helper in plugin_paths.py and land independently, noting the overlap with #​17383 for merge order. Basis: judgment
    4. The done-when asks for a live sandboxed run of start and refresh. An unattended run cannot do that; should it be a person-run check, with the test covering the location?
      RECOMMENDED: Yes. Make the live run a manual check by a person, and have the automated criterion be a test that start and refresh write only under the chosen location. Basis: judgment

    Sources read

    • plugins/session-flow/scripts/away.py:4: state lives in <plugin data>/away/<session>/ as state.json, refused.jsonl and lock
    • plugins/session-flow/scripts/away.py:224: session_paths builds root/away/session
    • plugins/session-flow/scripts/away.py:1127: hook_state reads only from data_root, or every session-flow data dir when CLAUDE_PLUGIN_DATA is unset
    • plugins/session-flow/scripts/away.py:1205: main takes --data-root or data_root(os.environ, DEFAULT_PLUGIN_ROOT)
    • plugins/session-flow/scripts/plugin_paths.py:35: data_root resolves to <config>/plugins/data/<plugin@​marketplace>, under the protected config dir
    • plugins/session-flow/hooks/run-away-hook.sh:8: the hook exits early unless $CLAUDE_PLUGIN_DATA/away exists
    • plugins/session-flow/scripts/tests/test_away.py:298: existing data_root tests
    • https:/​/code.claude.com/docs/en/sandboxing: sandboxed Bash writes the working directory, added directories and TMPDIR; ~/.claude is not writable by default

    To answer, post a comment that starts with this line:

    **Decision recorded.** <answer>
    

    Automated refinement by the lanes App. Answer with a comment whose first line is **Decision recorded.**.

  7. kyle-sexton commented on Nov 19, 2026

    @kyle-sexton
    MemberAuthor

    Decision recorded.

    Question (Q229, hub morning report 2026-11-19): where should away.py state live so it works with the Bash sandbox on? Options: (a) the hooks do the writes during the absence (Stop hook regenerates the refused and external-action blocks, the refresh prompt is dropped, the watched-folder scan moves to end), state location and security surface unchanged; (b) state under the git-ignored <launch checkout>/.work/away/<session>/ (trust-boundary change); (c) a documented sandbox.filesystem.allowWrite entry for the data directory (loosens a sandbox control). Recommendation: (a).

    Owner answer (2026-11-19, 9:5x AM EST, in the hub session): "go w/ recomendations"

    Decision: (a). The owner accepts the changed criterion: start, end and deliver still run outside the sandbox, but only while the person is present (under Q228 (a), start is always attended). The per-Stop transcript scan cost is to be measured in the PR.

  8. kyle-sexton commented on Nov 19, 2026

    @kyle-sexton
    MemberAuthor

    Delivered by #17436 (merged as a54dfa1), option A, which the owner chose: the Stop hook writes the report's refused-actions and external-actions blocks itself, outside the sandbox, so no refresh runs during an absence.

    Remaining done-when items, settled by that choice rather than built:

    • State in a sandbox-writable location (or a documented fallback): the state stays under the plugin data directory; only hooks and attended commands (start, end, deliver) write it.
    • Hooks read state from the same location: unchanged, since the location did not move.
    • start and refresh run inside the sandbox, shown live: refresh is no longer needed while away; start, end and deliver run attended, outside the sandbox.
    • State location covered by a test: not applicable while the location is unchanged.

    Closing as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Work status

    confirmed

    Priority

    medium

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions