跳到正文
DEV Community· Mir Arshad Ali Talpur·· 1 小時前AI 評分47

國防 AI 工程實戰手冊:建立能經受調查的審計追蹤

Defence AI Engineering Playbook: Build an Audit Trail That Survives an Inquiry

AI 導讀

這份國防 AI 工程手冊為分析智能體提供可建置、測試和移交的審計追蹤規格,協助團隊回應調查對輸入、規則、版本及審批記錄的查問。方案涵蓋逐項聲明追溯、SHA-256 雜湊鏈及發布前檢查,範圍限於情報摘要、物流和規劃等輔助工具,不包括武器、目標選定或作戰行動。ZizkaDB 可記錄事件並顯示記錄有否遭修改,但不負責保護網絡、系統認證或確保符合政策。

正文

For engineering teams building or integrating AI analysis agents for defence customers. Business objectives first, then the build, the tests and the runbooks.

A defence customer buys an AI analysis agent. Months later, one assessment is wrong, a commander was briefed on it, and an inquiry starts. The questions that follow are engineering questions: which inputs, which rules, which versions, who approved, and is the record original. This playbook turns those questions into specifications your team can build, test and hand over.

Scope and honesty first. This covers staff and decision-support tools such as intelligence summarisation, logistics and planning aids. It does not cover weapons, targeting or operations. The case is an illustrative composite. Everything here is general engineering information, not security, legal or accreditation advice. Deployment in a restricted environment needs your customer's accreditation and approval. ZizkaDB records events and shows whether the record was altered. It does not secure a network, apply markings, accredit a system or make it compliant with any policy. Field names and parameter names are illustrative, so check the SDK reference. Sizing figures are arithmetic examples, not benchmarks. Measure your own.

The case in six lines

A route-analysis agent reads reports from several sources. A stale report is re-circulated, the duplicate check scores it as independent, the agent states high confidence that a bridge is impassable, the planning cell approves the brief without seeing a contradiction flag, and a convoy is held a day. An inquiry asks nine questions. The contractor's rotated application logs answer two of them.

Business objectives, translated into engineering deliverables
Business objective Engineering deliverable Acceptance test
Answer an inquiry in hours, not weeks Claim-level lineage from source item to briefed statement, queryable with why() Given any claim id, return full chain in one query; timed drill under 30 minutes by someone who did not build it
Prove the record is original Per-agent SHA-256 hash chain, verified on schedule, chain head held in separate custody Verification passes daily; a deliberately edited test row is detected within one cycle
Separate product faults from process faults Versioned config events and human review events in the same chain For a seeded fault, the chain shows which component and which approver
Scope the blast radius fast Impact query from a faulty input or config version Seeded defect: list of dependent assessments matches ground truth
Pass customer security review Self hosted, no outbound dependency, least privilege keys, reference and digest storage Review checklist signed off; network egress test shows zero outbound calls
Avoid silent regressions after upgrades Replay and baseline checks gating releases CI blocks a release that changes golden-case outcomes without approval
Limit liability and rework Release gates that block on contradictions Gate test suite passes in CI and in acceptance

If a deliverable has no acceptance test, it is not done.

Reference architecture

Everything below sits inside the customer's accredited enclave.

Agent service: the analysis agent, instrumented with the SDK. It writes events and never reads other agents' records.
ZizkaDB: one instance per agent per install in the open source edition, running in a single container, backed by Postgres on storage the customer controls.
Gate service: deterministic rules that run outside the model and decide whether an assessment can be released.
Review UI: where the planning cell approves. It writes human review events with exactly what was displayed.
Head anchor job: reads the chain head on a schedule and writes it to a system under a different authority.
Audit workstation: read-only, expiring keys, used by inquiry staff and the customer's assurance team.

Design rule: the audit layer observes. If it is down, the agent must degrade in a defined way (see the failure policy below), and it must never alter the agent's outputs.

Step 1: define the event schema before writing code

Write the schema as a short spec reviewed by the programme, security and customer. Keep payloads small, store references and digests, and give every event a type and a parent.

Event Parent Required fields
source_item none item_ref, originator, info_date, marking_ref, reliability {rating, set_by}, sha256, ingest_ts
novelty_check source_item compared_to[], method, method_version, score, threshold, result
claim novelty_check or other claims text_ref, confidence, basis[], contradicted_by[], rule_set_v
release_check claim rule_id, rule_version, inputs_digest, result, blocking (bool)
config_change none component, from_version, to_version, authorised_by, ticket, effective_ts
versions_in_force source_item model_id, prompt_id, prompt_sha256, rule_set_v, rating_table_v, data_snapshot_id
human_review release_check reviewer, saw[], saw_contradiction_flag, displayed_digest, action, dwell_ms
brief_issued human_review brief_ref, text_sha256, audience
correction claim corrected_text_ref, reason, found_by

