Skip to content

IMPORTANT

AI Context & Knowledge Heritage

  • Subsystem: Architecture & Documentation / Core Docs / CLI_TOOLS
  • Architecture: @docs ARCHITECTURE:Documentation
  • Failure Path: Information drift, legacy terminology, or documentation mismatch.
  • Observability: Traceability via execution/parity_guard.py

๐Ÿ› ๏ธ CLI Operations: Tadpole OS Tooling โ€‹

Status: Verified

Tadpole OS provides a suite of deterministic Python scripts for lifecycle management, memory synthesis, and post-mission debriefing. These tools are located in the execution/ directory.


๐Ÿง  Mission Debriefing (debrief_mission.py) โ€‹

The primary tool for extracting institutional memory and architectural wisdom from mission logs.

Usage โ€‹

bash
python execution/debrief_mission.py <MISSION_ID> [--commit]

Options โ€‹

FlagDescriptionDefault
<MISSION_ID>Required positional mission ID to debrief.None
--commitCommit Learning: Appends synthesized insights to directives/LONG_TERM_MEMORY.md.false

Workflow โ€‹

  1. Extraction: Reads mission history and logs from the configured SQLite database.
  2. Synthesis: Uses the configured Groq-compatible endpoint to identify failures and technical lessons.
  3. Persistence: Formats insights into standard markdown for the OS's long-term memory.

๐Ÿ Python Script Audit (audit_python_scripts.py) โ€‹

Performs a side-effect-free inspection of every workspace .py file. It parses and compiles each source file without importing it, checks import availability, records network/database/process capabilities, and flags non-portable paths or unsafe APIs.

Usage โ€‹

bash
npm run audit:python
# Fail on warnings that require manual review:
python execution/audit_python_scripts.py . --strict-warnings

The machine-readable report is written to reports/intelligence/python_script_audit.json. Generated dependency, build, virtual environment, and .tmp directories are excluded; repository tmp/ scripts remain in scope.


๐Ÿ›ก๏ธ Parity Guard (parity_guard.py) โ€‹

The integrity gatekeeper used to ensure that code and documentation remain in a state of "Sovereign Parity." Modularized into single-responsibility libraries under execution/lib/:

  • execution/lib/parity_router.py: AST route extraction via syn with deterministic regex fallback.
  • execution/lib/parity_validators.py: Isolated validation checks for API parity, environment variables, skills, documentation cross-links, and wiki metadata.

Usage โ€‹

bash
python execution/parity_guard.py [FIX=1]

Checks Performed โ€‹

  • API Parity: Compares Axum routes (router.rs) against openapi.yaml.
  • Tag Verification: Scans all source files for @docs tags and verifies the destination file exists.
  • Environment Safety: Checks if all std::env::var calls in the engine are documented in .env.example.
  • Skill Validation: Verifies that every JSON skill manifest has a corresponding execution script on disk.
  • Link Guard: Validates that all relative markdown links and anchor references resolve without broken paths.

๐Ÿ” AI Context Contract Verifier (verify_ai_context.py) โ€‹

Verifies that source files across the repository conform to AI Context Alignment standards, ensuring that AI agents always have structured architectural heritage when inspecting files. Modularized into:

  • execution/lib/ai_context_parser.py: Comment/string stripping, header block isolation, metadata extraction, and code body slicing.
  • execution/lib/ai_context_resolver.py: Symbol definition checking, telemetry tag emission verification, witness test harvesting, and ADG manifest integration.

Usage โ€‹

bash
# Verify entire repository
python execution/verify_ai_context.py .

# Verify specific file
python execution/verify_ai_context.py src/services/agent_service.ts

๐Ÿงน Clean Code & Complexity Ratchet Tooling โ€‹

The repository enforces clean-code standards and complexity constraints across Rust, TypeScript, and Python via deterministic scripts in .agent/skills/clean-code/scripts/ integrated as npm scripts in package.json.

npm Scripts โ€‹

ScriptCommandPurpose
npm run lint:cleanpython .agent/skills/clean-code/scripts/clean_code_linter.pyFull codebase audit for file size, function size, nesting depth, parameter counts, and raw .unwrap() calls.
npm run lint:clean:diffpython .agent/skills/clean-code/scripts/clean_code_linter.py --diffGit-diff pre-commit mode checking only staged and modified files.
npm run lint:complexitypython .agent/skills/clean-code/scripts/complexity_analyzer.pyCyclomatic complexity scoring (Rust, TS/JS, Python) flagging high-risk control flow ($\ge 15$).

