Skip to content

fix: reject unexpected trailing arguments in transact/retract (#303) - #350

Merged
adityamukho merged 2 commits into
mainfrom
worktree-fix-303-transact-trailing-args
Aug 24, 2026
Merged

adityamukho merged 2 commits into
mainfrom
worktree-fix-303-transact-trailing-args

Conversation

@adityamukho

Copy link
Copy Markdown
Collaborator

Summary

  • (transact [facts] {opts}) — the options map placed after the facts vector instead of before it, exactly the syntax quoted in :valid-at appears to filter by transaction time instead of a fact's actual valid-from date #303's own repro — was silently accepted as if no options were given. The map was dropped and every fact's valid-time defaulted to the transaction's wall-clock timestamp instead of the intended :valid-from.
  • This made :valid-at appear to filter by transaction time instead of a fact's actual valid-from: facts only became query-visible once :valid-at reached real ingestion time, matching every data point in the issue's reproduction table.
  • Root-cause investigation ruled out the read path — :valid-at filtering in the executor, net_asserted_facts retraction/window semantics, and the on-disk B+tree index after checkpoint + reopen were all verified correct with direct reproductions. The defect is in parse_transact/parse_retract: both only ever read the elements they expected and never checked for leftover trailing elements, so a misplaced or extra argument was silently discarded rather than rejected.
  • Fix: both commands now hard-error on unexpected trailing arguments instead of silently ignoring them. parse_retract had the identical latent gap (no observable impact today since retract doesn't parse an options map, but the same silent-discard defect), fixed alongside per user request.

Closes #303

Test plan

  • New parser unit tests (RED verified first): options map after facts vector → error; trailing garbage after a valid (transact {opts} [facts]) → error; trailing garbage after (retract [facts]) → error
  • cargo test — 693+ tests, 0 failures
  • cargo fmt --check clean
  • cargo clippy --all-features -- -D warnings clean (matches CI's rust-clippy.yml scope)
  • Manual repro: correctly-ordered (transact {:valid-from ...} [facts]) verified correct for single-fact, multi-pattern-join, and checkpoint+reopen (on-disk index) scenarios; incorrectly-ordered form now errors clearly instead of silently corrupting valid-time

🤖 Generated with Claude Code

https://claude.ai/code/session_01Nsh3ZnmoK6PTaUbp4HcqHY

adityamukho and others added 2 commits August 24, 2026 19:39
`(transact [facts] {opts})` — the options map placed *after* the facts
vector instead of before it — was silently accepted as if no options
were given: the map was dropped and every fact's valid-time defaulted
to the transaction's wall-clock timestamp instead of the intended
:valid-from. This made :valid-at appear to filter by transaction time
rather than a fact's actual valid-from, since facts only became
visible once the query timestamp caught up to real ingestion time.

The read path (:valid-at filtering, net_asserted_facts, and the
on-disk index after checkpoint/reopen) was already correct — this was
a write-side parser gap: parse_transact/parse_retract only read the
elements they expected and never checked for leftover ones. Both now
hard-error on trailing arguments instead of silently discarding them.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nsh3ZnmoK6PTaUbp4HcqHY
@codecov

codecov Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@adityamukho
adityamukho merged commit a2ee4ae into main Aug 24, 2026
17 checks passed
@adityamukho
adityamukho deleted the worktree-fix-303-transact-trailing-args branch August 24, 2026 14:23
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.

:valid-at appears to filter by transaction time instead of a fact's actual valid-from date

1 participant