Engineering rules for the schema:

Store references and digests for anything marked. Content goes in the system of record. The audit event holds the pointer and a SHA-256 of the exact bytes the agent used. A reviewer can later recompute the digest from the source and prove it matches.
Hash the prompt. Keep prompts in version control. Log the identifier and the digest so you can prove which text ran without placing it in a wider system.
Record both clocks. Log the event time from the service and the source information date. Run NTP or the enclave's time source, and log clock source in the deployment record. An inquiry will ask about ordering.
Use stable ids. Item and claim ids must be deterministic so replays and corrections refer to the same objects.
Version the schema itself. Add a schema_v field. Never change field meaning without bumping it.
Step 2: instrument the write path

Use the SDK's log with parent_id for every event so that lineage is structural. A minimal pipeline:

python
item = await db.log(agent="route-analyst", event="source_item",
data={"item_ref": "RPT-5521", "originator": "liaison-north",
"info_date": "2026-03-04", "marking_ref": "M-17",
"reliability": {"rating": "C", "set_by": "rating-table-v6"},
"sha256": sha256_of(raw_bytes), "schema_v": 3})

nov = await db.log(agent="route-analyst", event="novelty_check",
data={"compared_to": ["RPT-5480"], "method": "text_similarity",
"method_version": "2", "score": 0.61, "threshold": 0.75,
"result": "independent"},
parent_id=item.id)

Practical points:

Batching. Group the events of one assessment where the SDK supports batching, to cut round trips. Verify ordering within the batch preserves parent links.
Idempotency. Retries after a timeout must not create duplicates. Use the idempotency key feature with a deterministic key such as assessment id plus step plus input digest. Test it by killing the network mid-batch and confirming exactly one event per step.
Redaction before storage. Apply redaction rules in the write path for any free text you cannot avoid logging. Unit test the redactor with a corpus of marked strings.
Sizing example (illustrative). Suppose an assessment touches 30 source items and yields 10 claims. With about 6 event types, that is roughly 120 to 200 events. At 1 KB average, about 200 KB per assessment. At 500 assessments a day, about 100 MB a day, or roughly 36 GB a year, before indexes. Replace these numbers with measurements from a day of real traffic.
Step 3: put the gates outside the model

Gates are code, not prompts. Examples of rules to implement and test:

A claim at high confidence needs at least two independent sources at or above a set rating.
Any claim with a non-empty contradicted_by is blocked pending human review.
A novelty score within a configured band of the threshold triggers review.
A claim based only on items older than a set age is downgraded.

Log every evaluation with rule id, rule version, an inputs digest and the result. The key engineering decision is whether a failed gate blocks release. In the case, the rule existed but only logged a warning. Make blocking explicit in the event (blocking: true or false) and cover it in tests, so an inquiry can see what the system would have done.

python
gate = await db.log(agent="route-analyst", event="release_check",
data={"rule_id": "HC_NEEDS_TWO", "rule_version": "4",
"inputs_digest": digest(inputs), "result": "fail", "blocking": True},
parent_id=claim.id)
if gate_failed_and_blocking:
hold_for_review(claim)
Step 4: record configuration and version changes as events

Wire your change process to the audit trail. Every change to the model id, prompt, rule set, rating table or similarity threshold must produce a config_change event before it takes effect, with the ticket reference and approver. In CI/CD, make the deployment pipeline write the event and refuse to deploy if the write fails. This gives you the answer to what changed since acceptance, and an auditable link from change tickets to behaviour.

Step 5: capture what the human actually saw

The review UI must log the digest of the exact content displayed, including whether the contradiction flag was visible, and dwell time. If the display omits a caveat, the record shows it. Do not log whether a person clicked approve alone, since that proves almost nothing. Log what they were shown, what they changed and what they approved.

Step 6: failure policy for the audit layer

Decide in writing what happens when audit writes fail.

Situation Policy Reason
Low-stakes event, transient failure Buffer locally, retry with idempotency key, alert after N minutes Do not lose evidence, do not stall analysts
Release decision cannot be recorded Hold the assessment, do not release An unrecorded decision cannot be defended
Buffer exceeds limit Page on-call, stop releasing new assessments Avoid operating without evidence
Chain verification fails Declare an integrity incident, preserve state, notify the assurance owner Treat as a security event

Test each row with fault injection in staging: stop the database container, fill the buffer, corrupt a test row. Confirm that behaviour matches the table.

