Skip to content

fix(summary): one-line fixed issues, clip long records, ask for short ones - #30

Merged
riponcm merged 5 commits into
riponcm:mainfrom
bigfree:summary-compact-entries
Oct 31, 2026
Merged

riponcm merged 5 commits into
riponcm:mainfrom
bigfree:summary-compact-entries

Conversation

@bigfree

@bigfree bigfree commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Closes #29.

  • A fixed issue is one line in the summary: id, title, location. If the issue has no location, the fix's location is used.
  • Record text in the summary is clipped to 300 characters. Line breaks are folded first, and the cut only moves back to a space if one is in the second half of the line, so a long path doesn't shrink to the word before it. Locations are never clipped, only folded onto one line.
  • TITLE_CHARS (140) and RECORD_CHARS (300) are in storage.py. AI_INSTRUCTIONS.md and the summary description of the five write tools now state the limits from those constants. log_issue used to say "~140 chars recommended".
  • The "a few hundred to ~1,500 tokens" claim in get_summary, the server instructions and AI_INSTRUCTIONS.md now says a few thousand for an aged project. That's closer to what the summary is after this change. The README table still has the old estimate; I left it alone.
  • INSTRUCTIONS_VERSION is 2, because the fingerprint test requires a bump. The next pjm init replaces an older AI_INSTRUCTIONS.md and keeps the old one as .bak, so a hand-edited copy needs merging back. Probably worth a line in the 0.3.5 notes.

On the project from the issue (2.9k events now), the summary goes from 47.2 KB on main to 22.2 KB with this branch. Full suite passes (376).

summary.md is read at the start of every session, so its size is paid on
every session. The section caps from #19 bound how many records it shows,
but not how long each one is, and a fixed issue still carried its whole
fix text and its failed attempts.

A fixed issue is now one line: id, title, location. Every record text is
clipped to 300 characters; the location is never clipped. The full text
stays in issues/, events.jsonl and search.
…lips

Clipping keeps summary.md bounded, but a record written at its full length
still loses its tail there, and the guidance only asked for entries to be
"concise". The rules summary now states the limits: an issue title under 140
characters, every other record under 300, with further evidence going into
another record_attempt. A test ties the stated number to LINE_CHARS so the
two cannot drift.

INSTRUCTIONS_VERSION goes to 2 so existing projects pick up the line on
their next `pjm init`.
Review of the two previous commits found:

- The word-boundary cut took the last space anywhere in the line, so
  "see <long path>" clipped to "see..." and text with a leading space to
  "...". The cut now only moves back to a space in the second half of the
  line; otherwise it cuts hard.
- Clipping counted characters but kept line breaks, so a pasted traceback
  or a line starting with "## " still broke out of its list item. Whitespace
  is folded before measuring.
- A fixed issue logged without a location lost where it was fixed; the fix
  location is used then.
- The 140/300 limits were stated only in AI_INSTRUCTIONS.md, which a client
  that never calls get_instructions does not read. The summary descriptions
  of log_issue, record_attempt, record_fix, add_decision and add_note now
  state them too.
- Both numbers were written out by hand next to the constant that enforces
  one of them. TITLE_CHARS and RECORD_CHARS now live in storage.py and every
  surface formats them in. The rendered instructions are unchanged, so the
  version 2 fingerprint still holds.

The clipping test now checks the clipped text is a whole-word prefix of a
sensible length, not only an upper bound.
- A location was printed as given, so one containing a line break could
  still open a stray "## " heading in summary.md. _loc() folds whitespace
  the same way record text is folded, without clipping, and replaces five
  copies of the same f-string.
- _clip finds the word boundary with rfind's start index instead of a
  separate threshold check. Same output.
- record_fix said summary.md clips longer text, but fix text is no longer
  in summary.md. It now states only the limit.
- get_summary, the server instructions and AI_INSTRUCTIONS.md promised "a
  few hundred to ~1,500 tokens". An aged project is a few thousand now, so
  they say that. The version 2 fingerprint is updated; version 2 is not
  released yet.
- Tests: one check over the five tool descriptions instead of five schema
  reads, and the fixed-issue location cases as one parametrized test. The
  short-record check moved into the long-record test as its control.
The names carry the meaning; the reasoning is in the commit messages and the PR.

@riponcm riponcm left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks, this is great work. I re-checked it on our side:

  • Real project: a 238-event summary drops from 8,974 to 3,458 tokens.
  • Synthetic worst case: from 17,269 to 6,318 tokens.
  • Upgrade: from 0.3.4, pjm init refreshes the instructions, keeps the edited copy as .bak, and a second run changes nothing.
  • Tests: the new summary tests fail on main and pass here.

Two small follow-ups are on our side, not yours: a whitespace-only location now counts as none, and the README token table now uses measured numbers. Approving; this ships in 0.3.5.

@riponcm
riponcm merged commit 3bea0e7 into riponcm:main Oct 31, 2026
@bigfree
bigfree deleted the summary-compact-entries branch November 16, 2026 20:24
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.

summary.md is still ~12k tokens on an aged project: entries have no length limit

2 participants