Files
skills/docs/requirements/061-bounded-council-files.md
T
Kevin Veen-BirkenbachandClaude Opus 5.5 0fad1bfae3 feat: hub and skills requirements 032 to 063
Hub: send in the field (032), coherent speak box (033), stream head band (034), Match at full width with its pile (035, 036), Home without the outer box (037), badge to Match (038), rejects that survive a changed or withdrawn card (039), the release card (040), code marks in the review diff (041), why Deny is off (042), the undo window clock (043), widgets without inner boxes (044), the Artifacts head on one line (045), accepting a red gate's risk (046), one code box (047), done rows greyed and folded (048), one control height (049), menus that stay open (050), radio settings in the Device card (051), bubbles beside the modes (052), agent settings on every face and name (053), pin only by menu (054), WASD in Match (055), the flowing card edge (056), Schedules in Controls (057) and the hub poll cost (059).

Skills: the coach leaves for its own repository kevinveenbirkenbach/coach (058; test_install pins its four skills in skills-lock.json and stays red until that repository is published and pinned), hooks and timers start fewer processes (060), council files on hot paths stay bounded and mirror by marker instead of mtime (061), scripts and hooks hand agents less output (062), and block.py builds the commit table and message block in one run (063). Requirement documents 032 to 063 with their implementation amendments.

MEDUSA false positives accepted after kvb-think-criticize (36 lines): MM-SCAN-058 (pla inside replace or plan), JB-SCAN-616/641 (the local clip helper), CODEGEN-SCAN-001 (drop-in paths), CGS-SCAN-029 (systemctl argv from constants), CGS-SCAN-040 (runner poll loop), FLA-SCAN-055 (feedback), WM-SCAN-354, AI-BACKDOOR-006, GENAI-SCAN-1270, B604 (runner shell path for passkey-verified commands), TC004, EXA002, EXA006, EXA010 and WEB-SSRF.

🎯 Fix: 92 %
💥 Break: 8 %
💸 Tokens: 89 %
⏱️ Velocity: –
🛡️ Security: ~100 %
🏆 Score: 95
🚦 Gate: ⛔ break 8 % > 5

Created-with: https://s.veen.world/skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 08:44:15 +00:00

82 lines
3.8 KiB
Markdown

# 061 - Bounded Council Files
## User Story
As the operator, I want the council files on hot paths to stay small and be
read only when they changed, so that every prompt and Bash call stays cheap
as the weeks pass.
## Decisions (operator-confirmed 2026-11-25; do not re-litigate)
1. **Queue histories** (operator): `kvb-org-queue-cleanup` trims both queue
histories to 30 days (`WINDOW_SECONDS`); `learned()` is memoized per
process on both files' (mtime_ns, size). Amended 2026-11-25 in the
implementation: the trim opens every round, before the chair check; a
line that is no history row stays, and rows appended during the rewrite
follow into the new file; the memo also keys on the inode and the
config's learning keys.
2. **Alerts** (operator): the `alerts.jsonl` read is skipped while its size
and mtime match the seen marker; rows past `ALERT_TTL` are dropped on
append; a memory stage is entered at once and left only after 2 samples
below it; "recovered" lines go to the chair only. Amended 2026-11-25 in
the implementation: the marker also holds the inode; an alert row carries
`chair`, and the disk "recovered" line is chair-only too.
3. **Mirror tail** (operator): the mirror stores the source's (inode, size)
and appends only the grown tail; a shrunk file or a new inode takes the
full merge. Amended 2026-11-25 in the implementation: the marker is
`.<name>.mirrored` beside the kept copy, and the stored size ends at the
last complete line, so a row still being written waits for the next
mirror. Amended 2026-11-25 after `make test`: an unchanged source is
skipped by the marker (same inode, marked size equal to its size), not
by an equal mtime; a copy created or a row appended in the source's
timestamp tick shared its mtime and lost those rows.
4. **Queue hold** (operator): the signal handler sets a `threading.Event`,
and a waiting hold waits on it for `POLL_SECONDS` instead of 0.2 s
ticks. Amended 2026-11-25 in the implementation: `Event.set()` inside a
signal handler can deadlock when the signal lands while the main thread
holds the event's lock in `Event.wait()`; the hold uses
`signal.set_wakeup_fd` on a pipe and `select` for `POLL_SECONDS`
instead, which wakes at once on a signal the same way.
## Approach
```mermaid
flowchart TD
subgraph P["🧭 0 · Preparation"]
P1["📋 Write requirement"] --> P2{"✅ Operator approves?"}
P2 -- "✏️ corrections" --> P1
end
P2 -- "🤖 yes" --> A1
subgraph A["🗄️ A · Files"]
A1["✂️ Trim queue histories"] --> A2["🧠 Memoized learned()"]
A2 --> A3["🚨 Alerts skip, TTL, hysteresis"] --> A4["🪞 Mirror tail"]
A4 --> A5["⏳ Event wait in the hold"] --> A6["✍️ Tests written, not run"]
end
A6 --> C1
subgraph C["🧪 C · Verification"]
C1["🧪 Unit and integration"] --> C2{"🟢 Green?"}
C2 -- "🔴 no: fix" --> C1
C2 -- "🟢 yes" --> CF{"💬 Operator feedback?"}
CF -- "✏️ changes" --> A1
end
CF -- "👍 fits" --> D1["🏁 Review, commit with operator OK, hand-over"]
```
## Acceptance Criteria
- [ ] A cleanup round leaves no history row older than 30 days and keeps
every newer row byte for byte.
- [ ] Ten prompts with an unchanged `alerts.jsonl` read it once.
- [ ] A memory value flapping around its threshold sends one alert per
stage change, not per sample; a non-chair gets no "recovered" line.
- [ ] A grown source mirrors only its new rows; a rewritten one merges.
- [ ] A waiting hold wakes at most once per `POLL_SECONDS` without a
signal, and at once on one.
### Tests
- [ ] Unit: trim, memo, alert skip and hysteresis, mirror tail and merge,
event wait.
- [ ] Integration: a cleanup round on a fixture council.
- [ ] E2E: n/a: no page change.