Skip to content

fix: bound daemon birth admission probes - #1064

Merged
bcdonadio merged 1 commit into
mainfrom
fix/966-birth-probe-budget
Sep 6, 2026
Merged

bcdonadio merged 1 commit into
mainfrom
fix/966-birth-probe-budget

Conversation

@bcdonadio

Copy link
Copy Markdown
Contributor

Summary

Cap each optional startup process-birth sample at 100 ms and one quarter of the remaining lifecycle budget, rounded down. Skip unusable budgets and omit the second sample when the first returned no evidence. Preserve authenticated admission and recovery-witness requirements across direct startup, managed startup, and managed reuse.

Motivation / Why

An optional birth probe could consume the complete startup deadline before required authenticated diagnostics ran, rejecting a healthy newly started daemon. With 100 ms remaining, a probe now receives at most 25 ms. Missing birth evidence still prevents recovery authorization, while ordinary authenticated admission can finish.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Chore / infra / config
  • Documentation

Release-note title

fix: bound daemon birth admission probes

A patch Changeset documents the behavior change.

Testing done

  • Deterministic regression reproduced complete 100 ms exhaustion before the fix.
  • Lifecycle-focused suite: 504 passed, 10 platform-specific integration cases skipped; lifecycle.ts has 100% statements, branches, functions, and lines.
  • Managed suite: 82 passed; final additive sub-millisecond boundary case passed separately.
  • Typecheck, targeted ESLint, Codecov configuration (7 tests), and diff checks passed.
  • Independent GLM/Grok reviews followed by Opus synthesis cover the exact candidate.

The sample cap depends on the existing synchronous platform helper honoring its timeout. Slower optional birth reads may omit the recovery witness; authentication checks remain required.

Review guide

Start with readAdmissionBirth and the three after-sample guards in src/daemon/lifecycle.ts, then the deterministic lifecycle regressions and user-facing deadline documentation. Codecov changes document existing ownership; classification is unchanged.

Related issues

Closes #966. Part of #968.

Checklist

  • DB access only via getLcmConnection()/closeLcmConnection() — no direct DatabaseSync (unchanged)
  • New connections set PRAGMA journal_mode=WAL and PRAGMA foreign_keys=ON (no new connections)
  • No implicit any — all types explicit
  • collectStats() not called in request handlers or hot paths
  • New routes have tests in test/daemon/routes/ (no new routes)
  • Multi-step writes use transactions (no storage writes added)
  • Schema migrations are additive only (no migration)
  • Relevant local tests pass: pnpm exec vitest run <test-files>
  • Fresh exact-head CI passes pnpm run test:ci with 100% line, branch, function, and statement coverage
  • Dependency changes use exact versions and update pnpm-lock.yaml; pnpm install --frozen-lockfile succeeds (dependencies unchanged)

Cap each optional startup process-birth sample to 100 milliseconds and one
quarter of the shared remaining lifecycle budget. Skip unusable follow-up
samples so authenticated diagnostics retain admission time without weakening
recovery witnesses.

Cover direct, managed-start, and managed-reuse paths with deterministic
deadline, abort, null, throw, and stable-witness cases. Document the
availability trade-off and keep lifecycle Codecov ownership current.

Signed-off-by: Bernardo Donadio <[email protected]>
Copilot AI lite review requested due to automatic review settings September 6, 2026 16:25
@bcdonadio bcdonadio self-assigned this Sep 6, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-06T16:27:45.307293Z 4ab3793 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI 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.

🟡 Changes recommended

The updated documentation’s skip condition for birth sampling is inconsistent with the implemented “quarter budget floors to 0ms” behavior (e.g., 1–3.999ms remaining).

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR fixes a startup-admission failure mode where optional process-birth probing could consume the entire lifecycle deadline before required authenticated diagnostics run, by strictly bounding each birth sample’s time budget and avoiding unnecessary re-sampling when the first probe yields no evidence.

Changes:

  • Bound readAdmissionBirth to min(100ms, floor(remaining/4)), and skip probing on abort/expired/too-small budgets.
  • Avoid the “after” birth sample when the “before” sample returned null, preserving authenticated admission while withholding recovery-witness eligibility.
  • Add deterministic lifecycle tests, update recovery documentation, and include a patch changeset + Codecov component notes.
File summaries
File Description
src/daemon/lifecycle.ts Bounds optional birth probe timeouts and suppresses second sampling when the first sample is unavailable.
test/daemon/coverage-400-lifecycle-managed.test.ts Adds regression tests for capped/omitted birth probes across direct-start, managed-start, and managed-reuse scenarios.
docs/daemon-restart-recovery.md Documents the bounded/optional nature of birth evidence during admission and its impact on recovery witness eligibility.
codecov.yml Updates component commentary to reflect #966 lifecycle ownership notes.
test/codecov-config.test.ts Updates expected component metadata comment for lifecycle ownership notes.
.changeset/966-bounded-birth-admission.md Patch changeset describing the user-facing behavior change.
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread docs/daemon-restart-recovery.md
@codecov

codecov Bot commented Sep 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@bcdonadio
bcdonadio merged commit 2a397dd into main Sep 6, 2026
23 checks passed
@bcdonadio
bcdonadio deleted the fix/966-birth-probe-budget branch September 6, 2026 16:33
@bcdonadio bcdonadio added this to the Hardening Target 2 milestone Sep 7, 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.

Optional birth probes can exhaust startup admission

2 participants