25 Commits

Author SHA1 Message Date
Boden Fuller 7f9a6bfb38 feat(hooks): enforce lead-only worker git guard as PreToolUse hook
Adds hooks/lead-only-worker-git-guard.sh: mechanical PreToolUse guard
that blocks destructive git commands (commit, push, reset, rebase,
merge, cherry-pick, branch -D, checkout -B, worktree remove) when
running inside a swarm worker context.

Worker detection (in order): AGENTOPS_SWARM_ROLE=worker,
AGENTOPS_ROLE=worker (legacy), CLAUDE_AGENT_NAME=worker-*,
.agents/swarm-role file, CWD under /.claude/worktrees/. Allows all
non-destructive git (status, diff, log, show, blame, fetch) and safe
variants (branch -d, checkout -b). Allows everything in lead context.

Respects AGENTOPS_HOOKS_DISABLED=1 (global kill) and
AGENTOPS_LEAD_ONLY_GUARD_DISABLED=1 (local disable). Catches chained
commands (foo && git commit) via leading-token regex.

Registered under PreToolUse / Bash matcher in hooks/hooks.json.
Synced to cli/embedded/hooks/ via make sync-hooks. Adds 30-assertion
test file covering block paths, allow paths, kill switches, legacy
signals, and native-team worker naming.

Consumes ag-yhr 'Enforce lead-only worker git guard before spawn'.
Mechanical enforcement of the swarm skill's lead-only commit policy
which was previously informational only.
2026-04-15 16:48:09 -04:00
Boden Fuller 729840d126 feat: add fresh-repo onboarding welcome 2026-04-09 16:41:44 -04:00
Boden Fuller 3eb679c6f6 feat(knowledge): rename athena → compile + add Karpathy-style knowledge compiler
Rename the athena skill to compile — a descriptive name that communicates
what it actually does. Extend with Karpathy's LLM Knowledge Bases architecture:

- New compile phase: LLM reads raw .agents/ artifacts and produces interlinked
  markdown wiki at .agents/compiled/ with index.md, log.md, backlinks
- New lint phase: detects contradictions, orphan pages, stale claims, coverage gaps
- Pluggable compute backend via AGENTOPS_COMPILE_RUNTIME (ollama|claude|openai)
- Hash-based incremental compilation (only recompile changed sources)
- compile.sh engine with security fixes (no shell injection, path traversal guard)
- Full rename across 93 files: skills, docs, CLI, tests, hooks, scripts, codex

Existing Mine → Grow → Defrag cycle preserved as phases within the larger
compile workflow. No vector DB — compiled wiki IS the retrieval layer.
2026-04-05 17:57:40 -04:00
Boden Fuller aef1efab3f feat(validation): add Stage 4 behavioral validation — holdout scenarios + satisfaction scoring
Add the missing validation tier between council/vibe (Stage 3) and production
(Stage 5). Inspired by StrongDM's Digital Twin Universe and Shield AI's
SITL/HITL/VITL fidelity ladder.

New capabilities:
- Holdout isolation hook: PreToolUse gate blocks agent access to .agents/holdout/
  unless AGENTOPS_HOLDOUT_EVALUATOR=1 (prevents reward hacking)
- Scenario schema: schemas/scenario.v1.schema.json defines holdout scenario format
- Verdict extension: satisfaction_score (0.0-1.0) and satisfaction_breakdown added
  as optional fields to verdict schema (v4)
- Scenario skill: /scenario for authoring and managing holdout scenarios
- Validation pipeline: STEP 1.8 inserted for behavioral validation
- Vibe exposure: weighted_score now exposed as satisfaction_score
- CLI commands: ao scenario init|list|validate with 11 passing tests
- Planning rule: schema wave ordering for additionalProperties:false
2026-04-05 08:35:31 -04:00
Boden Fuller ad029207cf feat(flywheel): complete escape velocity epic (ag-9qm)
Section-first retrieval with weighted scoring, namespace comparison,
verified citation semantics, and escape velocity verification.

