Repository navigation
Record the source fingerprint in an Observation and warn when it changes - #30
Conversation
An Observation named its source only by path. If the file at that path was re-encoded or replaced, observation query kept returning the old evidence with no sign that its timestamps no longer matched the file. observe now records the source's SHA-256, size and modification time under asset in manifest.json. query compares size and modification time first and rehashes only when they differ; if the hash no longer matches it prints a warning to stderr, and the MCP query tool adds that warning to its result. A missing file, or an Observation made before this field existed, stays quiet. The idea comes from VIVID's content-hash-keyed evidence memory. The SHA-256 helper moves from update.rs to util.rs so both use one copy. The schema gains three optional asset fields; the JSON schema is regenerated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
The dependency update in #26 changed zod's export: nullable fields become a type array, and date-time patterns require seconds. The committed JSON schemas were not regenerated, so the schema drift check failed on any PR that touched the schemas. This regenerates them from the lockfile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0d12dd3bd2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let uri = asset.get("uri")?.as_str()?; | ||
| let metadata = std::fs::metadata(uri).ok()?; |
There was a problem hiding this comment.
Store an absolute source URI for later checks
When observe receives a relative video path, the probe preserves that raw argument in asset.uri, and this lookup later resolves it against the query process's current directory. Querying the Observation after changing directories—including running observation query . from inside the Observation—therefore treats an existing source as missing and silently skips the warning even if the source changed. Canonicalize the source when recording the manifest, or otherwise retain the creation-directory context.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in e937f0c. The fingerprint now records the canonical absolute path in asset.path, and the check uses it before uri. Verified end to end: observe clip.mp4 by relative path, replace the file, then run observation query . --at 1 from inside the Observation. The warning is printed.
| Ok(json!({ | ||
| "sha256": crate::util::sha256_file(path)?, | ||
| "size_bytes": metadata.len(), | ||
| "modified_unix_ms": modified_unix_ms(&metadata), |
There was a problem hiding this comment.
Omit unavailable modification timestamps instead of writing null
For a valid source whose modification time cannot be represented after the Unix epoch—for example, archived media with a pre-1970 timestamp—modified_unix_ms returns None, but json! serializes that as "modified_unix_ms": null. Both newly updated schemas permit this field to be absent but reject null, so observe emits a manifest that fails the advertised Observation contract. Insert the field only when a timestamp is available.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in e937f0c. modified_unix_ms is now inserted only when the timestamp is available, so a pre-epoch file produces a manifest without the field instead of null.
Review findings on the fingerprint: - observe kept the video argument as given in asset.uri, so after observing a relative path, a query from another directory (including `query .` inside the Observation) could not find the source and skipped the warning. The fingerprint now records the canonical absolute path in asset.path, and the check uses it before uri. The docs note that this path contains directory names. - A modification time before the Unix epoch was written as null, which the schema rejects. The field is now left out when it is unknown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An Observation named its source only by path. If the file at that path was re-encoded or replaced,
observation querykept returning the old evidence, with no sign that its timestamps no longer matched the file.What changes
observerecords the source'ssha256,size_bytesandmodified_unix_msunderassetinmanifest.json.querycompares size and modification time first and rehashes only when they differ. If the hash no longer matches, it prints:warning: clip.mp4 changed after this Observation was made (sha256 e21939863203 recorded, 942e19d40079 now). Its timestamps and evidence may not match the file; run observe again.querytool adds that warning line to its result. Other stderr stays out.update.rstoutil.rs.assetfields, and the JSON schema is regenerated. The CLI reference documents the behavior.The idea comes from VIVID's evidence memory, which keys evidence by path plus content hash.
Also: regenerated JSON schemas (commit 17f7010)
#26 bumped zod from 4.3.6 to 4.6.7, which changed its JSON Schema export: nullable fields become a type array, and date-time patterns require seconds. The committed
schema/json/*.jsonfiles were not regenerated, so the schema drift check fails on any PR that runs it, including this one. This commit regeneratessample,signal_deckandobservation_manifestfrom the lockfile.Cost
observereads the source once more to hash it. That is small next to the FFmpeg passes it already makes. A query on an unchanged file only runsstat.Testing
cargo test --release: 119 passed, 0 failed. This includes the newsource_warning_reports_a_changed_file_only, which covers no fingerprint, unchanged, touched with the same bytes, changed content, and a missing file.touch-only file give no warning; replacing the file with a re-encode prints the warning above.manifest.jsonvalidates againstobservation_manifest.This PR is independent of #6, #29 and #5. It is based on
main.🤖 Generated with Claude Code