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 โ
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 โ
python execution/debrief_mission.py <MISSION_ID> [--commit]Options โ
| Flag | Description | Default |
|---|---|---|
<MISSION_ID> | Required positional mission ID to debrief. | None |
--commit | Commit Learning: Appends synthesized insights to directives/LONG_TERM_MEMORY.md. | false |
Workflow โ
- Extraction: Reads mission history and logs from the configured SQLite database.
- Synthesis: Uses the configured Groq-compatible endpoint to identify failures and technical lessons.
- 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 โ
npm run audit:python
# Fail on warnings that require manual review:
python execution/audit_python_scripts.py . --strict-warningsThe 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 viasynwith deterministic regex fallback.execution/lib/parity_validators.py: Isolated validation checks for API parity, environment variables, skills, documentation cross-links, and wiki metadata.
Usage โ
python execution/parity_guard.py [FIX=1]Checks Performed โ
- API Parity: Compares Axum routes (
router.rs) againstopenapi.yaml. - Tag Verification: Scans all source files for
@docstags and verifies the destination file exists. - Environment Safety: Checks if all
std::env::varcalls 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 โ
# 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 โ
| Script | Command | Purpose |
|---|---|---|
npm run lint:clean | python .agent/skills/clean-code/scripts/clean_code_linter.py | Full codebase audit for file size, function size, nesting depth, parameter counts, and raw .unwrap() calls. |
npm run lint:clean:diff | python .agent/skills/clean-code/scripts/clean_code_linter.py --diff | Git-diff pre-commit mode checking only staged and modified files. |
npm run lint:complexity | python .agent/skills/clean-code/scripts/complexity_analyzer.py | Cyclomatic 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 inserver-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 โ
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:exportSubcommands โ
| Subcommand | Description |
|---|---|
export | Export the full symbol graph as JSON (--pretty, --out) |
audit-context | Generate high-connectivity audit context for AI agents (--limit) |
lookup | Find all definitions of a named symbol (--name, --json, --out) |
file | List all symbols defined in a file (--path, --json, --out) |
blast | Calculate blast radius of a symbol (--name, --path, --depth, --format) |
validate | Run Active Documentation Guard on docstring symbols (--strict, --diff, --fix) |
route-parity | Verify 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) โ
| Value | Output |
|---|---|
text (default) | Human-readable stdout |
mermaid | Mermaid graph TD flowchart |
html | Interactive Cytoscape.js dark-mode HTML page |
validate Flags โ
| Flag | Description |
|---|---|
--strict | Fail with exit code 1 if any symbol is unresolved |
--diff | Restrict scan to git-modified files only (fast pre-commit mode) |
--fix | Auto-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 โ
| Command | npm Script | Description |
|---|---|---|
lint-headers <dir> | npm run adg:lint | Scans files for forbidden v1 header fields (Witness Tests:, Invariants:, etc.) |
codemod [--write] <dir> | npm run adg:codemod / npm run adg:codemod:write | Strips legacy v1 fact-fields while preserving @docs architectural guidance |
generate [--check] <dir> | npm run adg:generate / npm run adg:check | Computes witness maps, parses CSP, checks ratchets, and updates or validates adg.manifest.json |
verify <dir> | npm run adg:verify / npm run test:witness | Executes full verification pipeline (must-fail fixtures, lint, CSP grammar, manifest integrity) |
Usage Examples โ
# 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 byPOST /v1/engine/deploy(RequireAdmin).scripts/build-linux-light.{ps1,mjs,sh}: builds.deband.AppImageartifacts using Docker.scripts/build-macos-universal.sh&scripts/verify-macos-bundle.sh: builds and verifies Universal 2 macOS.dmgbundles.scripts/deploy-linuxlite.ps1: transfers and installs a built.debover 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.
