Skip to content

fix(nap): add silent-failure detection when archival returns null on oversized file#636

Closed
diberry wants to merge 1 commit intobradygaster:devfrom
diberry:squad/25-nap-silent-failure
Closed

fix(nap): add silent-failure detection when archival returns null on oversized file#636
diberry wants to merge 1 commit intobradygaster:devfrom
diberry:squad/25-nap-silent-failure

Conversation

@diberry
Copy link
Copy Markdown
Collaborator

@diberry diberry commented Mar 26, 2026

When decisions.md exceeds 20KB but archiveDecisions() returns null (no entries archivable), emit a warning action. Adds 'warning' type to NapAction, extracts oversizedDecisionsWarning() helper. 3 tests.

Team review: Flight ✅, FIDO ✅, Procedures ✅

Closes diberry#25

…oversized file

When decisions.md exceeds 20KB but archiveDecisions() returns null
(no entries archivable — all recent or undated), emit a warning action
in the nap report instead of silently reporting 'nothing to clean up'.

Changes from review:
- Add 'warning' type to NapAction (was using 'cleanup' with cast)
- Extract oversizedDecisionsWarning() helper (DRY — was duplicated in runNap/runNapSync)
- Tests assert on type='warning' instead of just description text

Closes #25

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@diberry
Copy link
Copy Markdown
Collaborator Author

diberry commented Mar 26, 2026

@bradygaster Ready for your review — team-approved with 3-reviewer gate (Flight, FIDO, Procedures).

larsontim12 pushed a commit to larsontim12/squad that referenced this pull request Mar 27, 2026
) (bradygaster#636)

* test: add comprehensive nap feature tests (38 tests)

Covers 11 test categories for the nap context hygiene engine:
- Metrics collection (before state)
- History compression (Tier 1, ## section boundaries)
- Log pruning (7-day threshold)
- Inbox cleanup (merge + delete)
- Decision archival (20KB threshold, 30-day age)
- Deep mode (3 entries vs 5)
- Dry-run mode (no file modifications)
- Journal safety (.nap-journal lifecycle)
- Report formatting (humanized bytes, tokens, NO_COLOR)
- Edge cases (missing dirs, empty files, 100KB+ files, multi-agent)
- Combined scenarios (all actions + flag combinations)

Tests use isolated temp directories with cleanup. Written against
the NapOptions/NapResult/NapAction interface contract.

Closes bradygaster#635

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* docs: update Hockney history with nap test learnings

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* feat: implement nap feature — context hygiene for .squad/ state (bradygaster#635)

Add squad nap command with tiered compression, log pruning, decision
archival, and inbox cleanup. Supports --deep and --dry-run flags.

- Core engine: packages/squad-cli/src/cli/core/nap.ts
  - Tier 1: history compression (keep 5), log pruning (7d), inbox merge, decision archival (20KB/30d)
  - Tier 2 (--deep): aggressive history compression (keep 3)
  - Dry-run: scan and report without modifications
  - Journal-based safety (.nap-journal) for interrupted runs
  - Both async (runNap) and sync (runNapSync) exports
  - Humanized before/after report with token estimates
  - NO_COLOR support

- CLI entry: squad nap command + help text in cli-entry.ts
- REPL: /nap slash command + help text in commands.ts
- Skill template: .squad-templates/skills/nap/SKILL.md

All 3229 tests pass (38 nap-specific). TypeScript compiles clean.

Closes bradygaster#635

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@diberry
Copy link
Copy Markdown
Collaborator Author

diberry commented Mar 27, 2026

Closing as duplicate — Brady merged related archival fallback in #627 (count-based archiveDecisions).

@diberry diberry closed this Mar 27, 2026
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.

fix(nap): Add silent-failure detection when archival returns null

2 participants