fix(antigravity-cli): only infer generation timestamps against a decoded session anchor - #1202
Merged
Merged
Conversation
…ded session anchor `read_trajectory_meta` collapsed the decoded `trajectory_metadata_blob` created-at and the file mtime into one `i64`, and that number was used both as the per-row timestamp fallback and as the trust anchor bounding the inferred agy 1.1.18 `chatModel.#9.#10` reading. A file mtime is always positive, so the `session_timestamp <= 0` guard that was supposed to decline inference without an anchor almost never fired: databases with a missing or undecodable metadata blob ran inference against a window built on the last write to the file. An opaque payload decoding near the mtime was accepted, and a genuine older turn was rejected for sitting below it. Report the created-at as `Option<i64>` alongside the effective fallback and thread it through `parse_gen_metadata` into `generation_timestamp_ms` and `inferred_epoch_ms`. With no decoded created-at the `#9.#10` inference is skipped entirely and the row keeps the fallback dating it had before the 1.1.18 layout was handled. The confirmed `#9.#4` Timestamp path returns before any of this and is unchanged. The existing missing-anchor test only passed 0 and -1, neither of which a real database produces. Adds an end-to-end SQLite test covering both shapes that yield no created-at (table absent, and a blob carrying no `#2`) with a payload the old mtime-anchored window would have accepted. Constraint: `#9.#10`'s 8-byte layout is inferred from a field dump, not read off a real database, so an accepted reading must be corroborated Rejected: Keep one i64 and sentinel the mtime case | any in-band sentinel is a valid epoch-ms value Confidence: high Scope-risk: narrow Directive: `session_window_ms` must only ever be handed a decoded created-at; do not reintroduce the mtime as an anchor Not-tested: a real agy 1.1.18 database (none available; `#9.#10` remains inferred)
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
read_trajectory_metacollapsed two different things into onei64. It decoded the session created-at fromtrajectory_metadata_blob.#2, and when that blob was missing or would not decode it substituted the database file's mtime — then returned a single number that served both as the per-row timestamp fallback and as the trust anchor bounding the inferred agy 1.1.18chatModel.#9.#10reading.#9.#10's 8-byte layout is inferred from a field dump rather than read off a real database, so every candidate reading is deliberately pinned to the containing session's lifetime before it is accepted, andsession_window_msdeclines to build a window when the anchor is not positive. That guard was not doing what its doc comment claimed. A file mtime is always positive, so the<= 0check almost never fired, and inference ran against a window anchored on the last write to the file rather than on when the conversation began. It cuts both ways: an opaque payload that happens to decode near the mtime clears the window and silently re-dates a turn, while a legitimate older generation is rejected for sitting below a recent mtime. Mis-dated turns corrupt day buckets and the server-side monotonic ratchet, which has no correction path.The change
read_trajectory_metanow returns aTrajectoryMetathat keeps the decoded created-at (Option<i64>) separate from the effective row fallback (i64, still the mtime when nothing decoded). TheOptionis threaded throughparse_gen_metadataintogeneration_timestamp_msandinferred_epoch_ms, so inference runs only when a genuine decoded created-at is present and positive. With no real anchor the#9.#10path is skipped entirely and the row keeps exactly the fallback dating it had before the 1.1.18 layout was handled at all.The confirmed
#9.#4Timestamp path is untouched — it returns before any of this logic and needs no anchor, and its existing "not bounded by the session window" regression test still passes unchanged.Tests
The existing missing-anchor test only exercised anchors of
0and-1, neither of which a real database produces, which is precisely why this went unnoticed. It now holds the row fallback positive and varies the anchor overNone,Some(0), andSome(-1), so the case that actually occurs — no decoded created-at, positive mtime fallback — is covered.New:
an_mtime_only_session_anchors_no_inferencedrives the real SQLite path with a positive file mtime and no decodable created-at, in both shapes that produce one (thetrajectory_metadata_blobtable absent outright, and the table present with a blob carrying a workspace but no#2). The#9.#10payload is a value half an hour before the file was written, and the test asserts up front that an mtime-anchored window would have accepted it, so it cannot silently stop testing anything.agy_1_1_18_rows_are_dated_per_turn_not_at_session_startremains as the positive half of the contract: with a genuine decoded created-at, per-turn inference still works end to end.Falsified by temporarily restoring the collapsed single-timestamp behaviour: the new test failed with
assertion left != right failed: an mtime is not a session start and must not anchor inference(both sides1787684689447, i.e. the row was re-dated to the opaque payload), while all 34 other tests in the module still passed. Restoring the fix returned the suite to green.Verification
cargo test -p tokscale-core antigravity— exit 0, 50 passed / 0 failed.cargo test -p tokscale-core— exit 0, 1899 passed / 0 failed.cargo clippy -p tokscale-core --all-targets -- -D warnings— exit 0.cargo fmt --all -- --check— exit 0.No agy 1.1.18 database was available, so
#9.#10remains an inferred layout; this PR narrows when that inference is trusted rather than confirming the encoding.