fix(nap): archive undated decisions and add count-based fallback#38
Closed
fix(nap): archive undated decisions and add count-based fallback#38
Conversation
Bug 1: Undated entries (### headings without YYYY-MM-DD) were immune to archival because daysAgoFromLine() returns null and the split logic treated null as 'recent'. Now treats undated entries as archivable when file exceeds threshold — they are archived before dated recent entries. Bug 2: When all entries are <30 days old, archiveDecisions() returned null regardless of file size. Added count-based secondary pass that keeps the most recent entries and archives the rest when the file exceeds threshold after age-based pruning. Fixes #20 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Owner
Author
|
Superseded by bradygaster/squad PR bradygaster#627 which merged the count-based fallback with Procedures' correction (undated entries preserved). Our fix in this PR was partially rejected by Procedures for the same reason Brady adopted. No longer needed. |
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.
fix(nap): Archive undated decisions and add count-based fallback
Fixes #20 —
decisions.mdgrows unbounded becausearchiveDecisions()silently fails on real-world content.Bugs Fixed
Bug 1: Undated entries immune to archival
daysAgoFromLine()returnsnullfor entries withoutYYYY-MM-DDdatesnulldaysAgo intorecent→ never archivedold/undated/recent). Undated entries are archived alongside aged-out ones when file exceeds threshold.Bug 2: Age-only pruning fails for active projects
old.length === 0→ returns null regardless of file sizeEvidence
Both bugs confirmed on
bradygaster/squad@dev— verified the code is identical upstream. This repo'sdecisions.mdis at 345KB (17× the 20KB threshold). Archival has been silently returningnullsince Feb 28.TDD Approach
5 new test cases written first (red), then implementation (green):
archives undated entries when file exceeds thresholdarchives mixed dated+undated — keeps recent dated, archives undatedarchives entries when all are recent but file exceeds threshold (count-based fallback)preserves all entries — no data loss during archivalsecondary pass keeps most recent entries by date, archives oldestResult: 43/43 nap tests pass. No existing tests broken.
Changes
packages/squad-cli/src/cli/core/nap.tsarchiveDecisions()test/nap.test.tsgenerateDecisions()helperPostmortem
Full postmortem posted on #20.
Root cause: Commit
aaefeb1(Feb 28) — Copilot wrote implementation + 38 tests in one pass. Tests used synthetic2024-01-XXdated fixtures, never challenging the "entries always have dates" assumption. The happy path worked; adversarial cases were never considered.Key lesson: "AI writes the tests it believes in, not the tests that break it." Adversarial test generation must be a deliberate separate step by a different agent.
10-Agent Team Review
Issues #20 and #21 received full team reviews from Flight, EECOM, FIDO, Procedures, and Telemetry. Key findings:
squad doctoralready exists (extend, don't recreate)squad.decisions.*OTel metrics exist (subsystem is completely dark)merge=union) conflicts with line-deletion archivalFollow-up Issues Created
##heading awareness in archiveDecisions