Repository navigation
Conversation
First Principles Review (Fable 5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The Not justified as shipped
What this change shipsInventory (10 items) — 9 justifiedIntent: let operators widen SEL audit-log rotation/retention limits without editing source (issue #4993) — an ADDITION.
[FIRST-PRINCIPLES-REVIEWED] 40367c2 |
Design Review (Fable 5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS Residue of an abandoned mid-review design shipped: the description's "What changed" and a migration path both describe a Watch
Suggestions
[DESIGN-REVIEWED] 40367c2 |
GPT 5.6 Review — 🔴 changes requested (blocking)GPT 5.6 found at least one blocking issue that must be resolved before merging This comment is updated in place on each push. BLOCKING -- src/kiro_crew/sel.py:615 -- Untrusted legacy marker bypasses SEL coherence ceilings
Adjudication (Opus 4.8) — is blocking on each finding proportionate?F1 (fenced) — Harm rung: the fence anchors this at unbounded (crash-data-loss-corruption), but the code I opened shows the realized harm is a recoverable, visible disk-pressure issue, not silent unrecoverable loss. Conditions confirmed this run:
Recovery: offline reset of the marker; no auto self-correction ( Real fix (clamp legacy hints to 🏷️ Fenced finding(s) machine-flagged as likely edge caseThe security fence keeps these findings blocking regardless of adjudication; the only clearance path is a human override. The annotate-only pass judged the condition combination each one requires extreme, and pre-drafted the override rationale below. A repository writer must independently verify a rationale before posting it — it is machine-authored, and a wrong override on a security-class finding ships exactly the class the fence exists to stop.
False positive or not applicable? A repository writer can comment: |
Opus 4.8 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
7a1091f to
c71355f
Compare
Disposition: GPT blocking finding on
|
c71355f to
75d296f
Compare
|
Review dispositions for head
Same-span ledger — span Also carried in |
75d296f to
5a06de6
Compare
|
Pre-push review round 4 (local dual-model gate on the restructure), dispositions — new head Local Opus: PASS, 0 blockers, 2 advisories (both taken). Local GPT: 4 blockers, split verdict resolved finding-by-finding:
Span ledger Gates on |
|
5a06de6 to
281b0e4
Compare
5e8a01b to
87b2850
Compare
|
|
|
|
|
|
self-added: yes
|
|
|
self-added: yes
|
|
|
|
self-added: yes
|
|
|
self-added: yes
|
|
span=ff91a2389e17 Finding (F1, sel.py:2504): concurrent raises can land after both deletion-floor refreshes — needs-a-decision
|
|
self-added: yes
|
|
self-added: yes
|
|
span=4509d9f16a93 Finding (F2, test/test_sel.py:5273): the test leaks a per-test SEL daemon writer — fixed
|
|
span=ff91a2389e17 Finding (F1, src/kiro_crew/sel.py:559): a pre-upgrade sandbox can forge the deletion floor — needs-a-decision
|
|
span=6ebfad1fd011 Item 9 (whole-design): the Black-baseline removal + reformat of
|
|
span=ff91a2389e17 Finding (src/kiro_crew/sel.py:336): version-skew floor forge — needs-a-decision (unchanged)
|
The segment size cap (32 MiB), keep-count (7), and retention window (365 days) were hardcoded module constants, fixing the audit-log disk ceiling at ~256 MiB for every install: a small-disk container could not lower it, and a compliance install could not raise the keep-count to match the stated retention window. Read three overrides once at SecurityEventLog construction — KIROCREW_SEL_MAX_BYTES, KIROCREW_SEL_KEEP, KIROCREW_SEL_RETENTION_DAYS — via a fail-soft _env_int() helper. Malformed, zero, or negative values clamp to the default with a warning that names the variable only (never the rejected value, which could be a mis-pasted secret). Plain os.environ reads on purpose: kiro_crew.config would be an import cycle. The module constants stay the single source of the defaults, and the rotation/prune sites now read the instance attributes. Closes #4993
|
span=ff91a2389e17 Finding (src/kiro_crew/sel.py:336): version-skew floor forge — fixed
|
|
Maintainer note: PR #11780 (merged 2026-09-19, Already conflicting; when rebasing please also update |
|
Open-PR triage, 2026-10-05: REBASE + CONTINUE-DEVELOPMENT Checked head
No duplicate or superseding PR was found, so this PR should stay open. |
cruisercohen
left a comment
There was a problem hiding this comment.
Requesting changes on head 40367c2d01f7e35d4945dec52ad965627e80595b. It addresses #4993: the three raise-only variables, the fail-soft parse that never echoes the rejected value, and the clamped keep count all follow the shape the issue asked for. I can't approve it until the following are fixed.
-
Rebase needed. The branch is about 3,270 commits behind
mainand conflicts insel.py,metrics/events.py,sel.mdand.github/black-baseline.txt.mainhas since changedsel.pywith #13308 (chain lock anchored on the log directory) and #16598 (retry a failed best-effort append and count dropped events). Please replay the floor refresh and both delete phases against the currentprune()and rotation lock path, as the earlier overlap note asked. -
Hidden break after a clean rebase.
test_sandbox_governance_mask.py:302callssandbox._private_memory_seatbelt_rules(), which no longer exists onmain(#11780). That test fails even if the rebase applies cleanly. -
Open security-class finding. At
sel.py:615-618,_read_legacy_retention_floorseedskeep,daysandmax_byteswithmax()and never clamps them to_SEGMENT_MAX_BYTES_MAX/_RETENTION_DAYS_MAX. A planted legacy hint therefore lands in the new marker above the coherence ceilings. The cheap fix is to clamp the legacy hints the same way the env path clamps. That clears the fenced GPT finding without needing an override. -
Windows test failure in this PR's own test. On Backend Tests (Windows) (6),
TestEnvOverrides::test_directory_fsync_real_io_error_propagatesfails with "DID NOT RAISE OSError". Directory fsync is not attempted on Windows, so the injected EIO never fires. Skip it on Windows, or gate it on the same platform check the production code uses. -
Local failure to check after the rebase. Locally (Linux, Python 3.12),
TestSegmentEnumerationIsBounded::test_enumeration_stops_at_the_scan_capfails every time at this head ("walked 10 entries with a cap of 8"). The new floor-directory walk in the pending-record reader also goes throughos.scandir, so the test's counting wrapper sees both walks. It passed on the Linux CI shards, so it may depend on directory order. Please make the test count only the segment walk, or make the bound explicit for both walks, so it is deterministic.
The rest of test_sel.py, test_sel_prune_streaming.py, test_sandbox_governance_mask.py and the SEL TestIsSensitivePath cases pass locally at this head (935 passed). This PR also changes the sensitive-path gate and the sandbox readonly exposure, so a maintainer will need to sign off on those parts after the rebase as well. I'll review again when the head moves.
|
Thanks for working on this and for the careful raise-only design. We are closing this PR because main has since moved SEL rotation into src/kiro_crew/sel_rotation.py and the branch is about 7,300 commits behind, so a rebase would be close to a rewrite; cruisercohen's review on 2026-10-09 is also still open. The need is real and stays tracked in #4993. A fresh, smaller PR against sel_rotation.py is very welcome. The branch is left untouched, so you can reopen this PR at any time, or open a fresh one on current main, if you want to pick it back up. |
Problem / Motivation
Operators cannot widen the Security Event Log (SEL) limits without changing source code. A process-local override is not enough because the gateway, CLI, and scheduled jobs share one audit-log directory. A sibling with a scrubbed environment could rotate or prune at lower defaults and erase history protected by another process's raised policy.
Why it matters
SEL records tool calls and permission decisions. Retention settings must not let an audited child erase that evidence. Operators still need a safe way to retain larger segments, more closed segments, or more days of history for compliance.
What changed (motivation → approach → change)
Three startup variables widen the limits:
KIROCREW_SEL_MAX_BYTES,KIROCREW_SEL_KEEP, andKIROCREW_SEL_RETENTION_DAYS. Each value is raise-only. Invalid values fail soft to the compiled default without logging the rejected value. The keep count stays below the bounded segment scan.The highest declared max-bytes, keep, and days values live in
security_events.meta/retention_floor.json. The sandbox exposes that top-level leaf as readonly and nofollow. The shared sensitive-path gate hides it as defense in depth. Only a complete, regular, single-link marker can authorize deletion.A writer publishes an immutable pending raise before trying the non-blocking rotation lock. A lock holder reads the marker and pending records before rotation or deletion. A successful stamp folds every visible maximum into the marker. An incomplete or unauthenticated floor disables deletion. Rotation refreshes max bytes before closing the live file.
prune(keep_days=N)clampsNto the refreshed days floor before either age sweep.prune(keep_days=N)prune()_segment_keepbefore excess is computed.max(N, self._retention_days)after refresh.self._retention_days._segment_max_bytesbefore rotation. The count sweep refreshes keep independently.The SEL module and tests are Black-formatted and removed from the formatting baseline. The baseline removal rides along deliberately: this change already reformatted every hunk it touched in those files, and leaving them baseline-exempt afterward would let future formatting violations in them land unchecked - the exemption removal tightens the gate rather than adding churn. The test root clears the three variables between cases. Operator and system documentation describe the variables, shared floor, pending records, and fail-closed behavior. The documentation linter recognizes only the live readonly marker path.
Tests
python3 -m pytest test/test_sel.py test/test_sel_prune_streaming.py -q— 331 passed. This includes rotation, pruning, contention, tamper, symlink, FIFO, hard-link, malformed-marker, oversized-marker, non-integer-marker, and off-event-loop initialization regressions.EIOon the directory fsync propagates instead of being swallowed as an unsupported-platform hint; a skipped retention or prune sweep emits thekirocrew.sel.retention_skippeddegraded-health counter; and TB-scaleKIROCREW_SEL_MAX_BYTES/ 100-year-plusKIROCREW_SEL_RETENTION_DAYSoverrides clamp at coherence ceilings instead of folding into the monotone floor marker; and floor authority now lives inside the OS-sealedsecurity_events.d— a forged low floor at the legacysecurity_events.metapath neither lowers retention nor deletes protected audit segments on new code, and legacy values seed the new authority only upward.prune(keep_days=1)deletes an entry inside a 100-day floor. Both pass with this change.TestIsSensitivePathSEL cases passed for the live log, readonly metadata, rotated segments, and absolute paths.black --check --target-version py310, isort, flake8, and documentation lint passed. The touched Python files remain outside the Black baseline.Manual verification
N/A — unit coverage exercises the construction, rotation, count sweep, age sweep, live-log rewrite, lock contention, and path-security behavior without an external service.
Related Issues
Closes #4993
Pattern harvest
Rule candidate: review-prompt
Pattern: Shared deletion limits need one authenticated monotone floor that every delete-triggering path refreshes.
Checklist
feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)