PayCargo · AI-Sandbox · Step 6.w

6.wFoundation Audit — scheduled AI audits + operator console

Unattended, read-only AI audits of the platform on a schedule you own; each publishes a versioned HTML report into Doc Vault. Now also an interactive Console cartridge: run an audit now, watch run history, edit the grounding doctrine, and connect an external scheduled evaluator.
Block: 6.w (cartridge; administrative department) · State: Live in AI-Sandbox · Cartridge: cartridges/administrative/foundation-audit/
Self-audit removed
The AI self-audit was removed by decision. The platform must never be able to read its own repository (even read-only), so it can't enumerate its own weaknesses. This cartridge no longer has a GitHub reader, repo tools, Bedrock, a guardrail, or scheduled jobs — it is now a passive operator console (grounding-docs editor + read-only run history + a latent Doc Vault publish path). The description below is retained for historical context.
Shipped
Three AI audits run on EventBridge schedules and file their reports into the Foundation Audit Doc Vault project. The cartridge began headless (backend-only); it now carries an operator console the launcher iframes — a tile you open to run an audit on demand, read the run history, and edit the CLAUDE.md/skills.md doctrine the auditor follows.

Contents

  1. The three audits
  2. System identity (no signed-in user)
  3. Publishing to Doc Vault
  4. The operator console (HTTP surface)
  5. The grounding-docs editor
  6. Connecting an external scheduled evaluator
  7. Files at a glance

1. The three audits

Each audit is a read-only Bedrock tool-use run over repo source + live platform state, on the shared agent engine (shared/modules/agent/engine.js). Every tool is a READ (list_tree, read_file, list_dir, platform_state) — the auditor cannot change the platform it audits. The model is Sonnet 4.6 (the account has Bedrock access to it).

jobIdAuditCadence (UTC)
audit-disciplineFoundation & cartridge discipline drift vs. doctrinedaily 07:00
audit-soc2Security & SOC 2 complianceweekly Mon 07:30
audit-cartridgeCartridge quality & anti-patternsweekly Mon 08:00

All three fire on their cron and on demand. The manual path sends { source:'manual-run', jobId }; the handler accepts it alongside the EventBridge { source:'eventbridge-scheduler', jobId }. Every fire writes start + terminal run records into the shared agent-state table (agent_session_id='job-run'), which the obs Schedules tab and the watchdog read (Step 6.k).

2. System identity — not per-user

A scheduled run has no signed-in user, so the cartridge uses a dedicated system identity:

3. Publishing to Doc Vault

A finished report is filed as a versioned document in the Foundation Audit Doc Vault project via the system-publish path — a direct lambda:InvokeFunction carrying { source:'system-publish', … }, checked before Doc Vault's HTTP gates (the IAM invoke permission is the authorization, exactly like the trash-sweep). It ensures a _system-owned project by fixed projectId, optionally grants viewer to the configured reader, then runs the same commit invariants (discipline check + append-only version). Publishing is best-effort: a publish problem never fails the audit (the report is already recorded).

Operator step

Set audit_report_reader (tfvars) to your cognito:username, or reports publish but stay system-owned (unreadable) until granted through the obs share picker. Same "operator supplies identity" pattern as the GitHub PAT.

4. The operator console (HTTP surface)

The cartridge was backend-only; it now ships a small console the Console launcher iframes (its own S3+CloudFront frontend and an API Gateway HTTP API behind the same X-Origin-Secret gate). The handler dispatches on event shape — an HTTP request carries event.rawPath; the scheduled paths carry event.source and never a rawPath — so an HTTP request still cannot spoof its way into a run.

RouteAuthDoes
GET /api/healthorigin secretliveness
GET /api/config+ pool JWTaudit catalog + doc-vault project + flags
GET /api/runs+ pool JWTrecent run history (Query on the agent-state table)
POST /api/run+ admins / cart-foundation-auditfire an audit now (async self-invoke = obs manual-run)

The tile is gated to the cart-foundation-audit group (admins bypass). Run-now is an async self-invoke with a deterministic-ARN IAM grant (avoids the role↔function cycle); the UI returns immediately and polls /api/runs while a run is running.

5. The grounding-docs editor

The console edits this cartridge's CLAUDE.md / skills.md in place — the same versioned Content CMS docs that steer the built-in audits and that an external evaluator pulls over the Console MCP. The handler forces cartridge=foundation-audit, scope='_'; read is any signed-in user, write is admins / the cart group.

RouteDoes
GET /api/groundingactive CLAUDE.md + skills.md bodies/versions
PUT /api/grounding/{name}save a new active version of claude/skills

Network note (VPC endpoint policy)

This Lambda is VPC-attached, so console-content had to be added to the agent-tier DDB gateway endpoint policy (cartridge_table_patterns) for the reads/writes to reach it. That change also unblocked squad-assess/workbench grounding reads, which were being silently denied at the endpoint before (best-effort masked it). IAM still gates each role — foundation-audit gets read+write on that one table only.

6. Connecting an external scheduled evaluator

Beyond the built-in audits, an operator can point their own scheduled Claude Code at this cartridge over the Console MCP. The in-cart guide ("Connect a scheduled evaluator") walks it: mint a machine token targeting foundation-audit with boundaries grounding + publish, set the machine up with one paste, then a cron that pulls the current doctrine (grounding_manifest/grounding_get), reviews the repo, and calls publish_evaluation into this cartridge's Doc Vault project. The reviews land alongside the built-in audits, through the same discipline gate.

7. Files at a glance

The loop, closed

Edit the doctrine in the cartridge → the scheduled evaluator pulls the current version over MCP → it publishes its review into the Foundation Audit Doc Vault project → the operator reads it. Human authors the standard; the machine applies it on a schedule.