Step 7: keys, roles and separation of duties
Agent write key: write only, scoped to its agent name. Rotate on a schedule.
Operator key: read access for support within the contractor, expiring.
Assurance key: read-only, expiring, issued by the customer, used on the audit workstation.
Admin access: held by a separate role from anyone who can deploy the agent. Log admin actions.

The point of separation is credibility. If the person who can ship code can also edit the record, the record proves less.

Step 8: tamper evidence in practice

ZizkaDB chains SHA-256 checksums per agent, and the chain route lets you verify the history. A reliable operational pattern:

A scheduled job calls verify_chain for each agent, for example every 15 minutes.
It writes the returned head, the timestamp and the verification result to a system under the customer's authority, not the contractor's. A signed ledger, a records system or a write-once store all work, depending on the customer's rules.
It alerts on any mismatch.
A monthly drill edits a copy of the database in staging and confirms detection.
python
res = await db.verify_chain(agent="route-analyst")
anchor_store.append(agent="route-analyst", head=res.head, ts=now(), ok=res.ok)

Restore testing matters as much as verification. After restoring a backup, run verify_chain and compare with the stored heads. A restore that cannot be verified is not evidence.

Step 9: tests that belong in CI

Treat the audit trail as a feature with tests.

Lineage completeness test: for each of N golden assessments, walk why() from the brief to every source item and assert there are no orphan events.
Golden cases: include the stale re-circulated report, a genuine corroboration, a contradiction and a low-reliability single source. Assert outcomes and gate results.
Replay regression: on any model, prompt or rule change, replay a frozen sample of historical inputs through the candidate version under a separate agent name and compare claims and gate results. Fail the build on unexplained differences and require a review note.
Idempotency test: simulate retries and assert no duplicates.
Redaction test: feed marked strings and assert none persist.
Chain tamper test: modify a test row and assert verification fails.
Drift baseline: compare weekly distributions, for example share of high-confidence claims, gate failure rate and novelty score distribution, with a reference period. Alert on shifts beyond agreed bounds.
Step 10: write the inquiry runbook

Prepare queries now so nobody improvises later.

Question Query pattern
What did the agent read for this claim? why() from claim id, list source_item ancestors
What was rated and by whom? source_item.reliability and config_change for the rating table at that time
Which versions were live? versions_in_force ancestor, plus config_change events before the timestamp
Who saw what? human_review ancestor with displayed_digest
How many others are affected? impact from the faulty source_item or config_change event
Is the record original? verify_chain plus comparison with anchored heads
What did the system look like then? time travel with at() for the relevant timestamp

Run a timed drill every quarter with someone outside the team.

Multi-party setups

The open source edition records one agent per install, so give each party its own instance where each owns an agent, and agree to exchange chain heads. Government, contractor and partner each hold the others' heads. A mismatch is visible to all. For fleets, multi-agent flows or agent to agent recording, the Cloud edition exists, but it is unsuitable for restricted environments, so plan separate instances and exports inside the boundary. Anything shared across domains or nations goes through your security and releasability procedures.

Definition of done
Schema spec approved and versioned.
Every release decision has a recorded gate result and, where relevant, a human review event.
Config changes cannot deploy without an audit event.
Hash chain verified on schedule with heads in separate custody, tested by drill.
Backup restore verified against anchored heads.
CI includes lineage, golden, replay, idempotency, redaction and tamper tests.
Egress test proves no outbound calls.
Inquiry drill completed in the agreed time.
Accreditation and approvals completed by the customer.
Business outcomes to report

Track these after go-live, since they justify the work: time to answer an inquiry question, number of assessments held by gates and later confirmed correct, share of claims with unresolved contradictions, mean time to scope an incident, replay differences caught before release, and the number of verification failures.

What this does not give you

ZizkaDB does not judge whether an assessment was right, does not stop a bad output by itself, and cannot show what was never logged. The tamper evidence shows the record is unchanged since the head was stored, not that it was complete. Security accreditation, handling markings, releasability and legal admissibility are separate matters for your customer and counsel.

Where ZizkaDB fits

ZizkaDB is an open source causal audit database for AI agents. It gives you linked events, why(), impact, replay, time travel, drift baselines, export and a SHA-256 hash chain, runs self hosted in a single Docker container on Postgres, and is model, LLM and cloud agnostic. Your security team can read the code. Start with one pipeline, write the schema spec this week and run the first timed drill before the customer asks for it.

Corrections: if you represent a party mentioned here and believe a statement is inaccurate, contact us and we will review it promptly.

Sources: US Department of Defense Directive 3000.09 and DoD AI Ethical Principles (traceable, auditable methodologies, data sources and design documentation); NATO Principles of Responsible Use for AI in Defence (explainability and traceability); EU AI Act Article 2(3) and Recital 24 commentary; ZizkaDB documentation.

來源:DEV Community · dev.to