Skip to content

feat(guardian): verify callbacks and bound retention - #7

Merged
gagan114662 merged 2 commits into
mainfrom
feat/guardian-lifecycle
Aug 1, 2026
Merged

gagan114662 merged 2 commits into
mainfrom
feat/guardian-lifecycle

Conversation

@gagan114662

@gagan114662 gagan114662 commented Jul 31, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • distinguish configured Guardian hooks from callback-proven active monitoring
  • continuously compact per-agent local finding sinks with complete-record retention
  • preserve late records from the previous file generation across compaction
  • baseline activation so pre-configuration records cannot falsely prove callback execution
  • encode file generation into exact JavaScript-safe cursors so compaction resets readers safely
  • add a three-alert Playwright observer smoke test and privacy assertions

Verification at exact head 1f8b7a49f0e6dada6ff6be846ade97d2705a03ac

  • repository-wide pnpm check: passed
  • desktop TypeScript: passed
  • desktop tests: 3,752/3,752 passed
  • Tauri library: 1,860 passed, 14 ignored
  • Guardian focused native tests: 11/11 passed
  • Guardian Playwright smoke: 1/1 passed
  • E2E production build: passed
  • diff/file-size/format checks: passed

The first Tauri and Playwright attempts were sandbox-blocked on localhost binds; the unchanged tree passed both with local-network permission.

Originating Buzz channel: 2db0f46d-71e4-46c2-9798-3b248dac5fff

Co-authored-by: gagan114662 <[email protected]>
Signed-off-by: gagan114662 <[email protected]>
@gagan114662
gagan114662 marked this pull request as draft July 31, 2026 18:30
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@xhawk-ai xhawk-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 Review Summary

I reviewed the Guardian lifecycle change that adds callback-proven health, cursor generations, continuous findings retention, and E2E coverage. The main concerns are in the backend retention/health logic: compaction can drop findings written concurrently by callbacks, and historical findings can overwrite a current broken health state as active.

🔍 Findings

🟠 High 1 · 🟡 Medium 1

.and_then(|()| target.sync_all())
.map_err(|error| format!("failed to persist retained Guardian storage: {error}"))?;
set_private_permissions(&temporary, 0o600)?;
std::fs::rename(&temporary, path)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High

This replacement races with the callback writer: any Numbat hook that appends after read_to_end (or holds an append fd to the old inode while this rename happens) writes records that are not present in retained, and the rename then makes those security findings unreachable. Continuous compaction needs coordination with writers or a strategy that does not replace the actively appended file after taking a snapshot.

Comment on lines +611 to +613
if !batch.findings.is_empty() && batch.health.state != "active" {
batch.health = active_health();
write_health(&app, &agent_pubkey, &batch.health);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium

This upgrades every non-active health state based on any retained historical finding. If Numbat is later uninstalled (unsupported/disconnected) or retention fails and the worker writes stale, the next read that returns an old finding overwrites that current failure with active, falsely reporting Guardian monitoring as healthy.

Co-authored-by: gagan114662 <[email protected]>
Signed-off-by: gagan114662 <[email protected]>
@gagan114662
gagan114662 marked this pull request as ready for review August 1, 2026 17:31
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@gagan114662
gagan114662 merged commit ba6f1e0 into main Aug 1, 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.

1 participant