Skip to content

feat(temporal): refuse later revisions with earlier system time - #122

Merged
seonghobae merged 5 commits into
mainfrom
agent/revision-system-time-order
Aug 24, 2026
Merged

feat(temporal): refuse later revisions with earlier system time#122
seonghobae merged 5 commits into
mainfrom
agent/revision-system-time-order

Conversation

@seonghobae

Copy link
Copy Markdown
Contributor

Summary

  • ADR 0002/0013 still required later document revisions to be later in system time.
  • Adds standalone revision_order: a higher revision number cannot carry earlier or equal system time.
  • Recovered order flags match known truth at a higher computed rate than accepting every pair.
  • Does not persist revisions or allocate migration 0008.

Claim boundary

  • In-memory order gate only. #45 still owns 0007.
  • Does not replace persistence_postgres interval CHECKs or recreate encrypted_mapping.

Test plan

  • RED: order_contract failed with E0432
  • cargo test -p revision_order --offline --lib --tests
  • cargo clippy -p revision_order --all-targets --offline -- -D warnings
  • cargo llvm-cov -p revision_order lines 23/23; nightly-2026-08-01 branches 12/12
  • docstring, workspace, and documentation gates
  • Exact-head CI and independent review

A higher document revision number cannot carry earlier or equal system
time (ADR 0002/0013).
@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 52 minutes.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 86b4d023-51af-49bc-a38e-a2905cf5e8b9

📥 Commits

Reviewing files that changed from the base of the PR and between 245e8b2 and 56c57d7.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (16)
  • ARCHITECTURE.md
  • CHANGELOG.md
  • Cargo.toml
  • README.md
  • crates/revision_order/Cargo.toml
  • crates/revision_order/src/error.rs
  • crates/revision_order/src/lib.rs
  • crates/revision_order/src/revision.rs
  • crates/revision_order/tests/crate_contract.rs
  • crates/revision_order/tests/order_contract.rs
  • docs/TRACEABILITY.md
  • docs/adr/README.md
  • docs/research/revision-system-time-order.md
  • docs/research/standards-and-literature.md
  • docs/validation/temporal-event-foundation.md
  • scripts/check_workspace_contract.py

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

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

# Conflicts:
#	CHANGELOG.md
#	docs/adr/README.md
#	docs/research/standards-and-literature.md
#	docs/validation/temporal-event-foundation.md
@seonghobae
seonghobae marked this pull request as ready for review August 20, 2026 18:44
@seonghobae

Copy link
Copy Markdown
Contributor Author

Current head b032c85 is synchronized with origin/main. Conflict resolution preserved the revision-order implementation, current main documentation, and ADR 0013. A documentation validation failure caused by a leading space that hid ADR 0013 from the index parser was fixed at the source.

Validation on this exact head: cargo fmt --all -- --check; cargo test -p revision_order --offline (6 tests, all passed); full Python quality suite (89 tests, all passed); python scripts/check_workspace_contract.py; python scripts/validate_documentation.py; python scripts/check_docstrings.py; git diff --check.

No merge is requested until a qualifying independent approval and current required checks are present.

@devin-ai-integration devin-ai-integration 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@seonghobae

Copy link
Copy Markdown
Contributor Author

Current-head review refresh for b032c85:

  • Revision ordering rejects later content with an earlier system time, preserving reproducible bitemporal history.
  • git diff --check, documentation validation, workspace contract, docstring contract, and cargo fmt --all -- --check passed locally.
  • Current hosted checks are pass=15, pending=1, fail=0; merge remains withheld until the pending exact-head required check completes and qualifying approvals exist.
  • No new actionable source defect was found at this exact head; no approval is being self-issued.

@seonghobae

Copy link
Copy Markdown
Contributor Author

Rebased current head 38542fd onto origin/main. The changelog and any ADR conflict were resolved by retaining both feature and current-main decisions; inherited documentation trailing whitespace was removed. Local merge-tree, git diff --cached --check, and cargo fmt --all -- --check pass. Exact-head hosted checks and required independent approvals remain required before protected merge.

@seonghobae
seonghobae enabled auto-merge (squash) August 24, 2026 00:57
@seonghobae

Copy link
Copy Markdown
Contributor Author

Current-head review completed for exact head 38542fd41196394587e024c7e824c840dcafb32c against base c45be17a9dbce95ef81cee230e9d128abc7160ac.

  • Revision order requires a strictly increasing revision number and strictly increasing system time; backward and equal-time revisions fail closed.
  • The realistic recovery contract compares recovered ordering with known truth and an accept-all collapse, while invalid and empty payloads are rejected.
  • Local pinned verification passed: cargo fmt --all -- --check; cargo test -p revision_order --all-features; package clippy with -D warnings; workspace contract; documentation validation; Rust docstring contract; git diff --check.
  • All exact-head hosted checks are green, including Live PostgreSQL, Strix, coverage, SAST, dependency, Noema, and OpenCode.
  • No actionable current-head finding remains. No qualifying independent human approval is present; protected merge remains withheld. Decision: WAIT_AND_REMEDIATE.

@github-actions
github-actions Bot disabled auto-merge August 24, 2026 08:19
…-time-order

# Conflicts:
#	ARCHITECTURE.md
#	CHANGELOG.md
#	Cargo.toml
#	README.md
#	docs/TRACEABILITY.md
#	docs/adr/README.md
#	docs/validation/temporal-event-foundation.md
#	scripts/check_workspace_contract.py
#	tests/quality/test_check_docstrings.py
@seonghobae
seonghobae merged commit 35de7d3 into main Aug 24, 2026
19 of 22 checks passed

@devin-ai-integration devin-ai-integration 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.

Devin Review found 4 new potential issues.

Open in Devin Review

Comment on lines +68 to +76
pub fn refuse_nonincreasing_system_time(
earlier: DocumentRevision,
later: DocumentRevision,
) -> Result<(), RevisionOrderError> {
if revisions_are_increasing(earlier, later)? {
return Ok(());
}
Err(RevisionOrderError::SystemTimeDidNotIncrease)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: refuse_nonincreasing_system_time returns InvalidRevisionPayload for equal/backward revision numbers

refuse_nonincreasing_system_time propagates InvalidRevisionPayload (via revisions_are_increasing) when the later revision number is not strictly greater, rather than SystemTimeDidNotIncrease. This is documented ("Returns revision-construction errors, or SystemTimeDidNotIncrease...") and tested, so it is intentional, but callers should be aware that a same-numbered revision pair is rejected as an invalid payload, not as a time-order violation.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +68 to +76
pub fn refuse_nonincreasing_system_time(
earlier: DocumentRevision,
later: DocumentRevision,
) -> Result<(), RevisionOrderError> {
if revisions_are_increasing(earlier, later)? {
return Ok(());
}
Err(RevisionOrderError::SystemTimeDidNotIncrease)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Error-propagation branch in refuse_nonincreasing_system_time may be untested

In refuse_nonincreasing_system_time (revision.rs), the ? operator on revisions_are_increasing(...) has an implicit error-propagation branch that fires only when the two revision numbers are equal or reversed. Every test call (both the unit test at revision.rs and the integration tests at order_contract.rs) passes strictly increasing revision numbers, so that inner Err path is never exercised through this function. Given the repo's 100% branch-coverage gate (AGENTS.md #8), this is worth confirming against the nightly branch-coverage run; the author claims 12/12 branches, but LLVM branch coverage of the ? desugaring is worth double-checking. Not reported as a bug because it is a coverage/CI concern that will be caught by the pinned coverage gate, not a runtime defect.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +51 to +59
pub fn revisions_are_increasing(
earlier: DocumentRevision,
later: DocumentRevision,
) -> Result<bool, RevisionOrderError> {
if later.revision_number <= earlier.revision_number {
return Err(RevisionOrderError::InvalidRevisionPayload);
}
Ok(later.system_time_seconds > earlier.system_time_seconds)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: System-time gate is consistent with bitemporal revision semantics

The gate refuses a later revision unless its system_time_seconds strictly increases (revision.rs, 55-58). This is transaction/system-time ordering only and does not constrain event/valid time, so it remains consistent with AGENTS.md #5 (revision edges may point to the past in event time). The strict > comparison also correctly rejects equal system times, matching the PR's stated 'earlier or equal' refusal. No bug; noting because the distinction between system time and event time is the crux of correctness here.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +45 to +59
/// Return whether `later` has a greater revision number and later system time.
///
/// # Errors
///
/// Returns [`RevisionOrderError::InvalidRevisionPayload`] when `later` is not
/// a strictly greater revision number than `earlier`.
pub fn revisions_are_increasing(
earlier: DocumentRevision,
later: DocumentRevision,
) -> Result<bool, RevisionOrderError> {
if later.revision_number <= earlier.revision_number {
return Err(RevisionOrderError::InvalidRevisionPayload);
}
Ok(later.system_time_seconds > earlier.system_time_seconds)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: Doc comment on revisions_are_increasing understates behavior

The doc for revisions_are_increasing at revision.rs says it returns whether later has "a greater revision number and later system time," but the function only returns the system-time comparison (revision.rs); the revision-number condition is enforced by returning an error, not folded into the boolean. This is a documentation/behavior wording mismatch, not a correctness bug, since callers get an Err when revision numbers are non-increasing rather than a false.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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