Skip to content

session-flow: remove a delivered absence's away state so idle hook cost returns to the cheap path #17389

Closed

Description

@kyle-sexton

Problem

session-flow's always-registered away hooks cost about 0.02 s per prompt and turn end when no away state exists (Python never starts). Once any away/ directory exists under the plugin data dir, the cost is about 0.09 s. A finished absence's state stays in place, so every later session pays the higher cost.

Done looks like

  • deliver (or end) removes a finished absence's state, or keeps it for a stated bounded retention.
  • After a delivered absence, no away/<session> directory remains (or only within the retention bound).
  • Measured idle hook cost in a session with no active absence is back to about 0.02 s, with the measurement recorded in the PR.
  • Tests cover the cleanup, and the report remains readable after delivery for as long as the retention says.

Refs: #17337

Activity

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

    @github-actions
    Contributor

    Size: Small
    Complexity: Low
    Uncertainty: Known
    Flags: none
    Blocked by: none
    Blast radius: session-flow's away deliver/end path and its tests; everyone running the plugin's away hooks.
    Reversible: yes; revert the cleanup change.
    Open questions: none
    Understood: after an absence is delivered, its away/<session> state should be removed (or kept only for a stated bounded retention) so idle hooks go back to the cheap no-Python path, with tests and a recorded measurement. Whether to delete immediately or keep a short retention is an implementation choice for the issue lane. Related, not duplicates: #17337 (referenced) and the open issue on where away.py state lives. No merged PR appears to fix this already. The measurement in the PR may need a person or host run.

    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; its title or stated work names a charge (retention), which needs an owner decision. Admission takes the issue once each of those is met, when intake triages it again (.github/actions/resolve-config/admission-rules.json).

    Reason: cost

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

    @melodic-automation-lanes
    Contributor

    The latest triage verdict holds nothing: admission moved the issue to needs-owner-decision; its comment says why.

  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: After deliver, session-flow removes the delivered absence's away/<session> state (and away/ once empty) so the idle hook takes the no-Python exit, while the report stays readable for a stated retention.

    Related work

    Open questions

    1. Should deliver delete the state at once, or keep it for a bounded retention? The issue allows either, and a retention needs a prune site.
      RECOMMENDED: Delete state.json, refused.jsonl and lock at deliver and keep only the report. The hook takes the cheap path only while away/ is absent, so a retention would keep the cost. Basis: plugins/session-flow/hooks/run-away-hook.sh:8
    2. Where should the report live after delivery? report_path can be inside the state dir (report.md beside state), which cleanup would delete, or in git-ignored .work/away, which it would not.
      RECOMMENDED: On deliver remove the state files but keep the report; when report_path is inside the state dir, move it to a stated retained location first, since the issue requires it to stay readable. Basis: plugins/session-flow/scripts/away.py:468
    3. Should deliver also rmdir away/ when empty, and should a failed cleanup fail deliver?
      RECOMMENDED: Yes, rmdir away/ when empty and ignore OSError if other sessions remain; a cleanup failure should be logged but not fail deliver. Basis: plugins/session-flow/scripts/away.py:953
    4. Should end also remove state? end leaves status ended, and the ended-to-delivered move is what the UserPromptSubmit hook uses to show the report once.
      RECOMMENDED: No: clean up only in deliver, since end must keep state for the show-once flow. Update MOVES so a later start after deliver still begins a fresh absence. Basis: plugins/session-flow/scripts/away.py:1106
    5. The idle cost measurement (0.02 s vs 0.09 s) needs a timed run on a host. Is it required in the PR, or may a test assert the early exit instead?
      RECOMMENDED: Add a test that runs run-away-hook.sh after deliver and checks it exits without starting Python; leave the timed measurement to a person. Basis: judgment

    Sources read

    • plugins/session-flow/scripts/away.py:953: cmd_deliver only sets status delivered and a timestamp; nothing is removed
    • plugins/session-flow/scripts/away.py:468: choose_report_path falls back to state_dir/report.md when .work/away is not git-ignored
    • plugins/session-flow/scripts/away.py:933: cmd_end copies the report to away/<session>/report.md
    • plugins/session-flow/scripts/away.py:1091: UserPromptSubmit hook returns nothing for delivered status and shows the report once for ended
    • plugins/session-flow/hooks/run-away-hook.sh:8: hook exits before Python when $DATA/away is absent
    • plugins/session-flow/scripts/tests/test_away.py: existing away tests to extend

    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.**.

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

    needs-owner-decision

    Priority

    medium

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions