Skip to content

hr-what-next: close ledger items whose done-when condition holds - #506

Closed
bompus wants to merge 5 commits into
mainfrom
feat/ledger-done-when
Closed

bompus wants to merge 5 commits into
mainfrom
feat/ledger-done-when

Conversation

@bompus

@bompus bompus commented Oct 31, 2026

Copy link
Copy Markdown
Owner

A ledger item can end with done-when: <condition>[; <condition>], each condition pr-merged owner/repo#n, issue-closed owner/repo#n or path-absent <absolute or ~/ path>, all of which must hold. Today a finished line stays open until someone notices; this lets a plan say what finishes it, and lets a script close it with the evidence.

  • plan-ledger.mjs exposes the parsed clause as doneWhen on open and deferred items. The clause must be the item's last field; a clause it cannot read is an error; text in backticks is prose and is ignored. The continuity snapshot does not carry the field.
  • check-open-work.mjs prints a "done-when" group (closeable, pending or error per line). Its exit code and other output are unchanged.
  • The new done-when.mjs <plan> prints the same and writes nothing. With --apply it closes only closeable lines through close-ledger-line.mjs, guarded by --expect so a line edited since is refused, with the evidence it found.
  • A failed lookup, an offline run, an unknown reference, a pull request named as an issue (or the reverse) and any path error other than ENOENT or ENOTDIR are errors and never close a line. A pull request closed without merging stays pending.
  • github-state.mjs also reports which references are pull requests and when they finished, and remembers answers for the life of the process, so one run asks GitHub once per reference.
  • No existing plan file changes; plans without a clause behave as before.

Replaces chief-of-staff's ledger-done-when.ts, which can be deleted once this is pinned.

Checked: tests written first (they failed before the code); a local review found four ways a line could close wrongly (a later field read as part of a path, a literal trailing dot dropped, whitespace that bypassed --expect, Windows paths read as relative) and each now has a test. bun run check and the full test run pass.

…items whose condition holds

A ledger item may end with done-when: <condition>[; <condition>], each condition pr-merged owner/repo#n, issue-closed owner/repo#n or path-absent <absolute or ~/ path>, all of which must hold. plan-ledger.mjs parses the clause onto open and deferred items (text in backticks is ignored; a clause it cannot read is an error). check-open-work.mjs prints a done-when group of closeable, pending and error lines without changing its exit code. The new done-when.mjs prints the same and writes nothing; with --apply it closes only closeable lines through close-ledger-line.mjs, guarded by --expect, with the evidence found. A failed lookup, an unknown reference, a pull request named as an issue or the reverse, and a path that cannot be read are errors and never close a line; a path is absent only on ENOENT or ENOTDIR.
… trailing dot, refuse paths a close could be redirected by, and look a reference up once

A later field such as recheck: was read as part of a path, so a path-absent clause could check the wrong name and report a line closeable. The clause must now be the item's last field. A trailing period is dropped only after a pull request or issue reference, not from a path. A path with a tab or consecutive spaces is an error, because the close compares collapsed text and the path could change between evaluation and close. A Windows path is an error. github-state.mjs remembers what GitHub said about a reference for the life of the process, so check-open-work.mjs asks once about a reference both its checks name.
@bompus bompus added the author:anthropic Pull request written by a anthropic model label Oct 31, 2026
…POSIX path tests off it

The parser refused every Windows temp path as not absolute, so the done-when tests failed on the Windows runner. A drive path is absolute only on Windows; elsewhere it is still an error. The symlink and trailing-dot tests depend on POSIX file-name behavior and run only there.

@bompus-ai-review bompus-ai-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bompus AI Review (GPT-6.1 Sol, xhigh reasoning): 3 finding(s).

… no space after its colon, and expand ~ literally

The close compared whitespace-collapsed text, so a path edited between evaluation and close could pass: close-ledger-line.mjs gains --expect-exact, and done-when.mjs uses it. A later field written as recheck:2026-11-01 was read as part of a path; the field guard no longer needs a space after the colon. A home directory containing a dollar sequence was substituted as a replacement pattern; ~ now expands as literal text.

@bompus-ai-review bompus-ai-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bompus AI Review (GPT-6.1 Sol, xhigh reasoning): 2 finding(s).

…arenthesized later field

A double-backtick span was stripped as two empty spans, which exposed its contents as a clause. Spans are now matched by delimiter length. A later field in parentheses or brackets, such as (recheck: 2026-11-01), was read as part of a path; the field guard now also looks after an opening bracket or comma.

@bompus-ai-review bompus-ai-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bompus AI Review (GPT-6.1 Sol, xhigh reasoning): 0 finding(s).

Review 3: only high findings and above are posted from here on.

@bompus bompus closed this Oct 31, 2026
@bompus
bompus deleted the feat/ledger-done-when branch October 31, 2026 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author:anthropic Pull request written by a anthropic model

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant