Repository navigation
P3: Hikvision family and the recovery engine (Phases 4 and 5) - #1
Merged
Merged
Conversation
Adds `spectra/recover/`, the vendor-free recovery engine (doc 3 §7, FR-29, FR-42).
No module here imports a vendor plugin; everything drives off the `VendorPlugin`
surface, so a new family stays one module plus one registry line (AC-12).
coverage.py defines the bucket precedence contract CLAUDE.md §14 assigns to P3 and
leaves unwritten. Ordered by which label misleads most if it were wrong:
unreadable > structural > parsed > carved > unaccounted
- `unreadable` outranks all: a parser will emit a recording whose extents span a
hole the source zero-filled, and no reading of those bytes is truer than "not read".
- `structural` outranks `parsed`: metadata must never be counted as video.
- `parsed` outranks `carved`: matches merge keeping the highest tier (FR-44).
- `unaccounted` is derived, never claimed — `claim()` raises on it.
The tiling invariant (buckets sum to image size exactly, TC-PS-07) is enforced in
`__post_init__`, so a map that does not tile cannot be constructed. Adjacent
same-bucket runs merge, so a fragmented carve costs rows proportional to
transitions rather than extents (NFR-04).
carver.py implements the T3 scan: windowed with overlap so a signature straddling a
chunk boundary is still found, validate-before-accept via each plugin's own
`Signature.validate`, strictly increasing offsets which also dedupes the rescanned
prefix, an optional `regions` restriction that takes `readable_ranges()` for T4, and
a wall-clock budget that raises rather than truncating — a short carve that looks
complete is the disqualifying failure mode (§9.3).
Tests: 28 new, including TC-RC-04 (boundary straddle, asserted both with and without
overlap so the bug cannot be reintroduced), TC-RC-05 (noise and bare planted patterns
yield nothing), TC-PS-07 (the sum invariant under 300 randomised overlapping claim
sets), and TC-RB-07 fuzzing.
240 passed, 6 skipped. No files outside spectra/recover/ and tests/ were touched.
Second format family, and the first proof that the plugin contract holds: one new module plus one registry line, no core file touched (AC-12). The generic conformance suite auto-parametrises over REGISTRY, so the plugin was under test the moment it was registered, and passes unchanged. Structure follows Han, Jeong & Lee, "Analysis of the HIKVISION DVR File System", ICDF2C 2015, LNICST 157 — peer-reviewed and openly available, which §5 rule 14 accepts as a source. doc 4 §12 rows 1-2 stay [R] until a Tier R image exists, so every claim is reported with its source and the plugin refuses rather than guesses. - Master sector at 0x200, signature at 0x210, version at +0x30. - Both HIKBTREE copies are read. Whichever validates is used, which one it was is recorded, and divergence between them is a reported finding, not silently resolved (doc 4 §4.2). - 48-byte entries at page+0x60. Channel is a BIG-ENDIAN u16 in an otherwise little-endian filesystem; read the other way channel 2 becomes 512, so there is a test that pins it. - status all-FF is a freed entry whose block survives: yielded as T2 at lower confidence only when include_orphans is set (FR-41). - start/end of 0x7FFFFFFF is the in-progress sentinel, reported as "still recording", never as a 2038 timestamp. - Unknown layout version, or neither tree validating, degrades to carve-only and says so (FR-03). - frames() reports channel=None and t_device=None: the PS layer carries neither dependably at this layout version, and inventing them is the failure FR-45 and §5 rule 2 forbid. Recording time comes from the index entry. The carve validator checks MPEG-2 pack marker bits AND requires the next start code to land where the declared stuffing length says. Markers alone leave ~1 in 256 of a random accept; chaining takes it to ~1 in 2^32, which is what lets the pattern pass the conformance suite's planted-pattern-in-noise assertion. Page-chain walking is bounded and cycle-safe (TC-RB-06); every offset read from disk is bounds-checked against the source size. tests/hikgen.py is a spec-conformance fixture carrying the same scope warning as dhavgen.py: it proves the parser implements the paper, not that the paper matches a real recorder. KNOWN CONFLICT, kept visible in CI rather than papered over: Tier S S-04/S-05 place the master magic at offset 0 and the tree offsets as <QQ at 32; the published layout puts them at 0x210 and 0x298/0x2A8. The two share only the magic strings, so one does not describe a real disk. Corpus independence (§15.1) forbids editing P6's generator to match this parser, so test_tier_s_corpus_layout_diverges_from_the_published_one asserts the S-04 layout is correctly NOT recognised, and documents what resolving it needs. Flagged for P6 and the hardware track. 276 passed, 6 skipped.
orphans.py implements the tier that matters most and is easiest to get dangerously wrong. A recorder frees an index entry long before it overwrites the block, so in that window the video is intact and invisible to the vendor's software — but a freed entry may equally point at a block that HAS been rewritten, and reporting that as recovered footage carrying the old entry's channel and timestamps is exactly the confident-wrong answer §9.3 forbids. So every orphan is checked against what the block actually contains before it is kept. The distinction the checks turn on is failed versus not-runnable. Hikvision's program-stream payload carries no dependable per-frame channel or timestamp, so those two checks are INAPPLICABLE there, not failed. Downgrading every Hikvision orphan because its container omits a field would discard good evidence and misreport why. Only a genuine contradiction downgrades; a verdict is trusted when something was actually checked and nothing contradicted it. A downgraded orphan is not discarded — it becomes a T3 carve candidate that keeps its extents and loses its metadata. The bytes may still be recoverable; nothing the freed entry claimed about them survived checking, so its channel and timestamps are not asserted (FR-45). merge.py groups by extent overlap, keeps the highest tier (T1 > T2 > T3 > T4, matching the coverage precedence parsed > carved for the same reason), and records on the survivor that duplicates existed and at which tiers — corroboration is worth keeping, and silently dropping it inflates nothing but also tells nobody. Grouping is transitive, so one long T1 absorbs several short carves that each touch it. Deterministic: input order does not affect the result (NFR-08). Both modules are vendor-free. orphans.py types its dependency as a structural Protocol over the slice of VendorPlugin it uses, so there is no route to importing a vendor module even by accident. 292 passed, 6 skipped.
The module docstring asserted both of these, and §17's "Diagram ideas NOT adopted" list rules out both by name: - "Hikvision has no delete operation, so T2 yield is low" — HDD initialise and expiry settings do remove footage, and a lagging backup HIKBTREE may hold orphan entries the primary has released. Unverified either way. - "recovery comes from comparing frame times against the volume initialisation time" — a dead-RTC reset or a manual clock change produces the same pattern, so that is at most an anomaly to corroborate against the device log, never on its own evidence that footage was destroyed. Neither claim affected behaviour; both were prose presented as fact, which is the §5 rule 14 failure this project exists to avoid. Replaced with what the code actually does: enumerate() reports what the index says, recover/orphans.py decides what to trust, and how much T2 yields on this family is an open hardware question (doc 4 §12 rows 1-2). Also labelled the 0x7FFFFFFF in-progress reading as [R] rather than stating it flatly, and kept it matched on the raw value rather than a rendered string (§17 item 7). History is left intact rather than amended: the wrong claim and its retraction are both on the record, which is the right default for this repo. 292 passed, 6 skipped.
carver.scan() finds structures; this turns them into Recordings. The gap between those two is where carving usually goes wrong — a pile of frame offsets is not footage, and emitting one clip per hit produces thousands of unplayable fragments that inflate every total in the report. Three rules: - A run ends at a discontinuity: channel change, time running backwards, sequence going backwards, or a byte gap. Walking through one is how a carver produces a single "recording" that is really two, with a start time from one and an end time from the other. The reason each run ended is recorded. - A run starts at an I-frame. Everything before the first keyframe references data that is gone, cannot decode, and is trimmed — with the trimmed byte count noted, because silently dropping bytes is its own kind of unexplained gap. - Confidence follows the doc 3 §7.2 ladder: 0.9 / 0.7 / 0.4 "time unknown" / 0.2. One thing the ladder does not cover, found by a failing test rather than by reading: a run WITH channel and time but only one keyframe falls into the same 0.7 band as "time but no channel". Those are different situations that would look identical to a report reader. Rather than invent a band the docs do not define, every recording now carries a confidence_note saying which case it is and why. Worth raising with P5, who consumes these in the report. Runs with no recoverable time are placed in physical order and given no timestamp at all — never one inferred from a neighbour (FR-45). Vendor-free: reads only Frame fields the contract guarantees and asks the plugin for frames; it has no idea which family it is working on. Verified end to end against a real DHAV stream, where carving recovers channel and time per frame, and against a second image where two recordings on different channels stay separate. 310 passed, 6 skipped.
…(FR-29, FR-41..FR-46)
Wires the tier engines into the case: runs T2/T3/T4, merges with what parse already
found, persists new recordings, and writes the coverage map. First code in the repo
to insert into the `coverage` table, which has existed unused since Phase 0.
Two behaviours worth calling out:
Recovery does NOT require a successful parse. A carve-only image — unknown layout
version, damaged superblock, a family we identify but cannot walk — is exactly what
T3 exists for. parse refuses those (FR-03) and recovery must not inherit the refusal.
Index-backed tiers are skipped with a recorded reason rather than failing the run.
Existing T1 recordings take part in the merge. A carve re-finds footage the index
already described; without the T1 rows in the comparison every recovered file would
be reported twice and every total inflated (FR-44). Re-running recovery adds nothing
and rewrites rather than doubles the coverage map.
AC-06 yield is reported honestly: minutes are counted only where both ends of a
recording have a recovered time, items without time are counted and named in the
summary, and the ratio is None rather than 0% when there is no T1 baseline to divide
by.
Bug found by the tests: `spectra/recover/__init__.py` re-exports a function named
`merge`, which shadows the submodule of the same name, so `from spectra.recover
import merge as merge_mod` binds the function. Import from the submodule explicitly,
with a comment so the next person does not undo it.
Verified end to end on a synthetic Hikvision volume with two orphaned entries:
parse 1 recording, 30 min (T1)
recover --tiers T2,T3 2 recordings, 75 min recovered — 250% over T1
coverage structural 1.8% · parsed 42.9% · unaccounted 55.4%
case verify VERIFIED, 10 audit records
325 passed, 6 skipped.
Completes the tier ladder. T4 cuts every candidate span at each bad-sector run, so each survivable piece becomes its own clip and none is reported as spanning bytes that were never read. One long clip with an invisible hole in the middle is the failure this prevents, and it is why T4 is a tier rather than a flag on T3. `_subtract()` does the span arithmetic and records what bounded each piece. Two things it reports, and the second was found by a failing test: - Holes that SPLIT a span. Rare in practice: by the time reassembly runs, the carve has usually been restricted to readable ranges and the hits either side of a hole have already grouped separately. - Holes that BOUND a piece — the common case, and initially missed. Exact adjacency is too strict: a span typically stops a little short of a hole because the last frame that would have crossed into it failed to validate and was dropped. The hole still bounded the clip. The window is one sector, because a sector is the granularity at which a disk becomes unreadable. Saying "this clip ends here because the next sectors could not be read" is the difference between a short clip and an unexplained one. Tests use a RawImageSource subclass whose `_raw_read` raises EIO for chosen sectors, so core/source.py's retry, zero-fill and gap recording all run exactly as they would on failing hardware — the gaps are real, not simulated at the API boundary. Also: tiers_run is now sorted, so the summary reads "T3, T4" rather than "T4, T3". 336 passed, 6 skipped. Verified through the CLI end to end.
…dings Phase 7, the declared shippable line (doc 8 §2). Adds the report package that turns everything already parsed and recovered into what the problem statement actually asks for. spectra/report/negative.py (FR-81) Section 7 generated rather than written: 13 finding codes derived from the coverage map, provenance class, identification state and time model. Non- deletable by construction — there is no suppression path, every call re-derives from the case, so a finding disappears only when the underlying fact changes. spectra/report/findings.py (FR-86, AC-11, NFR-08) The deterministic data spine every rendering reads from. Three properties make AC-11 hold: generated_utc is a parameter taken from the operation's own audit record (never a clock read), every query is explicitly ordered, and it reuses canonical_json from core/audit.py rather than adding a second canonicaliser. Splits conclusions_digest from the whole-file digest. findings.json carries the audit head, and generating a report is itself an audited event, so two runs give two file digests on a correctly behaving tool — which is exactly the check a court would run to test the determinism claim. conclusions_digest covers only what was found on the disk, so two labs examining one image compare one number. spectra/report/certificate.py (FR-83, doc 1 §5.1) The Schedule's own form: Part A (party, with the s.63(2) recital and the owned/maintained/managed/operated block) and Part B (expert, with designation), the exact SHA1/SHA256/MD5 checkbox list, DVR as a named source type, and the mandatory enclosed hash report. statute_for() selects the IEA s.65B(4) form for proceedings instituted before 1 July 2024. Signatures are left blank. Pre-filling a sworn statement by two named people would forge the thing the section exists to obtain. spectra/services/report.py The certificate re-hashes each artefact from the artefact store rather than reprinting stored digests: it is tendered with the files, so its digests should be measured from the files in the bundle, and Hasher computes all three in one pass over bytes that must be read anyway. The evidence image is the exception and keeps its stored MD5/SHA-256 with SHA-1 blank. An artefact that no longer matches its recorded digest is withheld from the tender and the withholding is disclosed on the form, with empty hash columns and a note naming both digests. Refusing outright would block a whole tender over one bad file; tendering it would put a contradicted digest on a form that looks complete. A silent omission is what an adversarial reader looks for first. core/hashing.py Hasher gains SHA-1: the Schedule names it and a certificate cannot tick a box for a digest never computed (CLAUDE.md §17 item 1). cli.py spectra report findings|certificate, so the whole surface stays headless for doc 6 validation. 389 tests passing. Verified end to end: identify -> parse -> recover -> report on a synthetic Hikvision volume, including the withheld-artefact path.
…mat time Closes the two P0 requirements that had a table but no writer, and one real bug. FR-73 chain of custody (SOP Form F-2) services/custody.py records physical transfers. The custody table gains the two columns that make a row mean anything — seal number and whether the seal was intact on receipt — and seal_intact is three-valued on purpose: NULL means never sealed, 0 means found broken. Merging those would report a case-ending fact at the same weight as a routine one. chain_breaks() checks that each transfer's releasing holder is the previous transfer's receiving holder. A mismatch means the item moved without a row, which is exactly what F-2 exists to make visible, and a report that prints the rows without running the check has only printed rows. FR-74 case documents (BNSS s. 103/105/94) New attachment table. Documents are hashed on the way in and stored in the same content-addressed store as everything else, so `spectra verify` checks them with the existing walk — but deliberately not in `artifact`. That table is what SPECTRA produced; an officer's panchnama listed there would be presented as tool output, and a s. 63(4) tender including it would claim to vouch for a document the tool never made. Each kind carries its statutory hook so a reader sees why a document is in the case without knowing the SOP. Negative findings gain NF-NO-CUSTODY, NF-SEAL-BROKEN, NF-NO-SEAL, NF-CUSTODY-GAP and NF-MISSING-DOCUMENTS. The document expectation follows what actually happened: a seized recorder (class A/B) should have a s. 103 memo, a s. 105 recording and an authorisation; a live acquisition (C) is not asked for the recording, because whether s. 105 attaches turns on whether it was a search and that is not the tool's to guess; a third-party export (D) is asked only for the authorisation. Demanding documents a case could not have is how a section becomes one examiners skim. Bug: services/parse.py discarded disk_layout.format_time entirely The Hikvision plugin populates it from the master sector and the insert wrote a literal None. The volume initialise time bounds how far back footage can possibly go, so losing it loses a report §5 fact. It is now kept in the same three layers as `recording`: device raw, encoding, and local. `format_utc` stays NULL until an offset is established — the column name promises UTC and the recorder's clock cannot deliver it (FR-53). Schema 1 -> 2 for the three additions. No case directories predate this. CLI: spectra case custody|attach|chain. 412 tests passing.
Completes Phase 7 (doc 8 §2), the declared shippable line. spectra/report/generator.py (FR-80, FR-87, AC-09) Renders findings.json into the twelve sections doc 3 §10 fixes. The template adds layout, headings and the fixed statutory language and adds no facts: every number in the report came out of the findings document that ships beside it, so a reader can check the rendering against the data without trusting the renderer. Two banners are unconditional when they apply and appear before section 1 — absolute time not established, and audit chain verification failed. Both are the kind of thing a reader must not have to reach section 8 or 11 to discover. StrictUndefined rather than the default: a missing key raises instead of rendering an empty cell. A silently blank field in a forensic report is a wrong report, not a tidy one. Branding (FR-87) is presentation only and is escaped. An agency may put its letterhead on the report; it may not put its house style on what the tool could not read. A test asserts the template has no selectattr, no truncate and no <details>, because a severity filter or a collapse-by-default would defeat FR-81 in presentation while leaving the data intact. Section 11 states why it cannot list the report or findings.json among the artefacts: both are created after the data is assembled, and a document cannot carry its own digest. Without that line a reader comparing the table against the case directory finds extra files and no explanation. PDF/A WeasyPrint is an optional extra (`pip install 'spectra[pdf]'`) because it needs cairo and pango at the system level, which CI and the minimum-spec VM should not carry to run the rest of the suite. When absent the HTML is still written and the caller is told exactly why the PDF is missing — a forensic tool may not quietly hand over a lesser artefact than the one requested (rule 7). Jinja2 added as a runtime dependency (pure Python, BSD-3-Clause, no native deps, safe for the offline bundle — NFR-07, NFR-15, NFR-16). CLI: spectra report generate. 432 tests passing. Verified end to end against a synthetic Hikvision volume with custody entries and an attached panchnama.
…s (FR-55) spectra/timeline/anomalies.py Five detectors: overlapping windows on one channel at different disk regions, footage written later on the disk but timestamped earlier, footage predating the volume format time, footage dated after acquisition, and zero-length recordings. Every one reports a contradiction in the recorded data and none reports a cause. That is the entire design: each pattern has several available explanations and the disk cannot choose between them, so each anomaly carries `possible_causes` and the wording says what was observed rather than what it means. A test asserts no detector offers fewer than two explanations — a symptom handed over with one implied cause is a conclusion in disguise. before_volume_format is the one CLAUDE.md §17 names directly. "Timestamp earlier than volume init means footage was destroyed" is explicitly rejected there, because a dead RTC battery resetting on power-up writes genuinely new footage bearing an old date and produces exactly the same pattern with nothing deleted. The detector reports it as an observation to corroborate against the device log, and a test greps the wording for "destroyed", "wiped", "erased", "proves" and "confirms" so the claim cannot creep back in through phrasing. Runs on device-local time deliberately. A recorder disagreeing with itself is not something a clock offset can explain away, so these are found on the axis the contradictions actually live on. Anomalies surface as NF-TIME-* negative findings at `attention` severity — never `serious`, since a contradiction to explain is not a conclusion — and render in report section 9 with their explanations beside them. A reader taking the timeline at face value without seeing these has been misled by omission. This is what the disk_layout.format_time fix in d10234a unblocked: the detector needs the volume format time the parse service had been discarding. 448 tests passing.
…ncing bitstream run_motion_analysis() took each frame's compressed H.264/H.265 payload, treated it as an 8-bit greyscale buffer, and tiled it when it was shorter than the assumed 320x240 geometry. It then ran frame differencing over that. The result was a measure of entropy-coded byte churn, not of motion. Its tests passed because they fed synthetic flat-byte payloads and asserted only that some segments came out. Why this was worse than an obvious bug: an encoder spends more bits on a moving scene, so coded-byte churn correlates with real activity well enough to produce segment lists that look right in a demo. It was a proxy for the wrong quantity wearing the output format of the right one — the confident wrong answer doc 6 §1 names as the only disqualifying failure mode. core/media.py gains MediaTool.decode_gray(), which builds the MPEG-TS the remux path already knows how to make, decodes it through FFmpeg to raw greyscale frames sampled at 2 fps and 320x240, and verifies the output is a whole number of frames. iter_gray_frames() streams them so a long recording does not blow the 4 GB ceiling (NFR-04). Sampling is deliberate: Stage 1 exists to remove 90-99% of the compute before the expensive stages, and neither full rate nor full resolution is needed to find where activity is. Without FFmpeg the service now raises and writes no annotation. A motion result nobody can trace to decoded pixels is worse than no motion result, because the absence is visible and the wrong answer is not. The CLI was never passing a MediaTool at all; it does now. The result carries decode_note and sampled_fps, printed by the CLI and available to the report, so a reader is told the analysis sampled and that activity shorter than one sample interval can fall between samples. A sampled analysis that does not say so overstates its coverage. Tests rewritten to run on real encoded video. The one that matters is the static scene: coded bytes vary frame to frame whatever the camera sees, so the old code reported motion on a motionless grey field and the new code reports none. Verified end to end — moving 5/6 sampled frames and 1 segment, static 0 and 0. 457 tests passing.
Status line, the implemented CLI surface, and §17 item 1 (SHA-1) marked decided. Five new §17 entries for things raised while building: schema version 2 and what moved, the motion-analysis decode requirement, the two digests in findings.json, WeasyPrint as an optional extra, and FR-34 having no producer to write against. Each names the doc section that now needs updating, per the authority rule: docs outrank this file, so a divergence recorded here is a doc edit still owed.
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.
Builds out P3 (Hikvision family, recovery engine) and, since P5 is unassigned, the
report package that turns everything upstream into what the problem statement asks for.
Phase 4 — Hikvision family
plugins/hikvision.py. Master sector at0x200, both HIKBTREE copies read withdivergence reported, per-page entry walk, MPEG-PS pack validation that checks the
marker bits and requires a following start code (a false positive needs ~1 in 2^32).
Proves AC-12: the second format family needed two lines in
registry.pyand nocore file changed.
Phase 5 — recovery engine, vendor-free
recover/implements T1–T4 against the plugin contract only.orphans.py(T2) validates before trusting.CheckResultispass/fail/inapplicable, because a check that could not run is not a check that passed — anorphan is trusted only if at least one check ran and none failed.
carver.py(T3) scans in 64 MiB chunks with 64 KiB overlap; strictly increasingoffsets dedupe the rescanned prefix. Over budget it raises rather than truncating,
so a partial carve is never mistaken for a complete one.
gop.pyreassembles, cutting spans at unreadable holes and recordingcut_by.merge.pykeeps the highest tier on overlap and records that duplicates existed.coverage.pyis the §14 contract.CoverageMap.__post_init__callsverify(), soa map that does not tile the image cannot be constructed;
unaccountedis derivedand cannot be asserted.
Phase 7 — the report package (the shippable line)
report/negative.py— FR-81, 18 finding codes, non-deletable by construction:no suppression path exists and every call re-derives from the case.
report/findings.py— FR-86. Carries two digests. The whole-file digest covers thisexamination's own history and legitimately moves between runs, because generating a
report is an audited event.
conclusions_digestcovers only what was found on thedisk, so two labs compare one number. Without that split the obvious test of AC-11
— run it twice, compare — fails on a tool behaving correctly.
report/certificate.py— FR-83. The Schedule's actual form: Part A with the s. 63(2)recital, Part B with the expert's designation, the exact SHA1/SHA256/MD5 checkbox
list, DVR as a named source type.
statute_for()selects the IEA s. 65B(4) form forproceedings instituted before 1 July 2024. Signatures are left blank — pre-filling
a sworn statement by two named people would forge the thing the section exists to get.
report/generator.py— FR-80/FR-87, twelve sections.StrictUndefined, so a missingkey raises rather than rendering an empty cell. A test asserts the template contains no
selectattr,truncateor<details>: a severity filter would defeat FR-81 inpresentation while leaving the data intact.
The certificate re-hashes each artefact it tenders rather than reprinting stored
digests. An artefact that no longer matches is withheld and the withholding is disclosed
on the form with empty hash columns and both digests in a note — refusing outright would
block a whole tender over one bad file, and tendering it would put a contradicted digest
on a form that looks complete.
FR-73 / FR-74 — chain of custody and case documents
Both were P0 with a table and no writer.
custodygains seal number and a three-valuedseal_intact(NULL = never sealed, 0 = found broken).chain_breaks()checks eachtransfer's releasing holder against the previous receiving holder.
Attachments are hashed into the same content-addressed store but deliberately not into
artifact— that table is what SPECTRA produced, and an officer's panchnama listed therewould be presented as tool output.
FR-55 — time anomalies
Five detectors, each reporting a contradiction and none reporting a cause; every anomaly
carries
possible_causes, and a test asserts no detector offers fewer than two.before_volume_formatis the one CLAUDE.md §17 names directly — it is not evidencefootage was destroyed, since a dead RTC produces the same pattern with nothing deleted —
and a test greps the wording for "destroyed", "wiped" and "proves" so the claim cannot
creep back in through phrasing.
Two bugs fixed
services/parse.pydiscardeddisk_layout.format_time. The Hikvision pluginpopulates it and the insert wrote a literal
None. The volume initialise time bounds howfar back footage can go. Now kept in the same three layers as
recording;format_utcstays NULL until an offset exists, because the column name promises UTC and the recorder's
clock cannot deliver it.
services/analytics.pynever decoded video. It took the compressed H.264/H.265payload as a greyscale buffer, tiling it when short. Its tests passed because they fed
synthetic flat-byte payloads. This was dangerous rather than merely broken: encoders spend
more bits on moving scenes, so byte churn correlates with activity well enough to look
right in a demo. It now decodes through FFmpeg at 2 fps / 320x240 and refuses without
it. The test that catches it is a static grey scene — the old code reported motion on it,
the new code reports none. Verified: moving 5/6 sampled frames and 1 segment, static 0 / 0.
Notes for review
disk_layoutcolumns, threecustodycolumns, newattachmenttable). No case directories predate this.
[pdf]extra because itneeds cairo/pango; without it the HTML is written and the skip is stated, never silent.
adc4e54retracts two claims I had asserted in ahikvision.pydocstring thatCLAUDE.md §17 explicitly rejects. History left intact.
457 tests passing, 6 skipped (pyewf absent; DHAV ground-truth vectors stay
[R]untilhardware). Verified end to end: identify → parse → recover → custody → report →
certificate →
spectra verify chain→ VERIFIED.