fix(clean): reserve room for the stamp so the playbook body isn't truncated on load#5
Merged
Merged
Conversation
…ncated on load save_playbook capped the body to PLAYBOOK_MAX_CHARS and THEN prepended a ~60-char provenance stamp, but load_playbook re-caps stamp+body to PLAYBOOK_MAX_CHARS. A maxed-out playbook therefore lost its last ~60 body chars on the way to the workers, and ops reported the pre-truncation length. Cap the body to PLAYBOOK_MAX_CHARS - len(stamp) so stamp+body fits the same budget load applies, and the whole body survives (also fixing the over-reported size). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Owner
Author
Gate: adversarial verify → clean (SAFE)The verifier confirmed the fix is correct and regression-free across every angle:
The verifier noted one pre-existing, non-regression, whitespace-only nit: the read-side Gate verdict: clean. Dry-run mode → open for human merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
The playbook is the supervisor's advisory memory, injected into every worker pass (ops → telemetry → supervisor → playbook → workers).
save_playbookcaps the body toPLAYBOOK_MAX_CHARS(1500) and then prepends a ~60-char provenance stamp, butload_playbookre-caps stamp + body toPLAYBOOK_MAX_CHARS:So a maxed-out playbook silently loses its last ~60 body characters before reaching the workers, and
ops.update_playbook_implreportsupdated playbook (1500 chars)while only ~1440 are ever delivered. The tail of the supervisor's learned guidance never arrives.Fix
Build the stamp first and cap the body to
PLAYBOOK_MAX_CHARS - len(stamp), sostamp + bodyfits the exact budgetload_playbookre-applies on read. The whole stored body then survives the round-trip, and sincesave_playbookreturns that body, ops' reported size now matches what workers receive. The read-side re-cap (a guardrail against a hand-edited oversized file — the playbook is human-editable) is preserved.Test
test_full_size_playbook_body_is_not_truncated_on_loadsaves an over-max playbook and asserts the entire stored body survivesload(tail included) while staying within the cap and keeping the stamp — verified to fail on the pre-fix code (the tail is dropped). Existingtest_size_cap_enforced/test_roundtrip_and_stampstill pass (cap still enforced, stamp still present).Full clean suite: 134 passed, coverage 92% (gate 75%). Offline evals: 8/8 green.
ruff check pipeline evalsclean.Scope note: this is the playbook size-cap handling only — it does not touch the deliberately-deferred playbook prompt-injection trust-model concern.
Found by the autonomous bughunt loop (iteration 5), during a fresh sweep of
pipeline/cleanafter merging PRs #2–#4. Dry-run mode — human merges.🤖 Generated with Claude Code