AI models now scan repositories, detect vulnerabilities, and propose patches automatically. SWT3 proves those changes were reviewed, authorized, and compliant -- independent of the scanner.
Who this is for: DevSecOps engineers integrating AI code scanners into CI/CD pipelines, compliance officers responsible for change management evidence, and assessors evaluating whether AI-assisted code modifications meet regulatory review requirements. No prior SWT3 knowledge required.
SWT3 witness anchors prove that specific operational controls were active at a specific point in time. They do not replace the assessor's independent judgment, professional expertise, or regulatory authority. Assessors must verify that anchored evidence is sufficient, appropriate, and relevant to the specific assessment context. Each regulatory framework retains its own assessment authority, methodology, and determination standards.
A new class of AI-powered tools can now scan an entire repository, trace data flows across files, identify vulnerabilities by CWE category, and generate working patches -- all without human intervention. The developer's role shifts from writing fixes to reviewing them.
This shift introduces a compliance gap. Traditional change management assumes a human wrote the code. Existing audit trails prove who committed, who merged, and when. They do not prove:
Git commit history shows that a change happened. It does not prove that the change was governed.
This guide is vendor-neutral. The same witness workflow applies to any AI code scanning tool, including:
SWT3 witnesses the governance process around the scanner. It does not scan code itself, evaluate patches, or make security determinations. The scanner provides intelligence. SWT3 provides proof that the intelligence was governed.
When an AI model scans code and proposes a fix, the model's own output is not independent evidence that the fix is correct. This is the self-attestation problem: the entity performing the action is the same entity reporting on the action.
Regulators recognize this structural limitation:
| Framework | Requirement | Implication for AI-Generated Patches |
|---|---|---|
| EU AI Act Art. 14 | Human oversight for high-risk AI systems | AI-proposed code changes in safety-critical systems require documented human review |
| EU AI Act Art. 15 | Accuracy, robustness, and cybersecurity | Automated patches must maintain an immutable lineage and audit trail |
| NIST AI RMF GOVERN 1.1 | Legal and regulatory compliance documented | Change management evidence must survive audit |
| NIST AI RMF GOVERN 1.7 | AI system changes tracked | Tool invocations and their outcomes must be recorded |
| NIST 800-53 CM-3 | Configuration change control | Automated changes require the same controls as manual ones |
| CMMC CM.L2-3.4.3 | Track, review, approve/disapprove changes | AI-proposed patches must pass the same review gate as human patches |
| SR 11-7 | Model risk management | Code modifications by AI models in financial systems require independent validation evidence |
The common thread: automated changes need the same (or stronger) governance evidence as manual changes. A git merge alone does not satisfy any of these requirements.
The following diagram shows where SWT3 witness anchors fit into a typical AI code scanning pipeline. Each numbered step maps to a specific SWT3 procedure.
Each phase of the AI code modification lifecycle maps to an existing SWT3 procedure. No new procedures are needed.
| Workflow Phase | Procedure | What It Proves | Factors |
|---|---|---|---|
| Scanner invocation | AI-TOOL.1 | Which tool ran, how long it took, and whether it succeeded | called (1), latency_ms, outcome (1/0) |
| Scanner authorization | AI-TOOL.2 | Scanner was in the approved tool charter (no rogue tools) | granted_tool_count, charter_match, permission_change_type |
| Human review gate | AI-HITL.3 | Named individual linked to the review decision | required, actual, binding_method |
| Vulnerability record | AI-VIO.1 | Policy violations or blocked merges documented | severity, auto_detected, policy_category |
| Multi-step linkage | AI-CHAIN.1 | Scan, review, and merge are linked as a single governed lifecycle | chain_depth, cycle_bound, accepted |
| Scan log integrity | AI-AUDIT.1 | Scanner output logs have not been tampered with | entries_checked, integrity_verified, log_format_code |
| Component inventory | AI-SBOM.1 | Scanned components documented per G7/CISA SBOM-AI | total_components, clusters_documented, format_code |
The wrap_tool decorator automatically mints an AI-TOOL.1 anchor each time a wrapped function is called. Wrap your scanner invocation function, and every call produces an anchor with the tool name, latency, and success/failure status.
from swt3_ai import Witness
witness = Witness(
tenant_id="your-tenant-id",
api_key="axm_live_...",
endpoint="https://sovereign.tenova.io/api/v1/witness"
)
# Wrap your scanner function -- every call mints AI-TOOL.1
@witness.wrap_tool(tool_name="claude-security-scanner")
def run_scan(repo: str, config: str) -> dict:
"""Your scanner invocation logic."""
return scanner_cli.scan(repo=repo, config=config)
# Each call automatically witnesses:
# factor_a = 1 (tool was called)
# factor_b = latency_ms
# factor_c = 1 if succeeded, 0 if exception raised
result = run_scan("my-org/my-app", "security-scan.yml")
witness.flush()
import { Witness } from '@tenova/swt3-ai';
const witness = new Witness({
tenantId: 'your-tenant-id',
apiKey: 'axm_live_...',
endpoint: 'https://sovereign.tenova.io/api/v1/witness'
});
// Wrap your scanner function -- every call mints AI-TOOL.1
const runScan = witness.wrapTool(
async (repo: string, config: string) => {
return await scannerCli.scan({ repo, config });
},
'copilot-autofix' // tool name recorded in the anchor
);
// Each call automatically witnesses:
// factor_a = 1 (tool was called)
// factor_b = latency_ms
// factor_c = 1 if succeeded, 0 if exception raised
const result = await runScan('my-org/my-app', 'security-scan.yml');
await witness.flush();
The critical governance boundary. When a developer reviews the scanner's proposed fix and approves or rejects it, the reviewer's identity must be captured. The witness_reviewer_identity method mints an AI-HITL.3 anchor linking a named reviewer to the decision.
import hashlib
# After the developer reviews and approves the patch:
reviewer_email = "jdoe@example.com"
reviewer_hash = hashlib.sha256(reviewer_email.encode()).hexdigest()[:12]
witness.witness_reviewer_identity(
required=1, # reviewers required for this code path
actual=1, # reviewers who actually reviewed
method="session", # binding method: none, session, or cryptographic
reviewer_id_hash=reviewer_hash
)
witness.flush()
// After the developer reviews and approves the patch:
witness.witnessReviewerIdentity(1, 1, {
method: 'session', // binding method: none, session, or cryptographic
reviewerIdHash: 'a1b2c3d4e5f6' // pre-hashed reviewer identifier
});
await witness.flush();
witness_reviewer_identity(required=1, actual=0). The anchor mints with verdict FAIL (actual < required), creating an immutable record that a required review did not occur. This is more valuable than no record at all -- it proves the control was in place even when it was violated.
required=2. The anchor records whether the two-reviewer requirement was met. Assessors can query for anchors where actual < required to find governance gaps.
Organizations often have policies that restrict where AI-generated patches can be applied. Examples: "No AI patches to authentication modules," "Critical CWE findings must be manually fixed," or "AI patches to regulated modules require two reviewers." When these policies are violated, record them.
# Policy: AI patches to auth/ directory require manual fix
if scan_result.target_path.startswith("auth/") and scan_result.auto_patch:
witness.witness_violation(
severity=3, # 1=low, 2=medium, 3=high, 4=critical
description="AI patch blocked: auth module requires manual fix",
auto_detected=True, # detected by policy engine, not human
policy_category="access" # one of: unspecified, content, access,
) # data, safety, regulatory
witness.flush()
// Policy: AI patches to auth/ directory require manual fix
if (scanResult.targetPath.startsWith('auth/') && scanResult.autoPatch) {
witness.witnessViolation(3, 'AI patch blocked: auth module requires manual fix', {
autoDetected: true,
policyCategory: 'access'
});
}
await witness.flush();
AI-VIO.1 is informational (verdict always PASS) because the act of recording a violation is itself a governance success. The anchor proves the policy enforcement mechanism was active.
A code scanning workflow typically involves multiple steps: scan, triage, review, patch, merge, deploy. These steps should be linked by a shared cycle_id so assessors can trace the complete lifecycle of a single finding from detection to resolution.
import uuid
# Create a witness with a shared cycle_id for this finding lifecycle
cycle_id = str(uuid.uuid4())
witness = Witness(
tenant_id="your-tenant-id",
api_key="axm_live_...",
endpoint="https://sovereign.tenova.io/api/v1/witness",
cycle_id=cycle_id
)
# Step 1: Scan invocation (AI-TOOL.1 via decorator)
@witness.wrap_tool(tool_name="scanner-cli")
def run_scan(repo):
return scanner_cli.scan(repo)
result = run_scan("my-org/my-app")
# Step 2: Reviewer identity (AI-HITL.3)
witness.witness_reviewer_identity(required=1, actual=1, method="session")
# Step 3: Chain handoff to merge (AI-CHAIN.1)
witness.witness_chain_handoff(
depth=3, # 3 steps in this lifecycle
target_agent="ci-merge", # identifier of the merge agent/step
accepted=True # merge completed successfully
)
witness.flush()
import { Witness } from '@tenova/swt3-ai';
import { randomUUID } from 'crypto';
const cycleId = randomUUID();
const witness = new Witness({
tenantId: 'your-tenant-id',
apiKey: 'axm_live_...',
endpoint: 'https://sovereign.tenova.io/api/v1/witness',
cycleId
});
// Step 1: Scan invocation (AI-TOOL.1 via wrapper)
const runScan = witness.wrapTool(scannerCli.scan, 'scanner-cli');
const result = await runScan('my-org/my-app');
// Step 2: Reviewer identity (AI-HITL.3)
witness.witnessReviewerIdentity(1, 1, { method: 'session' });
// Step 3: Chain handoff to merge (AI-CHAIN.1)
witness.witnessChainHandoff(3, 'ci-merge', { accepted: true });
await witness.flush();
cycle_id, an assessor sees three independent anchors. With it, they see one governed lifecycle: "This CWE-79 finding was detected by scanner X, reviewed by engineer Y, and merged in commit Z -- all within one tracked sequence."
The SWT3 GitHub Action can enforce compliance gates in your CI/CD pipeline. When a scanner runs as part of a pull request, the gate can verify that all required witness anchors were minted before allowing the merge.
name: AI Code Scan + Witness Gate
on:
pull_request:
branches: [main]
jobs:
scan-and-witness:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# 1. Run your AI code scanner (any scanner)
- name: Run AI security scan
id: scan
run: |
# Replace with your scanner CLI
scanner-cli scan --repo . --format json > scan-results.json
echo "findings=$(jq '.findings | length' scan-results.json)" >> $GITHUB_OUTPUT
# 2. Witness the scan invocation + apply policy gate
- name: Witness scan and enforce policy
run: |
pip install -q swt3-ai
python3 << 'WITNESS'
import json
from swt3_ai import Witness
w = Witness(
tenant_id="${{ secrets.SWT3_TENANT_ID }}",
api_key="${{ secrets.SWT3_API_KEY }}",
endpoint="https://sovereign.tenova.io/api/v1/witness"
)
# Wrap the scan result as AI-TOOL.1
@w.wrap_tool(tool_name="scanner-cli")
def load_results():
return json.load(open("scan-results.json"))
results = load_results()
findings = results.get("findings", [])
critical = [f for f in findings if f.get("severity") == "CRITICAL"]
# If critical findings exist, record policy violation and fail
if critical:
w.witness_violation(
severity=4,
description=f"{len(critical)} critical findings require manual review",
auto_detected=True,
policy_category="safety"
)
w.flush()
raise SystemExit(f"::error::{len(critical)} critical findings require manual review before merge")
w.flush()
WITNESS
# 3. Run the SWT3 compliance gate
- name: SWT3 Gate
uses: tenova-labs/swt3-gate-action@v1
with:
tenant-id: ${{ secrets.SWT3_TENANT_ID }}
api-key: ${{ secrets.SWT3_API_KEY }}
fail-on: CRITICAL
ai-scan-witness:
stage: test
script:
- pip install -q swt3-ai
- python3 << 'WITNESS'
import json
from swt3_ai import Witness
w = Witness(
tenant_id="$SWT3_TENANT_ID",
api_key="$SWT3_API_KEY",
endpoint="https://sovereign.tenova.io/api/v1/witness"
)
@w.wrap_tool(tool_name="scanner-cli")
def run_scan():
import subprocess
subprocess.run(["scanner-cli", "scan", "--repo", ".",
"--format", "json", "-o", "scan-results.json"], check=True)
return json.load(open("scan-results.json"))
results = run_scan()
w.flush()
WITNESS
rules:
- if: $CI_MERGE_REQUEST_IID
SWT3 clearing levels control what data appears in witness anchors. For code scanning workflows, choose the level that matches your data sensitivity requirements.
| Clearing Level | What Appears in the Anchor | When to Use |
|---|---|---|
| Level 0 -- Analytics | Full procedure ID, factors, observations (hashed tool names, CWE categories, reviewer email) | Internal scanning of non-sensitive repositories. Maximum forensic value. |
| Level 1 -- Standard | Procedure ID, factors, observations with PII redacted | Scanning shared repositories where reviewer identity is sensitive |
| Level 2 -- Sensitive | Procedure ID, factors only. No observations payload. | Scanning proprietary code where CWE details and file paths must not leave the environment |
| Level 3 -- Classified | Minimal: hashed procedure, numeric factors only | Air-gapped or regulated environments (defense, financial systems) |
When evaluating whether an organization's AI code scanning workflow is properly witnessed, assessors should verify the following:
actual >= required (review completed). If actual is 0, the review was skipped -- investigate why.reviewer_id_hash in AI-HITL.3 anchors should map to a real person, not a service account or bot. Ask the organization to demonstrate the mapping.Captures SHA-256 hashes of tool/function names and serialized arguments invoked by agents. Records whether the tool call succeeded or failed. Regulatory reference: EU AI Act Art. 14(4), NIST AI RMF GOVERN 1.7. Registry entry
Verifies runtime tools match the agent's approved charter. Detects tool drift (unauthorized scanners added to pipelines). Regulatory reference: NIST AI RMF GOVERN 1.5, EU AI Act Art. 9. Registry entry
Records the named human reviewer linked to each decision, with required vs. actual reviewer counts and binding method. The primary procedure for code review witnessing in this guide. Proves both that review occurred and who performed it. Regulatory reference: EU AI Act Art. 12(2)(d), Art. 14(1). Registry entry
Logs policy violations with type, severity, and remediation status. Informational (always PASS) because recording a violation is itself a governance success. Regulatory reference: EU AI Act Art. 9, NIST AI RMF MANAGE 4.1. Registry entry
Links scan, review, and merge steps into a single governed lifecycle via shared cycle_id. Enables assessors to trace a finding from detection through resolution. Regulatory reference: EU AI Act Art. 9, NIST AI RMF GOVERN 1.3. Registry entry
Verifies cryptographic integrity of scanner output logs. Proves scanner logs have not been tampered with between scan completion and review. Regulatory reference: EU AI Act Art. 12, GDPR Art. 30. Registry entry
Inventories scanned components per G7/CISA SBOM-AI specification. Documents what was scanned, not just what was found. Regulatory reference: G7/CISA SBOM-AI, EU AI Act Art. 11, EO 14028. Registry entry