- Add weighted multi-feature scoring (heading, exact token, adjacency,
  proximity) gated by shadow namespace in inject_scoring.go
- Add `ao flywheel compare` command for primary-vs-shadow side-by-side
  metrics with promotion/rollback contract
- Add VerifyEscapeVelocity() with configurable targets (sigma>=0.30,
  rho>=0.65, sigma_rho > delta/100) in metrics_health.go
- Update 8 skill packet consumers with section evidence guidance and
  verified citation semantics (applied vs retrieved)
- 24 new tests across inject_scoring, metrics_flywheel, metrics_health
- Regenerate CLI reference for new compare subcommand

Closes: ag-9qm, ag-9qm.10, ag-9qm.11, ag-9qm.12, ag-9qm.13, ag-9qm.14
2026-04-04 16:22:38 -04:00
Boden Fuller 6df03bdbb3 feat(hooks): add claude factory startup routing 2026-04-02 15:32:50 -04:00
Boden Fuller 45db7ab97b feat(skills): apply Claude Code architecture lessons — retry budgets, stability flags, quality signals, orchestration pattern
Inspired by patterns discovered in Claude Code's npm source map leak:

- Add hook failure budget to lib/hook-helpers.sh (MAX_CONSECUTIVE_HOOK_FAILURES=3,
  configurable via AGENTOPS_HOOK_FAILURE_CAP) — prevents runaway hook loops
- Add metadata.stability field (experimental|stable) to skill frontmatter schema
  with heal.sh validation (H010) and skill-conventions documentation
- Add quality-signals.sh hook detecting repeated prompts and correction patterns,
  logging to .agents/signals/session-quality.jsonl with defined schema
- Document orchestration-as-prompt as a first-class pattern in shared references,
  linked from crank, swarm, evolve, rpi skills with codex parity
2026-04-01 08:07:39 -04:00
Boden Fuller d94be296be chore: merge upstream changes (hooks, scripts) 2026-03-27 19:47:01 -04:00
Boshu2 8365584399 feat(skills): implement 5 post-mortem improvements via parallel swarm
- Mirror-reference script (scripts/mirror-codex-references.sh) for automated skills→codex sync
- Confidence scoring in athena Mine/Grow with 0.3-0.9 weighted scale and auto-promotion
- SHARED_TASK_NOTES bridge in crank orchestrator for cross-worker context
- PostToolUse write-time quality hook for Write/Edit anti-pattern detection
- Plan mutation JSONL audit trail in crank for drift analysis
- 15 reference docs across 10 skills from competitive analysis
- All codex mirrors updated, embedded hooks synced
2026-03-21 21:46:38 -04:00
Boshu2 821624822d feat(config): add model cost tiers with per-agent model assignments
Add quality/balanced/budget/inherit tiers to ModelsConfig with
per-agent model resolution for council/crank/vibe cost management.
Includes ao config models subcommand, context-monitor hook,
and skill docs for tier consumption.

Epic: ag-w5c.6+ag-w5c.7
2026-03-21 19:17:54 -04:00
Boshu2 549d4b1b14 feat(skills): integrate competitive features from GSD/CE analysis
Add 5 features identified from reverse-engineering GSD v1.27 and
Compound Engineer v2.47:

- Node repair operator in crank (RETRY/DECOMPOSE/PRUNE recovery)
- Knowledge refresh auto-trigger via SessionEnd athena defrag hook
- Configurable review agents per project (.agents/reviewer-config.md)
- Three-tier plan detail scaling (Minimal/Standard/Deep)
- Adversarial ideation critique in brainstorm (Phase 3b red-team)
2026-03-21 15:35:04 -04:00
Boshu2 83ce8597b0 fix(flywheel): improve edit hook precision and archive reliability
Move edit-knowledge-surface hook from PostToolUse to PreToolUse so
learnings surface before the edit, not after. Fix false positives by
matching relative path first, falling back to filename only when no
path match. Fix archive script to use YYYY-MM-DD from filenames
instead of mtime, which gets reset by ao mine.
2026-03-21 00:06:55 -04:00
Boshu2 a550d43064 feat(flywheel): add edit knowledge hook and research archive script
Add PostToolUse:Edit hook that surfaces relevant learnings when editing
files mentioned in .agents/learnings/ (48ms, grep-based). Add
scripts/archive-research.sh to move stale research files to archive
and reduce search noise. Register hook in hooks.json with 3s timeout.
2026-03-20 23:58:52 -04:00
Boden Fuller b68a739331 feat(context): replace ao inject with signpost network + on-demand ao lookup
Kill the pre-loaded inject blob pattern. Context is now delivered via:
- AGENTS.md signpost files in .agents/ subdirectories (navigation)
- ao lookup --query for on-demand learnings retrieval
- session-start.sh emits a pointer instead of a blob

