Skip to content

fix(identity): stabilize Linux epoch start times - #9

Merged
steipete merged 1 commit into
mainfrom
koffi/p7-linux-start-epoch
Oct 10, 2026
Merged

steipete merged 1 commit into
mainfrom
koffi/p7-linux-start-epoch

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Linux epoch birth estimates can fall more than a second before a freshly spawned process. /proc/stat truncates the boot epoch to whole seconds, while /proc/<pid>/stat independently truncates birth to clock ticks. Their errors add: a real time-namespace reproduction exceeded the existing one-second bound in 470/500 x64 samples and 469/500 ARM64 samples, with errors reaching 1.0094 seconds. Ordinary GNU and musl measurements showed stable realtime/boottime offsets and CLK_TCK=100; neither libc-specific conversion nor accumulating clock drift was required.

Compute the epoch estimate from bracketed CLOCK_REALTIME/CLOCK_BOOTTIME samples at each read. Reject samples wider than one tick and disjoint boot-epoch intervals. Keep the boot-relative birth exactly as before for PID-reuse and ancestry comparisons. Document that epoch time is an estimate in the current wall-clock frame, bounded by two ticks plus one microsecond, and can change after a wall-clock correction. No public API is added.

The runtime proof now checks 32 freshly spawned children on the main thread and 32 in a real Worker against a derived 21 ms Date.now bracket at 100 Hz. GNU and musl, x64 and ARM64, Node and Bun are covered. The arithmetic regression also rejects a wall-clock step hidden by an otherwise narrow intersection. Existing lifecycle and Worker comparisons retain exact boot-relative identity checks.

Validation: local native pnpm check and Bun tests; real AWS Linux GNU/musl measurements and Node/Bun runtime proof; required CI on the PR head. Independent review identified the wide-sample intersection issue, which is fixed and covered before landing.

@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 10, 2026
@clawsweeper

clawsweeper Bot commented Oct 10, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge.

What this changes

This PR estimates Linux process epoch birth times from bracketed realtime and boottime samples while preserving boot-relative identity.

Example: Read a freshly spawned Linux process identity with CLK_TCK=100.

  • Before: The reported epoch birth can precede the spawn by 1.0094 seconds, as reported in the PR reproduction.
  • After: The documented uncertainty is less than 20,001 microseconds in the current wall-clock frame; boot-relative birth remains unchanged.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused and useful repair with no actionable defect found; validation establishes real native harness coverage, while standalone behavior artifacts are absent.
Proof confidence 🦐 gold shrimp (3/6) The ordinary external-contributor proof gate does not apply to this verified maintainer PR; its native harness exercises 32 fresh children on the main thread and 32 in a Worker, with exact boot-relative checks and bounded epoch assertions.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A newly spawned Linux process can appear to have started more than a second before it was launched.
Reason: The maintainer-authored repair corrects a documented accuracy limitation without adding an API, option, or competing identity source.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it fixes a concrete Linux timestamp error still present on main, and its author is a verified repository administrator. No actionable patch defect was found.

Priority: P2
Reviewed head: 78729bed41021acaa4d316f5740ed40cd7660e89

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No separate consumer transcript or base-versus-head failure output is attached; inspected CI supports the real native main-thread and Worker harness.
Agent review details

How this fits together

The identity subpath passes a PID to the native Linux observer, which reads procfs and clocks and returns a typed identity, proven absence, or a typed error.

flowchart TD
A[Caller PID] --> B[TypeScript identity API]
B --> C[Native Linux observer]
D[Procfs process stat] --> C
E[Realtime and boottime clocks] --> C
C --> F[Identity or typed error]
F --> G[Boot-relative ancestry comparison]
Loading

Technical review

Best possible solution:

Land the bounded clock-sampling repair with exact boot-relative comparisons and the documented current-wall-clock semantics.

Do we have a high-confidence way to reproduce the issue?

Main's calculation visibly combines whole-second boot-epoch truncation with process-tick truncation; the PR reports matching time-namespace measurements, but no reproduction was run during this read-only review.

Is this the best way to solve the issue?

The repair addresses the truncation at its native owner, retains exact boot-relative identity, and rejects uncertain observations instead of adding retries or fallbacks.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 17b242b4033f.

Provenance checked

  • Linux epoch calculation and clock-change brackets changes intended behavior with a stated reason (5852b3e: The scaffold established epoch birth reporting, stable boot-relative birth, and rejection of clock changes during observation.)
  • Lifecycle and Worker identity assertions changes intended behavior with a stated reason (5852b3e: The original proofs compared retained identity across lifecycle and Worker observations; the patch preserves exact stable fields while allowing bounded Linux epoch sampling variation.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Current main retains the inaccurate calculation: Main adds integer-second procfs btime to tick-quantized process birth, combining both truncation errors. (native/src/identity/linux.rs:120, 17b242b4033f)
  • Pinned implementation: The patch bounds each clock sample to one tick, rejects disjoint offset intervals, and preserves the existing boot-relative conversion. (native/src/identity/linux.rs:87, 78729bed4102)
  • Identity boundary remains stable: Ancestry already prefers boot-relative birth when both observations provide it, so the changed epoch estimate does not replace its PID-reuse comparison. (src/identity.ts:48, 78729bed4102)
  • Feature provenance: The merged scaffold PR established fresh identity observations, boot-relative comparisons, and clock-change rejection: feat: add process identity and Darwin coalition capabilities #1. (native/src/identity/linux.rs:54, 5852b3e263bf)
  • Maintainer identity verified: Although the PR REST response reports CONTRIBUTOR association, the repository permission endpoint confirms steipete has admin permission, consistent with the supplied maintainer context.
  • Real native harness validation: The exact-head Linux x64 GNU Node 22 job completed successfully, including native Node and Bun main-thread/Worker suites; these execute the new child timestamp assertions through the native identity API. (test/runtime.test.ts:5, 78729bed4102)

Likely related people:

  • Peter Steinberger: Raw commit 5852b3e adds native/src/identity/linux.rs:6 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5852b3e263bf; files: native/src/identity/linux.rs)

Labels

Label changes:

  • add P2: The PR repairs inaccurate Linux epoch timestamps without changing the boot-relative identity used for ancestry.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: The PR repairs inaccurate Linux epoch timestamps without changing the boot-relative identity used for ancestry.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

Reviewed October 10, 2026, 7:20 AM ET / 11:20 UTC.

@steipete
steipete merged commit 294ebd8 into main Oct 10, 2026
24 checks passed
@steipete
steipete deleted the koffi/p7-linux-start-epoch branch October 10, 2026 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant