Skip to content

fix(identity): return exact identities in publication and copy receipts - #962

Merged
steipete merged 3 commits into
mainfrom
fix/exact-identity-receipts
Oct 11, 2026
Merged

steipete merged 3 commits into
mainfrom
fix/exact-identity-receipts

Conversation

@steipete

@steipete steipete commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem

After #949, Windows file IDs outside Number's safe-integer range correctly fail identity checks, but fs-safe still returned some of those IDs as Numbers. A caller could publish a file successfully and then fail to reopen or republish that same file using fs-safe's own receipt.

Change

Add immutable exact identity companions to publication success/failure receipts, directory and temp-workspace receipts, public open/read/stat results, and clone metadata. Preserve existing field types and derive both views from the same admitted observation. Publication, comparison, and synchronous-copy inputs accept explicit exact-companion receipts. Existing staged, copy-publication, retained, and atomic/move receipts already carry exact identities.

Keep unsafe Numbers fail-closed. Preserve numeric Stats metadata, including Node's Date rounding and unsigned legacy scalar representation, and preserve Root stat/list/entry JSON through a non-enumerable companion. Document the round-trip rule and refresh declaration compatibility proof.

Validation

The new hardlink and forced-copy regression both fail on the base with path-mismatch for a simulated inode of 2^54 + 1, and pass with exact receipts. Property tests cover the full 64-bit range, signed Node representations, fractional timestamps, descriptor observations, and adjacent-ID rejection.

AWS Linux: full pnpm check passed (14,086 tests passed, 4,266 platform skips), including installed-package/declaration proof. AWS Windows: 170 focused tests passed, 82 platform skips. The final hash-verified NTFS run published 512 files (256 hardlinks and 256 cross-volume copies) and round-tripped every receipt with zero false matches or false rejections; 35 legacy IDs were outside Number precision. The disposable NTFS volume was detached and removed, and both AWS leases were released. Independent Codex review is clean at P0–P2; final exact-head CI is required before merge.

No release or version bump.

@steipete
steipete requested a review from a team as a code owner October 11, 2026 19:42
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
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. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 11, 2026
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR adds exact bigint identity companions to filesystem receipts and accepts them in subsequent guarded operations.

Example: Publish a file with inode 18014398509481985, then republish it using its receipt.

  • Before: The numeric inode rounds to 18014398509481984 and fails expected-source admission.
  • After: The exactIdentity companion preserves 18014398509481985n for reuse.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The repair has clear value and focused regression coverage, but an existing finding remains and final-effect authority evidence is missing.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A successful filesystem operation can return a numeric receipt that cannot identify the same file in a subsequent guarded operation.
Reason: The supplied maintainer-authored direction restores receipt reuse while retaining numeric metadata and unsafe-number rejection.

Merge readiness

⛔ Blocked before merge - 5 items remain

Keep this PR open: it repairs a current receipt round-trip failure, but the previously reported listing timestamp regression remains.

Priority: P2
Reviewed head: a6cdc6467889c518b005eb0dd45f56ab09869306

Before merge

  • Add real behavior proof - Authority-chain proof required: the complete body claims Windows NTFS publication round trips but provides no captured output or linked artifact; attach redacted terminal output or logs showing valid exact-companion reuse and rejection of adjacent or replaced source/directory identities before publication, copy destination creation, or synchronization, excluding IPs, keys, and non-public endpoints. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Preserve numeric timestamp precision when listing bigint stats (P2) - The prior finding remains: requesting bigint Stats here activates Number(mtimeNs) / 1000000 in pathStatFromStats, rounding before scaling. For mtimeNs=1700000000000000125n, Node's numeric observation yields 1700000000000.0002ms, while this projection yields 1700000000000ms. Typed POSIX listings therefore change existing metadata for unchanged files; sorted and filesystem-order entries use the same conversion. Share the seconds/remainder arithmetic already used by numberStats and cover the timestamp through public listing APIs.
  • Resolve security review attention item - Exact companions cross the caller-to-filesystem authority boundary; no concrete new bypass or supply-chain defect was found.
  • Resolve merge risk - Exact companions become accepted authority for publication, copy creation, and directory synchronization; stale-receipt rejection at these final effects remains unverified.
  • Explain or restore the original intent of Root listing metadata - perf(root): construct directory metadata without spread copies #818: Preserve field values and numeric/bigint timestamp conversion while removing intermediate allocations; the newly activated timestamp rounding is unexplained.

Findings

  • [P2] Preserve numeric timestamp precision when listing bigint stats — src/root-directory-list.ts:288

Provenance

Tests

  • Missing end-to-end proof: Capture public-API companion reuse and stale-source/directory rejection before publication, copy creation, or synchronization; the claimed base-fail/head-pass regression output is also absent.
Agent review details

How this fits together

The shared identity layer connects caller receipts and descriptor observations to guarded publication, copying, reads, and directory synchronization.

