Skip to content

Start lookup pages with a begin record that states their status - #108

Merged
liby merged 1 commit into
mainfrom
feature/lookup-status-before-records
Nov 21, 2026
Merged

liby merged 1 commit into
mainfrom
feature/lookup-status-before-records

Conversation

@liby

@liby liby commented Nov 21, 2026

Copy link
Copy Markdown
Member

Agents keep the first lines of a lookup far more often than its last. Between 2026-10-08 and 2026-11-21, on both of the maintainer's machines and outside Sessidx's own development, 65–79% of show results and 39–48% of grep and search results showed no end record. Most of those commands piped the output through head -n, head -c, or cut, although the skill has told agents not to since 2026-10-13. Every page is assembled before it is written, so its status is already known when the first data line goes out.

A search, grep, or show page now starts with {"type":"begin","complete":…,"stale":…,"more":…,"returned":N}. Its fields come from the same values as end, and more is true when end.next is set. begin carries no cursor, so it stays short enough to survive head -c. end is unchanged, because scripted loops read end.next from it and Pi keeps the last part of a long output. Errors still print only end. Filters that pass non-data records through, as the skill's examples do, keep working. A command that reads the first line positionally, or counts lines, now sees one more record.

Fable and Oracle reviewed the design. Oracle preferred a stderr summary that leaves stdout unchanged, but the same scan showed why that would not work:

  • 30–37% of grep and search calls merge stderr into stdout, and a third to a half of those pipe straight into jq, which a non-JSON line would break.
  • 10–18% of the results without end came from commands that discarded stderr.

A jq or script filter that keeps only data records still drops both begin and end. The page_status row in docs/formats.md records the rule, its evidence, and what it leaves uncovered.

The test helper stream now checks every lookup's begin against its end. A new test reads a grep, show, and search cut to their first line, and it fails when begin is removed. cargo mutants --in-diff caught all 18 mutants.

Agents keep a lookup's first lines far more often than its last: on
both of the maintainer's machines, 39-79% of `search`, `grep`, and
`show` results outside Sessidx's own development showed no `end`,
mostly after `head -n`, `head -c`, or `cut`, although the skill has
said not to since 2026-10-13. The status those agents never saw is
known before the first data line, because every page is assembled
before it is written.

A `search`, `grep`, or `show` page now starts with `begin`, carrying
`complete`, `stale`, and `returned` from the same values as `end`, and
`more` when `end.next` is set. It has no cursor, so it stays short
enough for `head -c`, and `end` stays where loops and Pi's tail-keeping
truncation read it. A stderr summary was rejected because a third of
`grep` and `search` calls merge stderr into stdout, often straight
into `jq`, and a tenth or more of the calls that lost `end` discarded
stderr. The test helper now checks every lookup's `begin` against its
`end`.
@liby
liby merged commit a7c82c4 into main Nov 21, 2026
5 checks passed
@liby
liby deleted the feature/lookup-status-before-records branch November 21, 2026 05:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant