Skip to content

perf(cli): stream-scan last session audit_degraded in doctor - #502

Merged
christopherkarani merged 2 commits into
mainfrom
factory/issue-411
Aug 18, 2026
Merged

perf(cli): stream-scan last session audit_degraded in doctor#502
christopherkarani merged 2 commits into
mainfrom
factory/issue-411

Conversation

@christopherkarani

Copy link
Copy Markdown
Owner

Summary

  • ryk doctor no longer readFileAllocs last-session events.jsonl (up to 64MiB) just to detect "type":"audit_degraded".
  • Stream-scans a 4KiB stack window with needle.len-1 overlap; cap still max_audit_log_len.
  • Detection kept. Fail-open on join/open/read errors kept (doctor must not crash on missing evidence).

Fixes #411

Test Plan

  • ./scripts/zig build test-lib -Dtest-filter=lastSessionAuditDegraded (worktree /tmp/ryk-factory-wt-411) — 24 tests passed, including:
    • pointed-at session detects audit_degraded
    • empty/whitespace .ryk/last and missing events → false
    • needle after 12KiB pad → true
    • needle split across 4KiB chunk → true

Notes

  • Offline doctor UX only. No hook/evaluate/policy/sandbox change.
  • No secrets. No protection-grade wording change.

ryk doctor no longer readFileAllocs last-session events.jsonl (capped
at 64MiB) just to look for audit_degraded. Stream a 4KiB window with
needle-length overlap and stop on the first hit. Fail-open on read
errors is unchanged.

Fixes #411
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@christopherkarani christopherkarani added in-review PR open; review/verify area:cli CLI commands doctor install priority:p2 Normal priority labels Aug 16, 2026
@christopherkarani

Copy link
Copy Markdown
Owner Author

REVIEW_PACKET pr=502 verdict=APPROVE findings=0

Adversarial review. Orchestrator did not write product code. A2A ryk-review/ryk-test down (only :9900 up).

Scope

src/cli/doctor.zig only. Stream-scan last-session events.jsonl for "type":"audit_degraded" instead of readFileAlloc (64MiB). Offline doctor UX. No hook / evaluate / policy / sandbox change.

Hard-fail checks

  • Fail-closed: N/A (doctor). Fail-open on join/open/read still returns false. Unchanged.
  • Deny not softened. Residual ask not rewritten.
  • Grade honesty: no protection-grade wording. Still a doctor health line.
  • Secrets: none.
  • Cap: still max_audit_log_len. Needle unchanged.

Stream-scan

4KiB stack window + needle.len-1 overlap. Split-across-chunk and post-12KiB cases are tested. Same substring match as before.

Gates

  • Path gate: agent-gate.sh --paths src/cli/doctor.zigtest-fast.sh units
  • ./scripts/zig build test-lib -Dtest-filter=lastSessionAuditDegraded24/24 (all 4 lastSessionAuditDegraded tests OK)
  • test-fast.sh units: 2669 passed / 37 skipped / 18 failed — daemon_trust / host_identity / cli.run under world-writable /tmp. Known host noise. Not this diff.

Stamping review:approve + test:pass. merge_ready still needs GitHub CI CLEAN.

@christopherkarani christopherkarani added review:approve Factory reviewer approved test:pass Factory tester passed real gates labels Aug 17, 2026
@christopherkarani
christopherkarani merged commit de08938 into main Aug 18, 2026
10 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:cli CLI commands doctor install in-review PR open; review/verify priority:p2 Normal priority review:approve Factory reviewer approved test:pass Factory tester passed real gates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[PERF] Doctor reads full audit events.jsonl (up to max_audit_log_len) for health checks

1 participant