Thresholds & Clean Code Standards โ€‹

  • File Length: $\le 500$ lines of code per file (prevents monolithic modules).
  • Function Length: $\le 50$ lines of code per function (promotes small, single-purpose helpers).
  • Nesting Depth: $\le 4$ levels of block nesting (enforces early returns and guard clauses).
  • Parameter Count: $< 6$ parameters per function (mandates parameter object bundling).
  • Zero Unwraps: $0$ production runtime .unwrap() calls in server-rs/src/ (fail-safe error propagation via ?, ok_or_else, or default matchers).

๐Ÿง  Graph Intelligence CLI (graph_query) โ€‹

The scriptable binary for symbol graph queries, audit context generation, and Active Documentation Guard enforcement. Located at server-rs/src/bin/graph_query/ (decomposed into 5 modules in ADG-05).

Usage โ€‹

powershell
cargo run --bin graph_query -- <SUBCOMMAND> [OPTIONS]
# or via npm scripts:
npm run graph:lookup  -- --name SymbolName
npm run graph:file    -- --path src/pages/Neural_Map.tsx
npm run graph:blast:guard -- --path src/pages/Neural_Map.tsx
npm run graph:blast   -- --path server-rs/src/routes/intelligence.rs --name get_blast_radius
npm run graph:export

Subcommands โ€‹

SubcommandDescription
exportExport the full symbol graph as JSON (--pretty, --out)
audit-contextGenerate high-connectivity audit context for AI agents (--limit)
lookupFind all definitions of a named symbol (--name, --json, --out)
fileList all symbols defined in a file (--path, --json, --out)
blastCalculate blast radius of a symbol (--name, --path, --depth, --format)
validateRun Active Documentation Guard on docstring symbols (--strict, --diff, --fix)
route-parityVerify Axum router.rs AST route parity against docs/openapi.yaml via syn + serde_norway (--root, --json)

graph:blast:guard is the mandatory pre-change alias for the file query. The graph CLI does not expose prune or watch commands; each invocation rebuilds its source snapshot before querying.

blast Format Options (--format) โ€‹

ValueOutput
text (default)Human-readable stdout
mermaidMermaid graph TD flowchart
htmlInteractive Cytoscape.js dark-mode HTML page

validate Flags โ€‹

FlagDescription
--strictFail with exit code 1 if any symbol is unresolved
--diffRestrict scan to git-modified files only (fast pre-commit mode)
--fixAuto-correct drifted symbol names using Jaro-Winkler similarity

๐Ÿ›ก๏ธ Active Documentation Guard CLI (tools/adg/adg.mjs) โ€‹

The zero-dependency Node.js CLI engine that enforces ADG v2 across the TypeScript and frontend codebase. Replaces manual comment claims with machine-computed manifests and executable invariant testing.

Commands & npm Scripts โ€‹

Commandnpm ScriptDescription
lint-headers <dir>npm run adg:lintScans files for forbidden v1 header fields (Witness Tests:, Invariants:, etc.)
codemod [--write] <dir>npm run adg:codemod / npm run adg:codemod:writeStrips legacy v1 fact-fields while preserving @docs architectural guidance
generate [--check] <dir>npm run adg:generate / npm run adg:checkComputes witness maps, parses CSP, checks ratchets, and updates or validates adg.manifest.json
verify <dir>npm run adg:verify / npm run test:witnessExecutes full verification pipeline (must-fail fixtures, lint, CSP grammar, manifest integrity)

Usage Examples โ€‹

powershell
# Lint source files for legacy v1 header anti-patterns
npm run adg:lint

# Regenerate the machine manifest and enforce ratchet coverage
npm run adg:generate

# Verify manifest matches repository state with zero drift
npm run adg:check

# Run full ADG v2 verification suite
npm run adg:verify

๐Ÿ—๏ธ Deployment & Lifecycle Scripts โ€‹

Cross-platform deployment, packaging, and Plane 1 lifecycle verification tools:

Features โ€‹

  • scripts/deploy-bunker-{1,2}.ps1 (Windows) & scripts/deploy-bunker-{1,2}.sh (Linux/macOS): pinned bunker deployment scripts invoked by POST /v1/engine/deploy (RequireAdmin).
  • scripts/build-linux-light.{ps1,mjs,sh}: builds .deb and .AppImage artifacts using Docker.
  • scripts/build-macos-universal.sh & scripts/verify-macos-bundle.sh: builds and verifies Universal 2 macOS .dmg bundles.
  • scripts/deploy-linuxlite.ps1: transfers and installs a built .deb over SSH.
  • scripts/publish-public.ps1: builds the sanitized .tmp/public-release/ snapshot for public sync.
  • npm run check:plane1 / npm run check:plane1:fast / npm run plane1:sandbox / npm run plane1:observe: Plane 1 Sovereign Lifecycle pre-flight gates, worktree sandboxing, and read-only health observation.

Sovereign Intelligence Architecture.