Skip to content

fix: converge explicit restart publication admission - #1079

Merged
bcdonadio merged 6 commits into
mainfrom
fix/950-restart-publication
Sep 6, 2026
Merged

bcdonadio merged 6 commits into
mainfrom
fix/950-restart-publication

Conversation

@bcdonadio

@bcdonadio bcdonadio commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Explicit daemon restarts can collide with a passive publication sweep before restart, immediately after the manager starts the replacement, or after replacement admission. Retry only those publication assertions after independently authenticating the daemon responsible for the lock.

Motivation / Why

A replacement can begin its first passive sweep before publishing its PID file. The nested assertion must use the supervisor's authenticated manager PID during this interval, while the outer assertions independently authenticate owned daemon state. The lock-owner record remains a comparison check and cannot establish daemon identity.

The current and replacement daemon have separate bounded retry allowances. Manager operations run once, and the existing post-start admission behavior remains intact.

Type of change

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

Release-note title

fix: converge explicit restart publication admission

Testing done

  • Exact candidate 6fda028b5478c973f42c082d705e8a5da17d6bdd: 12 direct lifecycle test files / 954 tests passed; lifecycle coverage is 100% statements, branches, functions, and lines.
  • 83 hermetic restart-publication tests cover the three boundaries, manager/PID-file startup ordering, identity drift, bounded PID/token reads and current-UID ownership, exact exception behavior, aborts, active-time budgets, and single manager mutation.
  • Both TypeScript projects, changed-file ESLint, Codecov ownership tests, frozen installation, and diff validation pass.
  • Regression tests failed before each relevant repair and pass in this candidate. All fixtures use private state and injected process, supervisor, network, and clock boundaries.
  • Independent GLM-5.3 Max and Grok 4.6 medium reviews, followed by Opus 5 medium synthesis and owner adjudication, found no unresolved P0/P1/P2 at this exact head. Fresh exact-head CI passed 10,012 tests and reports 100% lines, branches, functions, and statements across the complete production scope; both PostgreSQL conformance legs and Linux/macOS integration jobs passed.

Related issues

Closes #950. Part of #968. Preserves #865 post-start admission behavior.

The general legacy PID/token readers remain tracked separately in #1073; this change uses bounded reads only for the new restart-publication capture path.

Checklist

  • DB access only via getLcmConnection()/closeLcmConnection() — no DB access added
  • New connections set PRAGMA journal_mode=WAL and PRAGMA foreign_keys=ON — no connections added
  • No implicit any — all types explicit
  • collectStats() not called in request handlers or hot paths
  • New routes have tests in test/daemon/routes/ — no routes added
  • Multi-step writes use transactions — no writes added
  • Schema migrations are additive only — no schema changes
  • 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 — no dependency changes

Limits

The current and replacement identity allowances add up to four seconds of assertion wait; the existing independent child-final allowance can add another two seconds. Unavailable or staged health and unprovable identity remain failures.

Review guidance

Start with restart assertion identity capture and the initial-only nested wrapper. Then inspect the hermetic restart-publication tests for the absent PID window, token-disclosure boundary, deadline and cancellation behavior, and manager call counts.

Authenticate publication contention independently before and after daemon
replacement, and retry only the blocked assertions within bounded active-time
budgets.

Keep manager mutation and ensure work single-shot, preserve the existing child
convergence window, and fail closed on PID, token, birth, health, or runtime
identity drift. Add hermetic boundary coverage and operator guidance.

Signed-off-by: Bernardo Donadio <[email protected]>
Bring the Bug 950 candidate onto origin/main at b0df28e before review.
Preserve the merged bounded lifecycle birth probes and combine their Codecov
ownership notes with restart publication convergence.

Signed-off-by: Bernardo Donadio <[email protected]>
Integrate origin/main at 2dace53 after the earlier publication candidate
merge. Retain the upstream systemd parent-fixture stabilization before final
review.

Signed-off-by: Bernardo Donadio <[email protected]>
Read restart publication PID and token evidence through the existing bounded,
nonblocking regular-file helper while preserving scoped ownership and PID
tri-state behavior.

Keep ordinary post-contention assertion errors intact after deadline expiry,
and document the terminal typed-error and complete six-second contention
window.

Signed-off-by: Bernardo Donadio <[email protected]>
Integrate origin/main at d3c3b12 because the coordinator-checkpoint update
overlaps backend-publication documentation and Codecov ownership metadata.
Preserve both upstream ownership notes and Bug 950 restart behavior.

Signed-off-by: Bernardo Donadio <[email protected]>
Copilot AI lite review requested due to automatic review settings September 6, 2026 18:40
@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-06T19:20:32.888987Z 6fda028 New commits
ℹ️ 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.

🔵 Needs a closer look

It changes critical daemon lifecycle/publication-convergence control flow and identity capture semantics, which warrants final human review despite strong hermetic coverage.

Pull request overview

This PR fixes a reliability race where an explicit restartDaemon can collide with backend-publication passive sweeps at its assertion boundaries. It introduces bounded, identity-authenticated publication admission retries for restart-specific assertions (without replaying manager mutations), and documents the resulting timing/identity guarantees.

Changes:

  • Add restart-scoped publication convergence wrappers that only retry PrivateMutationLockContentionError after capturing authenticated daemon identity (PID/token/birth/health/runtime fields).
  • Extend lifecycle options to support a distinct wrapper for the initial publication assertion and a shared replacement retry budget across nested/outer restart assertions.
  • Add comprehensive hermetic tests for restart-publication convergence boundaries and update documentation/Codecov component notes plus a changeset.
File summaries
File Description
src/daemon/lifecycle.ts Adds restart-scoped publication evidence capture and retry wrappers; wires them into restartDaemon and ensureDaemon initial assertion flow.
test/daemon/lifecycle-restart-publication.test.ts New hermetic test suite covering PID/token/birth drift, manager PID absence window, abort/deadline behavior, and “no replay” restart semantics.
docs/backend-publication.md Documents the three restart assertion boundaries, bounded retry budgets, and fail-closed identity requirements.
codecov.yml Updates component narrative to include #950 in the lifecycle/service-manager ownership description.
test/codecov-config.test.ts Keeps Codecov ownership expectations aligned with the updated component narrative.
.changeset/steady-restart-publication.md Adds a patch changeset describing the user-visible reliability behavior change.
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0
  • Review effort level: Lite

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

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 50d3962dff

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/daemon/lifecycle.ts Outdated
@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!

Derive the publication-capture UID from the injected lifecycle authority or the
local process UID, and apply it to every bounded PID and token evidence read.

Cover production fallback, explicit zero, missing-getuid compatibility, and
injected descriptor-owner mismatches without changing manager UID behavior.

Signed-off-by: Bernardo Donadio <[email protected]>
Copilot AI review requested due to automatic review settings September 6, 2026 19:17

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.

🔵 Needs a closer look

It makes substantial changes to the daemon lifecycle restart/admission control flow and retry semantics in a critical reliability/security boundary that warrants final human review despite strong tests.

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@bcdonadio
bcdonadio merged commit aa6cefb into main Sep 6, 2026
22 checks passed
@bcdonadio
bcdonadio deleted the fix/950-restart-publication branch September 6, 2026 19:26
@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.

Explicit restart publication assertions race passive sweeps

2 participants