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.

Critical Assessor Notice: Boundaries of Cryptographic Evidence

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.

Contents

1. The Problem AI Code Scanners Create 2. A Model Cannot Audit Itself 3. The Witnessed Code Modification Workflow 4. Procedure Mapping 5. Witnessing the Scan (AI-TOOL.1) 6. Witnessing Human Review (AI-HITL.3) 7. Recording Policy Violations (AI-VIO.1) 8. Chaining Multi-Step Workflows (AI-CHAIN.1) 9. CI/CD Gate Integration 10. Clearing Level Considerations 11. Assessor Checklist 12. SWT3 Procedures Referenced

1. The Problem AI Code Scanners Create

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.

Scanners This Applies To

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.

2. A Model Cannot Audit Itself

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.

3. The Witnessed Code Modification Workflow

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.

DEVELOPER AI CODE SCANNER SWT3 WITNESS SIDECAR --------- --------------- -------------------- 1. Trigger scan (push / PR / schedule) | +-------------------> Analyze repository Trace data flows Detect CWE-xxx Generate patch | +--------------> [AI-TOOL.1] wrap_tool() decorator | factor_a: 1 (tool called) | factor_b: latency_ms | factor_c: 1 (success) / 0 (fail) | 2. Review findings <--------------+ Accept / Reject / Modify | +--------------------------------------> [AI-HITL.3] witness_reviewer_identity() | factor_a: reviewers required | factor_b: reviewers who reviewed | factor_c: binding method code | 3. Policy check (blocked scope? severity?) | [PASS] -----> Merge -------> [AI-CHAIN.1] witness_chain_handoff() | factor_a: chain depth | factor_b: 1 (cycle_id bound) | factor_c: 1 (accepted) | [FAIL] -----> Block -------> [AI-VIO.1] witness_violation() factor_a: severity (1-4) factor_b: 1 (auto-detected) factor_c: policy category code
Key principle: SWT3 anchors are minted at governance boundaries (scan invoked, human reviewed, policy checked), not inside the scanner itself. The scanner does not need to integrate with SWT3 at all. Your CI/CD pipeline or review workflow calls the SWT3 SDK.

4. Procedure Mapping

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

5. Witnessing the Scan (AI-TOOL.1)

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.

Python

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()

TypeScript

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();
What this produces: An immutable anchor proving that a specific scanner ran at a specific time with a measured latency and success/failure outcome. The tool name is hashed in the anchor. Source code, scan configuration secrets, and vulnerability details never enter the anchor.

6. Witnessing Human Review (AI-HITL.3)

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.

Python

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()

TypeScript

// 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();
If review is skipped: Call 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.
Four-eyes principle: For critical code paths (authentication, payment, safety), set required=2. The anchor records whether the two-reviewer requirement was met. Assessors can query for anchors where actual < required to find governance gaps.

7. Recording Policy Violations (AI-VIO.1)

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.

Python

# 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()

TypeScript

// 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.

8. Chaining Multi-Step Workflows (AI-CHAIN.1)

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.

Python

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()

TypeScript

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();
Why chaining matters: Without a shared 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."

9. CI/CD Gate Integration

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.

GitHub Actions Example

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

GitLab CI Example

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

10. Clearing Level Considerations

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)
Source code never enters the anchor. Even at Clearing Level 0, SWT3 records hashed tool names, hashed arguments, and structured observations -- not raw source code, diffs, or vulnerability details. The observations field is controlled by what you pass to the SDK.

11. Assessor Checklist

When evaluating whether an organization's AI code scanning workflow is properly witnessed, assessors should verify the following:

12. SWT3 Procedures Referenced

AI-TOOL.1 -- Tool Call Witnessing

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

AI-TOOL.2 -- Tool Permission Attestation

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

AI-HITL.3 -- Overseer Identity Capture

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

AI-VIO.1 -- Policy Violation Record

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

AI-CHAIN.1 -- Multi-Agent Chain Handoff

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

AI-AUDIT.1 -- Audit Log Integrity

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

AI-SBOM.1 -- AI Bill of Materials

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