Commit Graph

23 Commits

Author SHA1 Message Date
Bo e4e32a3374 feat(orchestration): dual-runtime OrchestrationPort foundation (ag-nk67 #orchestration-foundation) (#598)
## What

The **dual-runtime OrchestrationPort foundation** — the seam that gates
the
`[EPIC] AgentOps × Claude Managed Agents integration (dual-runtime)`
application epics.
Implements the 3-category model (Claude Workflow / NTM swarm / plain
skill) behind a
single `OrchestrationPort` with safe degradation **NTM → Claude-native →
beads floor**
and a global `AGENTOPS_ORCHESTRATION=off` opt-out.

Derived from a live 3-legged spike (`~/dev/agentops-3cat-spike/`): safe
degradation is
solvable at the selection layer; parallel buys quality/independence not
wall-clock at
small N; NTM is a multi-vendor control plane that runs Claude/Codex as
panes.

## What's in it (10 slices, agent-team driven)

- **Port + adapters** — `cli/internal/ports/orchestration.go` (idiomatic
to existing ports pattern) + new `cli/internal/orchestration/` pkg:
`Selector`, `ntm_probe` (capability detection via `ntm
--robot-capabilities`, not `command -v`), `beads_floor` +
`OrchestrationResult` parity type, degradation-conformance test.
- **Live CLI** — `ao orchestrate select` (`--pin`/`--opt-out`/`--json`);
COMMANDS.md regenerated.
- **Contracts** — `schemas/orchestration-{backend,result}.v1` + paired
`docs/contracts/` docs (structural-floor gated: 41 contracts).
- **Prose** — swarm/shared/crank rewritten NTM>native>beads; **gc
demoted** (soc-2rtm0); `rpi_phased_stream.go` doc-comment fixed.
- **Skills** — `automation-shape-routing` (the 3-category router) +
`workflow-builder` + meta-skill authoring chain wired (`context_rel`);
skill counts synced.
- `lib/orchestrate-select.sh` selector seam.

## Verification (local)

`go build ./...` clean · `go vet` clean · **56 Go tests pass**
(orchestration 31, ports 10, cmd/ao orchestrate 15) · structural-floor
PASS (41) · `lib/orchestrate-select.sh --self-test` 6/6 · live command:
`--json`→claude (NTM absent), `--opt-out`→beads, `--pin claude`→claude.

## Notes

- Bundles the foundation + the routing/authoring skills as one coherent
dual-runtime arc.
- NTM/Claude executors are stubs (the parity contract is real); concrete
executors land in the application epics this gates.
- Two-ladders distinction preserved (spawn-backend ladder A vs CLI
phase-executor ladder B) — see `docs/contracts/orchestration-ports.md`.

Closes-scenario: ag-nk67#orchestration-foundation
Bounded-context: BC5-Runtime
Evidence: cli/internal/orchestration/conformance_test.go
2026-05-29 18:42:45 +00:00
Bo e431339c40 feat(hookless)!: remove all hooks — skills + CLI only (soc-57b7f #remove-all-hooks) (#511)
## What

AgentOps 3.0 goes **fully hookless**. This removes the entire hook
product surface — the product is now skills + the `ao` CLI with **zero
hooks**. CI is the authoritative gate.

## Deleted

- `hooks/` — 46 hook scripts + `hooks.json` + examples (whole directory)
- `cli/embedded/hooks/` + embedded `hooks.json` +
`embedded/lib/hook-helpers.sh`
- `lib/hook-helpers.sh`
- `ao hooks` CLI command: `cli/cmd/ao/hooks.go`, `hooks_run.go` + 5 hook
test files; `cli/internal/bridge/hooks.go`;
`cli/internal/doctor/fix_hooks.go` + test
- Codex hook manifest (`hooks/codex-hooks.json`) + handler/audit scripts
(`scripts/audit-codex-hooks.sh`, `install-dev-hooks.sh`,
`test-hooks-output.sh`, `test-codex-hookless-lifecycle.sh`,
`test-hookless-rpi-phased.sh`)
- Hook lease surface: `docs/contracts/hook-lease-*`,
`schemas/hook-lease.v1.schema.json`,
`scripts/check-hook-lease-inventory.sh`,
`check-hook-port-replacements.sh`, `generate-hook-lease-inventory.py`
- Hook docs: `docs/HOOKS.md`, `cli/docs/HOOKS.md`,
`docs/architecture/hook-noise-audit.md`,
`docs/contracts/hook-runtime-contract.md`
- `tests/hooks/` (whole dir) + hook test scripts; 5 hook eval suites +
fixtures

## CI gates removed

`hook-preflight`, `validate-hooks-doc-parity`, `hook-output-schema-lint`
(+ scripts/bats), the hook eval suites, the `test-runtime-codex-smoke` /
`test-codex-native-install` / `test-codex-plugin-install` hook-handler
assertions, the cli-integration hook-lifecycle steps, the bats
`tests/hooks/*` glob + orphan-hooks audit, and the `--with-hooks`
install path. `embedded-sync` now validates only lib/skills. Both
summary `needs:` lists + the summary echo +
`docs/contracts/ci-jobs.yaml` updated; `validate-ci-policy-parity`
passes (66 rows). `.codex-plugin/plugin.json` drops the "Hooks"
capability.

## Load-bearing PRESERVED (reported, not forced)

- **`cli/cmd/ao/codex_runtime.go`** — the codex runtime *lifecycle
profile* (`HookCapable`/`HookConfigured` detection) is a
runtime-capability abstraction used by 6 `validate-codex-*` CI gates,
distinct from the hook product. Deleting it is a separate refactor.
- **`hooks-authoring` skill** + `schemas/hooks-manifest.v1.schema.json`
— reframed as an opt-in "author your own hooks" guide. Deleting the
skill cascades into catalog/domain-map/dispositions/context-map golden
files (skill-count sync), out of scope for the hook-product removal.
- **`scripts/pre-push-gate.sh`** — retired local gate (not in CI);
self-skips deleted hook scripts via `[[ -x ]]` guards; its 55 bats tests
still pass.
- Domain-enforcement audit keeps the `enforced`-mode schema for
backward-compatible JSON readers, but the hookless resolver only returns
`audited`/`unavailable`.

## Verification

`go build` / `go vet` clean; `go test ./...` = **11849 passed, 0
failed** (68 pkgs). gofmt clean on all touched files. Green: registry
`--check` (0 hooks), `regen-codex-hashes --check`,
`validate-ci-policy-parity`, `check-wiring-closure`,
`validate-embedded-sync`, `validate-manifests`, `validate-agents-split`,
`doc-release` (0 broken links), `generate-cli-reference --check`,
`heal.sh --strict`, codex/claude/plugin smoke tests, baseline-audit (0
stale). Diff: 231 files, +354 / −39803.

Closes-scenario: soc-57b7f#remove-all-hooks
Bounded-context: BC5-Runtime
Evidence: .github/workflows/validate.yml
2026-05-24 11:19:37 -04:00
Bo 8c02ded329 fix(bats): disable background gc in fixtures to kill the flaky teardown (soc-72gkw #bats-flaky-teardown) (#439)
P2 agentops-core bug. verified-rebase.bats test 919 intermittently
failed in teardown `rm -rf $TMP` — a git background process
(auto-gc/fsmonitor) held a file in $TMP/.git when rm fired (failed on
#438 run 1, passed on re-run). Would keep biting future PRs.

Root fix (shared helper, covers all fixtures):
- lib/bats-common.bash bats_init_repo: gc.auto 0 + maintenance.auto
false + core.fsmonitor false
Defense-in-depth:
- verified-rebase.bats teardown: cd / before rm, best-effort rm

How tested: shellcheck clean; bats-common 5/5; verified-rebase 4/4 × 3
consecutive runs (was flaky).

NOTE: claude-review infra-red (weekly limit, resets May 25) —
operator-authorized bypass when sole red.

Closes-scenario: soc-72gkw#bats-flaky-teardown
Bounded-context: BC5-Runtime
Evidence: lib/bats-common.bash
2026-05-23 02:00:07 -04:00
Bo 566f7bd69f feat(lib): bats-common.bash shared fixture helpers (soc-jhq6 #bats-common-helpers) (#435)
P2 agentops-core fix. 15 script-test bats files re-derive the same
fixture boilerplate (mktemp, git init + identity, bin-stubbing) →
setup-drift bugs. Centralized.

- lib/bats-common.bash (NEW): bats_repo_root, bats_init_repo,
bats_stub_bin — functions only, no top-level shell opts
- tests/scripts/bats-common.bats (NEW): 5 self-tests
- verified-rebase.bats: refactored to use the lib (proof-of-adoption)

Bounded: lib + self-test + 1 adoption. Broader adoption (~14 files) is
incremental follow-up.

How tested: shellcheck clean; bats 5/5 + 4/4 under CI-like env (EDITOR
unset). Caught + fixed the worktree-.git-is-a-file gotcha locally.

NOTE: claude-review infra-red (weekly limit, resets May 25) —
operator-authorized bypass when sole red.

Closes-scenario: soc-jhq6#bats-common-helpers
Bounded-context: BC5-Runtime
Evidence: lib/bats-common.bash
2026-05-23 01:03:41 -04:00
Boden Fuller 55ded76d0b fix(codex-spawn): bypass intent-echo on team-runner + smoke + validate scripts + tests
Substrate fix for the intent-echo hook trap. The Mac codex install ships
~/.codex/hooks.json with intent-echo.sh on UserPromptSubmit; long prompts
containing destructive verbs or scope-limiters trigger a HIGH-STAKES
preamble that captures as the assistant message. Non-interactive `codex
exec` then produces no real output.

team-runner.sh:226 is the load-bearing dispatcher behind /swarm, /crank,
/evolve, /codex-team, /red-team — patching it once propagates the fix to
every team-runtime skill. Mirror on the dry-run echo at :195.

smoke-test-codex-skills.sh prompts contain "only" (line 175); validate
prompt contains "only" (line 61). Both trigger today.
test-sandbox-mode.sh and test-structured-output.sh patched defensively
for drift resistance.

See .agents/findings/registry.jsonl entries f-2026-05-02-002 and
f-2026-05-02-003.
2026-05-02 12:34:56 -04:00
Boden Fuller 944be4b894 refactor(hook-helpers): source lib/ao-paths.sh in lib/hook-helpers.sh (soc-irg1.5)
Wire lib/hook-helpers.sh to source the canonical state-path resolver from
soc-irg1.1 (lib/ao-paths.sh). All path constants (_HOOK_PACKET_ROOT,
_EVIDENCE_ONLY_CLOSURE_DIR, _EVIDENCE_ONLY_CLOSURE_RELEASE_DIR, the failure-
budget state_dir paths) now prefer AO_AGENTS_DIR / AO_COUNCIL_DIR with the
legacy ${ROOT}/.agents fallback chain preserved when the resolver cannot be
sourced. AO_HOME / CLAUDE_PLUGIN_DATA precedence flows transparently.
2026-05-02 08:15:51 -04:00
Boden Fuller 940532a9fe feat(paths): state-path resolver foundation (lib/ao-paths.sh + cli/internal/paths) (soc-irg1.1)
Centralized resolver for .agents/ subpaths — replaces scattered hardcoded
paths across hooks and ao subcommands. Honors env precedence:
AO_HOME > CLAUDE_PLUGIN_DATA > \${PWD}/.agents.

- lib/ao-paths.sh: sourceable shell resolver, emits export NAME=value lines
  on stdout. Idempotent. Per-subdir env overrides win over the layout.
- cli/internal/paths/paths.go: Go package with Resolve() / ResolveFromRepo()
  / Validate(). 12 resolved roots: AgentsDir, KnowledgeRoot, HooksDir,
  ScopeLock, RPIDir, FindingsDir, PlansDir, CouncilDir, LearningsDir,
  PatternsDir, DecisionsDir.
- L1 unit + L2 cross-language scenario test asserting shell + Go agree
  for the same env (TestShellGoAgreement: 3 subcases).

KnowledgeRoot intentionally maps to .agents/wiki only (internal compiled
wiki); raw+wiki external knowledge tree is unmapped per f-2026-05-01-005.

This is the foundation; consumer migration lands in I5 under a warn-only
ratchet (per warn-then-fail-ratchet pattern).

Wave 1 of epic soc-irg1 (gstack absorption Tier 1).
2026-05-02 08:15:51 -04:00
Bo 78a8e9dfbd Fix commit-review redaction and add agents guide (#146)
## Summary
- redact quoted secret assignments and Authorization tokens in commit-review diffs
- add the Working with `.agents/` operator guide
- fix CLI docs check SIGPIPE false failures

## Review
- fixed trailing blank line caught by `git diff --check` before merge
- no remaining blocking review findings

## Validation
- required Validate workflow summary passed
- all blocking checks passed; security-toolchain-gate is non-blocking and reports pre-existing repo findings
2026-04-25 16:41:35 -04:00
Boden Fuller 6b983fa752 refactor(hooks): add managed runtime backend 2026-04-24 00:43:57 -04:00
Boden Fuller d03ff5620b chore(bd): default BEADS_DOLT_SERVER_PORT=3307 in hook helpers + bd scripts
lib/hook-helpers.sh exports BEADS_DOLT_SERVER_PORT with override via
${BEADS_DOLT_SERVER_PORT:-3307} so users can still override per shell.
All hooks that source hook-helpers.sh automatically inherit the port.

scripts/bd-audit.sh and scripts/bd-cluster.sh are standalone bd callers
that do not source hook-helpers.sh, so they get the same export inline.

cli/embedded/lib/hook-helpers.sh synced via make sync-hooks.

Consumes ag-co7 'Export BEADS_DOLT_SERVER_PORT=3307 in shell env'.
2026-04-15 15:53:15 -04:00
Boden Fuller 2484d5f67b fix(team-runner): surface claude process failures 2026-04-12 11:56:23 -04:00
Boden Fuller 1a51354917 docs(team-runner): clarify claude sandbox semantics 2026-04-12 11:51:20 -04:00
Boden Fuller c3fd166f7e refactor(rpi): wave 2 — hook polish, test infra cleanup, skill normalization
Hook polish: add missing kill switch to go-test-precommit.sh, fix shebang
and bracket style in hook-helpers.sh, shellcheck annotations for
finding-compiler.sh and session-start.sh.

Test infra: refactor defrag.go writeDefragReport to accept io.Writer,
consolidate chdirTempWorkspace into chdirTo delegation, add godoc to
testutil_test.go helpers.

Skills: normalize output_contract quoting in brainstorm, design,
red-team, review SKILL.md frontmatter.
2026-04-04 23:25:12 -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 7ac8a29b56 feat(ci): shift 9 CI-only checks to pre-push gate
Add doc-release, contract-compatibility, hook-preflight, hooks-doc-parity,
ci-policy-parity, shellcheck, symlink-rejection, learning-coherence, and
orphan-hooks checks to pre-push-gate.sh (checks 25-33). Add fast-mode
detection for docs/shell/learning file categories so new checks only run
when relevant files change.

Also fix shellcheck warnings in task-validation-gate.sh (SC2053 glob
directives) and remove unused error_msg in watch-codex-stream.sh.
2026-03-31 15:19:50 -04:00
Test e0d4a8a55d feat: add headless Claude team backend 2026-03-09 13:34:36 -04:00
Test b3b49d443e fix(post-mortem): preserve durable pre-commit closure proof 2026-03-09 12:07:32 -04:00
Test 40237c2b72 fix(post-mortem): harden closure audit follow-ups 2026-03-09 11:00:51 -04:00
Test d93d34a9c6 feat(post-mortem): add staged and worktree closure evidence 2026-03-09 10:00:16 -04:00
Test ec3a87df01 Complete ae591e7c follow-up batch 2026-03-08 21:40:47 -04:00
Boden Fuller 744bcabeb9 chore(cli,ci,docs): tech debt swarm — 10 fixes across scripts, hooks, CI, docs
- Fix hardcoded /tmp path in test-json-flag-consistency.sh (use mktemp)
- Add graceful skip for missing jq/python3 in check-contract-compatibility.sh
- Fix import grouping in maturity_test.go
- Update .agents/retros/ → .agents/learnings/ in ratchet gate.go
- Extract _validate_restricted_cmd to lib/hook-helpers.sh (shared lib)
- Wire test-json-flag-consistency.sh into CI (new validate.yml job)
- Add post-merge naming cleanup step to swarm local-mode.md
- Document operationalization heuristics in plan SKILL.md
- Create check-file-manifest-overlap.sh for pre-spawn conflict detection
- Wire file manifest overlap check into CI with self-tests
- Pre-mortem fixes: bash 4+ guard, mktemp in CI self-tests
2026-03-05 13:12:54 -05:00
Boden Fuller 1234ff75a3 fix(hooks+cli): harvest remediation — 10 fixes across hooks, CLI, scripts (na-oh2)
Wave 1 — Hook hardening:
- research-loop-detector: early exit for neutral tools before git rev-parse
- commit-review-gate: capture git diff once (4→2 calls, TOCTOU fix)
- task-validation-gate: extract validate_restricted_cmd to hook-helpers.sh,
  pre-validate assertion regex, fix || && precedence bug
- session-start: clear .intent-echo-fired on new session
- go-vet-post-edit: assertion density → additionalContext JSON

Wave 2 — Go + scripts:
- inject_learnings: single-read + parseFrontmatterFromContent + atomicWriteFile
  (eliminates double-read race in applyConfidenceDecayMarkdown)
- rpi_phased: pass actual phaseStart time to handleBudgetTimeout
  (fixes time_boxed StartedAt/DurationSeconds inaccuracy)
- bootstrap-maturity.sh: add .jsonl support with jq maturity injection
- inject.go: add non-verbose quality gate summary to stderr
2026-03-03 18:07:04 -05:00
Boden Fuller 37d4b5b2ae Merge branch 'codex/rpi-supervisor-cli' into main 2026-02-21 19:41:50 -05:00