Repository navigation
feat(audit): export both chains and verify them offline - #786
Conversation
Signed-off-by: hushen <[email protected]>
|
The Rust, PostgreSQL and container checks passed. Could you rerun that job? GitHub requires repository admin access to rerun it from my account. |
vladimirrott
left a comment
There was a problem hiding this comment.
Reviewed at 08f15fbd34dcf0cdd6d107445732fe86b95e7be1. Approving.
Your round-trip test deletes the database and the private key before verifying, and points SYSKNIFE_DATABASE_PATH at a directory that does not exist and then asserts it was never created. That proves --from opens nothing, which is the property an auditor needs. You also took the simpler option for partial exports (refuse with exit 2) and documented it in both places.
Your tests and four mutants, in a container at this head, running cargo test -p sysknife-cli --offline --locked --test audit_export and --test cli_smoke audit_export:
== pristine
running 5 tests ... test result: ok. 5 passed; 0 failed
running 3 tests ... test result: ok. 3 passed; 0 failed
== M1 export drops events (events, -> events: Vec::new(),)
test exported_chains_verify_without_a_database_or_private_key ... FAILED
test offline_verification_rejects_changed_and_missing_events ... FAILED
== M2 partial flag ignored by --from (if document.partial { -> if false {)
test offline_verification_refuses_partial_exports ... FAILED
== M3 export never marks partial
test offline_verification_refuses_partial_exports ... FAILED
test audit_export_emits_the_stored_rows_as_parseable_json ... FAILED
== M4 version check off
test offline_verification_refuses_unknown_versions_and_missing_fields ... FAILED
== pristine again
restored
test result: ok. 5 passed; 0 failed
test result: ok. 3 passed; 0 failed
M1 is the check the issue asked for: with the event half gone, the intact export stops verifying. I did not run the Postgres contract test locally; the postgres-contract job passed on this head.
The red docs-and-hygiene check is not yours. It failed on the Glama badge link in README.md, a file this branch does not touch:
[✖] https://glama.ai/mcp/servers/lacs-project/sysknife → Status: 0
##[error]dead link(s) in README.md after 3 attempts
Two notes, neither blocking. README.md:424 still describes export as "stored signed chain rows as JSON"; I can fix that wording when I write the CHANGELOG entry and the minor bump you asked for. And #784, #785 and #786 all move tests/evidence/workspace-tests.json from 2108, so two of them will conflict on that line after the first merges. Merging main and re-running UPDATE_TEST_BASELINE=1 scripts/test_baseline.sh fixes it.
Signed-off-by: hushen <[email protected]>
vladimirrott
left a comment
There was a problem hiding this comment.
Approving again at 1a6cae0.
Thanks for the merge. Beyond git's own merge of 08f15fb and main, your merge commit changes one file, the evidence file:
$ for n in 784:6d6c13af 785:06c3c184 786:08f15fbd; do echo "== ${n%%:*}"; t=$(git merge-tree --write-tree origin/main ${n#*:} 2>/dev/null | head -1); git diff --stat $t p${n%%:*}; done
== 786
tests/evidence/workspace-tests.json | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
It reads 2119: 2114 on main plus the five #[test] attributes this branch adds.
The partial-export guard from my earlier review still bites at this head:
$ timeout 2400 maintainer-merge verify 786 1a6cae0222344436d2a47ace71c32342b4070dc6 offline_verification_refuses_partial_exports 's/ if document.partial {/ if false {/' > verify-786.log 2>&1; echo "verify_rc=$?" >> verify-786.log
running 'offline_verification_refuses_partial_exports' unmutated
rust suite: evidence of 1 executed unit(s), passing unmutated
applying the mutation and re-running
receipt recorded for #786 at 1a6cae02 (observed: clean pass, mutated fail)
verify_rc=0
The red security-audit comes from main: cargo audit fails on RUSTSEC-2026-0538 against quinn-udp 0.5.14 in Cargo.lock, and main's own run at b83fda8 fails the same way. cargo update -p quinn-udp --precise 0.5.16 clears it, and that lockfile change is mine to land. You don't need to do anything for it. After it lands, this branch needs an update and a fresh run before it can merge.
As on #784 and #785: all three branches count from 2114, so the two that land after the first will conflict on that line again. I'm sorry for the extra round. Merging main and running UPDATE_TEST_BASELINE=1 scripts/test_baseline.sh resolves it, and I approve again when that file is the only change.
Summary
audit exportnow includes both transaction and event rows in a versioned JSON document.audit verify --from audit.json --pubkey audit-key.pubverifies that file offline, without opening a database or loading the private key.Exports made with
--sinceor--limitare markedpartialand refused by offline verification with exit code 2. A complete export uses the existing signature and binding checks; changed or missing bound events return exit code 1.Related Issue
Fixes #620.
Validation
migrates_legacy_schema_and_enforces_store_contractpassed, including verification of both exported chains with the public key.Notes for Reviewers
This changes the published export format from an array to
{ "version": 1, "chain": [...], "events": [...], "partial": false }. Consumers of the old array should read.chain. Please include this breaking output change in the release changelog and minor version bump.Row encodings are unchanged. Offline verification checks signatures and bindings; detecting removal of an otherwise valid tail still requires an independent checkpoint. The format and workflow are documented in
docs/cli.mdanddocs/the-audit-chain.md.