flowchart TD
  A[Caller paths and receipts] --> B[Identity snapshot]
  B --> C[Descriptor and pathname admission]
  C --> D[Guarded filesystem operation]
  D --> E[Final identity verification]
  E --> F[Numeric metadata and exact companion]
Loading

Technical review

Best possible solution:

Keep exact companions and existing identity fences while preserving Node's numeric timestamp arithmetic in directory metadata projections.

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

Main and v0.26.1 return numeric publication identities that unsafe-number admission rejects; the added regression models inode 18014398509481985, but no target code was executed during this read-only review.

Is this the best way to solve the issue?

Exact companions repair lost identity precision without weakening admission, provided directory projections preserve the existing numeric metadata contract.

Full review comments:

  • [P2] Preserve numeric timestamp precision when listing bigint stats — src/root-directory-list.ts:288
    The prior finding remains: requesting bigint Stats here activates Number(mtimeNs) / 1000000 in pathStatFromStats, rounding before scaling. For mtimeNs=1700000000000000125n, Node's numeric observation yields 1700000000000.0002ms, while this projection yields 1700000000000ms. Typed POSIX listings therefore change existing metadata for unchanged files; sorted and filesystem-order entries use the same conversion. Share the seconds/remainder arithmetic already used by numberStats and cover the timestamp through public listing APIs.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 3fd5d89b3126.

Merge-risk options

Maintainer options:

  1. Hold for final-effect evidence (recommended)
    Keep this PR open until captured public-API results establish valid companion reuse and rejection of stale source and directory receipts before filesystem effects.

Provenance checked

Testing

Proof path: in-process harness.

Security

Needs attention: Exact companions cross the caller-to-filesystem authority boundary; no concrete new bypass or supply-chain defect was found.

Evidence

What I checked:

  • Current and released receipt failure: Fetched main and v0.26.1 return numeric publication Stats while expected-source admission rejects unsafe Numbers, leaving large inode receipts unable to round-trip. (src/publish-file.ts:342, 5510bc8d566b)
  • Pinned introduced repair: The introduced diff snapshots explicit companions and derives publication metadata and exact identity from one final bigint descriptor observation. (src/publish-file.ts:347, a6cdc6467889)
  • Prior timestamp finding remains: Typed listings now request bigint Stats, activating the existing Number(mtimeNs)/1000000 projection; the seconds-and-remainder conversion used by numberStats is not used here. (src/root-directory-list.ts:288, a6cdc6467889)
  • Numeric timestamp oracle: The patch imports Node filesystem Stats and promises to preserve their metadata, making Node's implementation authoritative for this comparison: numeric timestamps use seconds times 1000 plus nanoseconds divided by 1000000. (lib/internal/fs/utils.js, caa20e28dc1f)
  • Authority paths inspected: Publication checks source expectations before publication, synchronous copy uses strict expected-source inspection before destination creation, and directory synchronization checks retained descriptor and pathname identity before flushing. (src/copy-root-file-sync.ts:123, a6cdc6467889)
  • Proof supplied: The complete body reports NTFS round trips but supplies no captured output or linked artifact; discussion adds no contributor evidence, and checked-in proof scripts contain instructions rather than execution results. Captured body sourceRevision: 9296753a40b138d6652e41831210a3808c182d609f74c5a7bfbea2cd6432a6c3. (scripts/exact-receipts-proof.mjs:19, a6cdc6467889)

Likely related people:

  • Peter Steinberger: Raw commit e26eff5 adds src/file-identity.ts:13 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e26eff537588; files: src/file-identity.ts)
  • Vincent Koc: Raw commit dc0ea4e adds src/file-identity.ts:11 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: dc0ea4e269b3; files: src/file-identity.ts)

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Large filesystem IDs expose a concrete, platform-dependent receipt usability defect.
  • merge-risk: 🚨 compatibility: The changed listing observations alter existing numeric mtimeMs values for valid fractional timestamps.
  • merge-risk: 🚨 security-boundary: Accepted exact companions participate in authorization of filesystem effects and require final-boundary stale-receipt validation.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add final-effect proof for valid companion reuse and show that source or directory replacement invalidates retained companions before publication, copy destination creation, or synchronization.

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 execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-11T19:50:35.718Z sha c6a87a2 :: needs real behavior proof before merge. :: [P2] Preserve numeric timestamp precision when listing bigint stats
  • reviewed 2026-10-11T20:18:46.802Z sha d964fe5 :: needs real behavior proof before merge. :: [P2] Preserve numeric timestamp precision when listing bigint stats

Reviewed October 11, 2026, 4:35 PM ET / 20:35 UTC (Revision 3).

@steipete
steipete force-pushed the fix/exact-identity-receipts branch from d964fe5 to a6cdc64 Compare October 11, 2026 20:30
@steipete
steipete merged commit 656d006 into main Oct 11, 2026
56 checks passed
@steipete
steipete deleted the fix/exact-identity-receipts branch October 11, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant