Skip to content

fix(notify): prepare private cache file before transaction budget - #332

Merged
777genius merged 4 commits into
mainfrom
fix/observation-cache-preflight
Oct 4, 2026
Merged

777genius merged 4 commits into
mainfrom
fix/observation-cache-preflight

Conversation

@777genius

@777genius 777genius commented Oct 4, 2026 •

Copy link
Copy Markdown
Owner

Windows first valid claims can fail because private temporary-file creation alone exceeds the 250ms transaction allowance. Original failed traces measured 288-791ms in NtCreateFile, including 537.766ms after the publication guard merged.

Prepare one empty private temporary file before starting the existing 250ms locked read/publication context, as root preflight already precedes that context. The original caller context still governs the complete claim and is checked before and after allocation; complete claim duration can exceed 250ms. This is an explicit budget-boundary change selected under the owner's delegated decision, not a claim that Windows I/O became faster.

All history and clock decisions remain under the permanent lock. Windows revalidates its pinned root and the replacement target during publication. Initial protected private ACL, atomic rename, checked close before admission, pre-rename deadline guard, post-publication check, fixed 60-second window and no automatic retry remain intact. Unused preparations are removed on every early exit. Eager preparation also makes duplicate lookup require a writable private root; allocation failure still denies admission. Existing standalone runtime writes remain thin prepare/publish wrappers.

Validation: Independent source and composition review accepted final eab71f7 against current main 8d5f814. The internal fix diff remains unchanged after integrating the concurrent Claude-label PR #331. Internal code is byte-identical to accepted 10806b8. Four focused macOS scenarios pass. Real-file tests cover canceled/expired preflight, document preservation, duplicate cleanup, Windows ACL changes after preparation and one-shot publication. The held-lock gate still requires lock/deadline denial, and bounds transaction BudgetElapsed rather than total preflight+claim time. Native Windows Go 1.25/1.26 qualification passed on the first attempt, including the complete shared cache/Gemini packages, private-file lifecycle and ACL contracts, and 20 unchanged strict consent repetitions.
https://github.com/777genius/agent-notifications/actions/runs/37195341892

#330 is merged and its original-attempt OS recorder accompanies normal final-head qualification. This PR now targets current main and preserves #331. Independent composition review also accepted merge tree 3fa9bc826cc9e1c4e13f7876e7cc88b5749f830b against main 75b7acd: the later #333/#334 changes are limited to landing/workflow/PNG files, with all Go code and qualification paths byte-identical to the CI head. All 25 final-head checks passed, including full Windows Go 1.25 and 1.26 on attempt 1. Passing controls do not prove faster syscalls or identify the driver.

Refs #320

@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.

@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a726c629-3787-4f25-919a-84dd2ccd1fd4
📥 Commits

Reviewing files that changed from the base of the PR and between 7cfaa7d and d255ef3.

📒 Files selected for processing (12)
  • docs/WINDOWS_OBSERVATION_DIAGNOSTICS.md
  • docs/gemini-notifications.md
  • internal/installruntime/private_cache_windows.go
  • internal/installruntime/private_cache_windows_test.go
  • internal/notification/observation/cache.go
  • internal/notification/observation/cache_other.go
  • internal/notification/observation/cache_preflight_test.go
  • internal/notification/observation/cache_preservation_windows_test.go
  • internal/notification/observation/cache_publication_test.go
  • internal/notification/observation/cache_test.go
  • internal/notification/observation/cache_unix.go
  • internal/notification/observation/cache_windows.go

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Cache claims now prepare temporary files before starting the locked transaction. Platform cache implementations manage preparation and cleanup, and Windows writes publish through a single-use prepared handle. The documentation and tests reflect the updated timing and failure reporting.

Changes

Observation cache claim and publication

Layer / File(s) Summary
Windows prepared write lifecycle
internal/installruntime/private_cache_windows.go, internal/installruntime/private_cache_windows_test.go
Windows writes now prepare a private temporary file before publication. The prepared handle validates the root, supports one publication, and removes unpublished files when closed. Tests cover ACL changes, reuse attempts, and temporary-file cleanup.
Claim preflight and platform cache lifecycle
internal/notification/observation/cache.go, internal/notification/observation/cache_windows.go, internal/notification/observation/cache_unix.go, internal/notification/observation/cache_other.go, internal/notification/observation/cache_*_test.go, docs/WINDOWS_OBSERVATION_DIAGNOSTICS.md, docs/gemini-notifications.md
Claim prepares the cache before starting the lock-budget context. Unix and Windows cache implementations prepare and clean up temporary files; unsupported platforms return cache_unavailable. Tests and documentation describe preflight failures, cleanup, and the transaction budget.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant RecentCacheClaim
  participant windowsCache
  participant PrivateCacheRoot
  participant PrivateCacheWrite
  Caller->>RecentCacheClaim: Claim(ctx)
  RecentCacheClaim->>windowsCache: Prepare(ctx)
  windowsCache->>PrivateCacheRoot: PrepareWrite(ctx, name)
  PrivateCacheRoot-->>windowsCache: prepared write
  RecentCacheClaim->>windowsCache: Write(data)
  windowsCache->>PrivateCacheWrite: WriteContext(ctx, data)
  PrivateCacheWrite-->>windowsCache: publication result
  windowsCache-->>RecentCacheClaim: write result
  RecentCacheClaim-->>Caller: claim result
Loading

Merge Risk: ⚪ Minimal · up to d255e

The change moves private cache file preparation ahead of the 250 ms transaction budget, so total claim time can exceed that budget. No merge-blocking issue was identified. Normal current-head CI should still finish before merge.

Security Architecture Review

Security architecture risk: 🔵 Low · up to d255e

The inspected changes preserve fail-closed admission, serialized attempt tracking, and private-file publication controls. Preparation now occurs before the transaction timeout, so complete claims can take longer and duplicates also require temporary-file allocation. No introduced security defect was established, but incomplete failure and interference coverage leaves bounded uncertainty.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The inspected claim path affects attempt tracking and admission at one local runtime root. A supplied key must be a SHA-256 hex value and selects an attempt record, not a filesystem destination; the Windows adapter publishes to the fixed observations.json name. No expanded filesystem privilege or cross-service authority is demonstrated by this path.

Trust Boundaries and Controls

  • observed — Windows preparation creates the temporary file with a private security descriptor in the initial creation call. Publication revalidates the pinned root's directory and private-ACL properties, validates the existing target as private, regular, and single-link, checks cancellation, and renames relative to the held root handle.
  • observed — Linux and macOS retain root ownership and permission checks plus bounded, no-follow cache reads. Preparation creates an exclusive 0600 temporary file; publication checks write length, sync and close results, and context state before replacement.

Resilience and Maintainability Implications

  • observed — Preparation failure, lock denial, invalid history, duplicate detection, and publication failure do not grant admission. Windows publication always closes its prepared resource, reports a close error when applicable, and marks successful replacement before cleanup so the committed document is not deleted. Cleanup errors on unused preparations are best-effort rather than a proven recovery guarantee.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 10 files. (2 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely identifies the main change: preparing the private cache file before the transaction budget starts.
Description check ✅ Passed The description gives a detailed summary and validation results, so it is mostly complete. It does not include the template’s explicit Summary, Test plan, or CLA headings and omits the CLA acknowledgm…
Full details: Docstring Coverage

Explanation

Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 10 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

I’m a rabbit with a cache to tend,
I tuck a clean temp file around the bend.
Before the clock begins its race,
I ready each write in its place.
One neat publish, then cleanup’s done,
And off I hop beneath the sun.

Comment @coderabbitai help to get the list of available commands.

@777genius

Copy link
Copy Markdown
Owner Author

Independent source review accepted exact d255ef3 against 9fb6035 with no actionable findings.

Internal code matches accepted and native-tested 10806b8 exactly. The internal diff SHA256 is 95821a099ad9d07d82304642f0f85824974ed1ad87fe063e9de9f44e4bc5ee1d. Documentation preserves recorder limits and explicitly defines preflight, inherited caller deadlines, the 250ms transaction budget and eager duplicate preparation.

Native Windows Go 1.25/1.26 canary 37195341892 passed on the first attempt. Normal exact-head CI is pending; this source acceptance does not claim faster I/O or a known driver cause.

777genius added a commit that referenced this pull request Oct 4, 2026
Retain bounded named GeneralProfile/FileIO/Minifilter recordings from original Windows qualification failures without changing strict outcomes. Independent review and all 12 current-head checks passed; native event/stack decoding verified recorder coverage.

Preserve original head ancestry for dependent PR #332. This records evidence and does not claim an availability cure.

Refs #320
Base automatically changed from chore/windows-observation-os-evidence to main October 4, 2026 10:43
Preserve the concurrent Claude branding changes and qualify their composition with the notification cache fix.

Refs #320
@777genius

Copy link
Copy Markdown
Owner Author

Independent read-only composition review accepted exact head eab71f7 against main 8d5f814. No blocking findings.

The previously reviewed internal fix is unchanged (diff SHA256 95821a099ad9d07d82304642f0f85824974ed1ad87fe063e9de9f44e4bc5ee1d). The concurrent Claude public-label changes do not alter cache identity, deadlines, admission or cleanup. Transaction budget, inherited caller context, private ACL/root pinning, locking, rename, checked close and cleanup contracts remain intact. Current exact-head CI must pass before merge.

@777genius

Copy link
Copy Markdown
Owner Author

Independent read-only review accepted merge composition: head eab71f7, current main 75b7acd, conflict-free merge tree 3fa9bc826cc9e1c4e13f7876e7cc88b5749f830b.

Differences from the accepted and CI-qualified head are limited to 14 separately merged landing/workflow/PNG paths from #333 and #334. Go production code, tests, dependencies, scripts and Go qualification workflows are byte-identical. No integration blocker; no repeat of unaffected Go checks is needed. All pending exact-head checks must still pass before merge.

Final Windows Go 1.25 and 1.26 full jobs passed on attempt 1 in run 37197800947.
https://github.com/777genius/agent-notifications/actions/runs/37197800947

@codecov

codecov Bot commented Oct 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.04878% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.96%. Comparing base (8d5f814) to head (eab71f7).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
internal/notification/observation/cache_unix.go 76.31% 5 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #332      +/-   ##
==========================================
+ Coverage   65.94%   65.96%   +0.01%     
==========================================
  Files         264      264              
  Lines       29929    29956      +27     
==========================================
+ Hits        19737    19759      +22     
- Misses       7240     7241       +1     
- Partials     2952     2956       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@777genius
777genius merged commit cb2b9d3 into main Oct 4, 2026
25 checks passed
@777genius
777genius deleted the fix/observation-cache-preflight branch October 4, 2026 12:19
@777genius

Copy link
Copy Markdown
Owner Author

Released in v1.47.1, an opt-in Linux/Windows prerelease. Draft and public package checks passed on Linux amd64/arm64 and Windows amd64. macOS is skipped; latest stable and automatic updates remain on v1.46.1.

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