Issues 1-8 of context-enforcement-phase3 plan:
1. Root .agents/AGENTS.md signpost + .gitignore restructure
2. Six directory signposts (learnings, patterns, plans, council, handoff, rpi)
3. session-start.sh and worktree-setup.sh no longer call ao inject
4. Skills updated: recover, evolve, crank, swarm, council, SKILL-TIERS
5. CLAUDE.md zero-context startup references .agents/AGENTS.md
6. context-contract-check hook deleted + CI/BATS refs removed
7. ao inject stderr deprecation notice + ao lookup help improved
8. Flywheel docs updated (ARCHITECTURE.md, knowledge-flywheel.md)
2026-03-07 11:03:13 -05:00
Boden Fuller 58354d7527 feat(hooks+cli): context enforcement hook + run-id namespaced paths (na-0v2 W3)
Add PreToolUse warn-only hook (context-contract-check.sh) that warns
when skills declaring isolated/fork context run without ao inject --for.
Reads stdin JSON, strips namespace prefix, resolves SKILL.md. Add
run-id namespaced artifact path helpers (inject_context_paths.go).
Sync embedded hooks via make sync-hooks.

Issues: na-0v2.5, na-0v2.6
2026-03-03 19:35:28 -05:00
Boden Fuller a170614eed feat(ag-u5t): wave 1 — git-worker-guard, embedded parity gate, swarm evidence validation, time_boxed phase result
Wave 1 of strict-quality epic (ag-u5t), 4 issues in parallel:

- ag-u5t.1: git-worker-guard.sh blocks git commit/push/add-all for swarm workers
- ag-u5t.2: embedded_parity section in task-validation-gate auto-validates hook sync
- ag-u5t.3: validate-swarm-evidence.sh enforces fail-closed evidence validation
- ag-u5t.5: time_boxed phase result status in RPI phased runner

Also fixes: test harness cwd leak from bare cd in constraint-compiler tests,
adds test coverage for commit-review-gate, intent-echo, research-loop-detector.

173/173 hook tests pass. All Go tests pass. Embedded sync verified.
2026-03-02 11:22:16 -05:00
Boden Fuller eabcec7f2d feat(hooks): add behavioral guardrails — 3-layer defense-in-depth
Layer 1 (CLAUDE.md): First-Edit Rule, Intent Echo, Two-Correction Rule
Layer 2 (hooks): research-loop-detector (escalating at 8/12/15),
  commit-review-gate (inject diff before commit),
  intent-echo (detect destructive/ambiguous keywords incl just/only)
Layer 3 (gates): assertion density check in go-vet-post-edit,
  behavioral assertions (command + expect_pattern) in task-validation-gate

hooks.json: 7 events (was 6), 12 hooks (was 9), new UserPromptSubmit.
All hooks non-blocking with kill switches. Embedded copies synced.
2026-03-02 10:46:26 -05:00
Boden Fuller 6cce98685c feat: post-mortem findings — test-first defaults, phase budgets, validation policy
- cli: default --test-first=true for strict-quality execution, add
  --no-test-first opt-out, add --budget/--no-budget phase budget controls
  with parsing and mutual exclusion validation
- hooks: add pre-mortem gate (PreToolUse on Skill), TaskCompleted hook
  for task-validation-gate, enhance gate with issue type classification
  and test-exempt path for docs/chore/ci types
- skills: pin council codex model to gpt-5.3-codex, add ci to crank
  skip-types, add evolve flags table with test-first/no-test-first,
  update validation contract with metadata policy for impl vs doc tasks
- skills: update rpi/swarm/crank references for budget controls,
  taskcreate validation metadata, and worker pitfall patterns
- tests: add pre-mortem gate and task-validation-gate hook tests,
  update test-first smoke and tuning defaults for new flag defaults
- chore: remove tracked .beads/ config (now gitignored), update
  learnings and next-work.jsonl
2026-03-02 09:41:11 -05:00
Boden Fuller 96b62f20fb chore: stage council V2 contract wiring and skill-codex updates
Wire 6-judge analytics recommendations into skill contracts, add push
skill, sync embedded hooks, and update docs/product metadata.
2026-03-02 06:48:56 -05:00
Boden Fuller 292ddf9491 chore: commit all pending workspace changes 2026-02-26 11:30:01 -05:00
Boden Fuller 753b52f4e1 fix: strip hooks to bare-minimum flywheel
Hooks were breaking and doing too much. Reduced from 22 hooks across
12 events to 3 hooks across 3 events (SessionStart, SessionEnd, Stop).

Kept only what the knowledge flywheel needs:
- SessionStart: mkdir .agents, ao extract, ao inject, skill context
- SessionEnd: ao forge transcript, ao maturity (scan/expire/evict)
- Stop: ao flywheel close-loop

Removed from registration (scripts still in hooks/ for re-enablement):
PreToolUse, PostToolUse, UserPromptSubmit, TaskCompleted, PreCompact,
SubagentStop, WorktreeCreate, WorktreeRemove, ConfigChange hooks.

session-start.sh: 600 → 99 lines
session-end-maintenance.sh: 79 → 53 lines
2026-02-22 19:26:22 -05:00
Boden Fuller f42f1fbdeb refactor: remove push-gate hook
Push-gate added friction without meaningful safety — the ratchet
nudge via prompt-nudge.sh already covers the workflow gating.
Removes hook, config entries, preflight expectation, stale comment
references, and 6 push-gate tests. Updates test 23 fixture path.
2026-02-22 19:08:58 -05:00
Boden Fuller 882fc2f3c9 perf: consolidate hooks — 14 process startups down to 4
SessionStart: remove 4 redundant thin wrappers (ao-extract, ao-inject,
ao-ratchet-status, ao-maturity-scan) — already done inside session-start.sh.
Fold ao inject into session-start.sh.

SessionEnd: merge 4 thin wrappers (ao-forge, ao-session-outcome,
ao-feedback-loop, ao-task-sync) into session-end-maintenance.sh.
Add maturity scan to session-end where it belongs.

Before: 7 SessionStart hooks + 5 SessionEnd hooks = 14 Go process startups
After:  3 SessionStart hooks + 1 SessionEnd hook = 4 Go process startups
2026-02-22 17:58:19 -05:00
Boden Fuller d673d7337c fix(hooks): rotate chain.jsonl, cache file count, remove redundant hook
- Add chain.jsonl rotation at session start when exceeding 200 lines
  (configurable via AGENTOPS_CHAIN_MAX_LINES), archiving excess to
  .agents/ao/archive/. Prevents unbounded growth that slows O(n) grep
  in 5 consumer hooks.
- Cache .agents file count in AGENTS_FILE_COUNT variable, eliminating
  a duplicate find call in the prune check.
- Remove ao-agents-check.sh (redundant with session-start.sh prune
  block) and deregister from hooks.json.
- Fix stop-auto-handoff test assertion (wrong glob path).
- Add kill-switch + fail-open tests for 9 previously uncovered ao-*
  hooks, achieving 100% hook coverage.
2026-02-21 21:23:53 -05:00
Boden Fuller 37d4b5b2ae Merge branch 'codex/rpi-supervisor-cli' into main 2026-02-21 19:41:50 -05:00