Skip to content

feat(setup): S2-bridge — guided-detect lib + auto-dispatch opt-in flip (one-click-installer) - #445

Merged
artyhoo merged 2 commits into
stagingfrom
worktree-oci-s2-bridge
Jun 10, 2026
Merged

feat(setup): S2-bridge — guided-detect lib + auto-dispatch opt-in flip (one-click-installer)#445
artyhoo merged 2 commits into
stagingfrom
worktree-oci-s2-bridge

Conversation

@artyhoo

@artyhoo artyhoo commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Summary

S2 sub-wave 3/3 of the one-click-installer umbrella (plan Task 4 + its kickoff §7 ⚠ prerequisite, after S1 #442). Two commits: (A) flips runtime-bridge auto-dispatch from opt-OUT to opt-IN per maintainer decision 2026-05-31 — the PostToolUse hook now dispatches ONLY kickoffs whose first line is <!-- bridge: auto -->; (B) adds the runtime-agnostic bridge guided-detect lib setup.d/bridge-guided.sh.

Design (cold-reviewed, 2 rounds): the gate lives in the hook only — packages/runtime-bridge/src/kickoff.ts untouched, so the manual tsx cli/dispatch.ts path (incl. bridge: skip semantics) that /dispatcher and /pipeline depend on keeps current behavior. Verified no other silent auto-dispatch path exists (settings.json:141 is the single hook wiring; consumers get the gated hook via setup-runtime-bridge.sh copy).

Changes

  • .claude/hooks/runtime-bridge-dispatch.sh — opt-IN gate after the -f guard (trimmed-exact first-line match, mirrors kickoff.ts:24-27; CRLF-safe); fix(pipeline): Stage 3 — suppress spurious aif auto-dispatch on meta-launch kickoffs (P4) #411 P4 meta-launch skip preserved.
  • New tests/hooks/runtime-bridge-dispatch-optin.test.sh — 3 cases: (a) unmarked kickoff → no dispatch, (b) marked → dispatches (positive control, tsx stubbed), (c) meta-launch+marker → still skipped (P4 regression guard). (a)/(b) share one path differing only in first line; pre-gate red phase pasted ((a) FAILED before the hook edit — negative arm proven non-vacuous, T-OCI-B).
  • .github/workflows/audit-self.yml — CI run-line for the new test (folder convention: tests/hooks/* enumerated individually).
  • Docs inverted opt-out→opt-in (bounded, package-local): runtime-bridge-setup.md, README.md, DESIGN.md, setup-runtime-bridge.sh say-text (+ stale-hook-copy refresh note for pre-flip consumers), dispatch.ts comments.
  • New setup.d/bridge-guided.sh + tests/install-sh/bridge-guided.test.sh — verbatim plan Task 4 (bridge_health_ok/bridge_diagnose/bridge_guided_run, health-first, never assumes docker). TDD red → green PASS=3.

Prior-art consult

  • No capability commit: Commit A edits existing files (new 94-LOC test is under tests/hooks/, outside packages/); Commit B's lib is outside packages/. No new deps.
  • No new capability area; no SSOT edits.

Test plan

  • bash tests/hooks/runtime-bridge-dispatch-optin.test.sh → PASS=3 FAIL=0 (+ pre-fix RED for case (a) pasted — worker verify-trace)
  • bash tests/install-sh/bridge-guided.test.sh → PASS=3 FAIL=0 (red phase pasted)
  • bash -n hook + lib → exit 0
  • runtime-bridge vitest: 134 passed | 1 skipped, 0 failed (exit-1 from a PRE-EXISTING unhandled error in aif-dispatch-dedup.test.ts importing dispatch.ts main(); proven pre-existing by control run on pristine staging worktree)
  • grep -rn 'bridge: auto' → marker present at all 7 documented sites
  • CI ci-success (runs on PR; includes the newly wired hook test)

§1.7 Self-discipline check (REQUIRED if PR touches discipline-bearing files)

§1.7 Skipped: operational hook behavior flip + lib + tests + doc inversions; no rules, principles, shipped templates or goal-bearing docs touched.

🟢 Простыми словами

Раньше написанный агентом kickoff-файл автоматически уходил в исполнение внешней системой (aif), если его явно не пометили «пропусти» — опасный дефолт: реальная автономная работа стартовала молча. Теперь наоборот: ничего не уходит само, пока первой строкой файла не написано «bridge: auto». Плюс добавлена библиотечка, которая перед установкой проверяет «жив ли мост» по health-запросу — неважно, в докере он или нет.

Observations (out of scope, follow-ups)

  • packages/runtime-bridge/test/runtime-bridge.test.ts:86-121 Test 1 stale-but-green since fix(pipeline): Stage 3 — suppress spurious aif auto-dispatch on meta-launch kickoffs (P4) #411 (asserts only exit-0); doubly stale post-flip — rewrite as negative arm or drop (follow-up).
  • Pre-existing vitest exit-1: aif-dispatch-dedup.test.ts import runs dispatch.ts main() without argv → unhandled rejection at dispatch.ts:185. Fix = argv/import.meta guard, separate PR.
  • docs/meta-factory/dispatcher-skill-rphase.md:17 could gain a one-liner about the hook-layer opt-in (R-phase record left untouched).
  • Task 5 (./setup) may want an installer-level reminder for consumers holding pre-flip hook copies.

artyhoo added 2 commits June 10, 2026 15:25
… marker (kickoff §7)

Maintainer decision 2026-05-31 (one-click-installer kickoff §7): auto-dispatch
is real, metered autonomous work — the PostToolUse hook must not fire on every
*/kickoff.md write (old opt-OUT footgun). Gate lives in the HOOK ONLY:
kickoff.ts `bridge: skip` semantics keep serving the manual dispatch.ts path
(/dispatcher, /pipeline) unchanged.

- .claude/hooks/runtime-bridge-dispatch.sh: after the file-exists guard, exit 0
  unless first line is exactly `<!-- bridge: auto -->` (trimmed match, mirrors
  kickoff.ts:24-27 skip-marker precedent). Path filters + #411 P4 meta-launch
  skip retained.
- tests/hooks/runtime-bridge-dispatch-optin.test.sh: paired-negative — (a)
  unmarked kickoff = no dispatch (RED before the gate: failed with
  DISPATCH-CALLED, proving non-vacuity), (b) marked = dispatch fires (positive
  control), (c) meta-launch + marker = still skipped (P4 regression guard).
  tsx stubbed via PATH-prepend; jq/node asserted to avoid vacuous pass.
- audit-self.yml: wire the test into principles-meta-tests job.
- Docs flipped opt-out → opt-in (runtime-bridge-setup.md, README.md, DESIGN.md,
  setup-runtime-bridge.sh say-text, dispatch.ts comments) + stale-hook-copy
  re-run note for consumers who installed before the flip.
Plan Task 4 (docs/superpowers/plans/2026-05-31-one-click-installer.md) verbatim:
setup.d/bridge-guided.sh exposes bridge_health_ok <url> (keys on /health —
succeeds whether aif runs in docker or natively), bridge_diagnose <url>
(up|docker|native|absent), and bridge_guided_run (diagnose → matching bring-up
advice → delegate our-side writes to the existing setup-runtime-bridge.sh).
Sourceable lib-only via BRIDGE_LIB_ONLY=1.

TDD: tests/install-sh/bridge-guided.test.sh RED with lib missing (PASS=1
FAIL=2) → GREEN PASS=3 FAIL=0.
@artyhoo
artyhoo enabled auto-merge (squash) June 10, 2026 12:33
@artyhoo
artyhoo merged commit f757b5a into staging Jun 10, 2026
23 checks passed
@artyhoo
artyhoo deleted the worktree-oci-s2-bridge branch June 10, 2026 12:42
artyhoo added a commit that referenced this pull request Jun 10, 2026
…equired at library layer (kickoff §7) (#446)

Completes the S2-bridge opt-in flip (#445). The hook gate shipped in #445
guards the PostToolUse path only; the stage dispatch (one-click-installer
kickoff §7, maintainer decision 2026-05-31) mandates the inversion in
kickoff.ts itself:

- buildKickoffSpec defaults to requireAutoMarker: true — the safe default
  for any future programmatic caller; an unmarked kickoff yields no spec.
- <!-- bridge: skip --> hard-blocks every path; nothing overrides it.
- cli/dispatch.ts is the ONE explicit opt-out ({ requireAutoMarker: false }):
  the manual on-demand contract (/dispatcher, /pipeline, operators) stays
  unchanged per §7 «everything else stays manual».
- Test 5 converted to the opt-in contract: (a) unmarked → null
  (paired-negative), (b) auto marker → spec, (c) skip → null on every path,
  (d) manual-path opt-out → spec.

Prior-art: skipped — default inversion within existing runtime-bridge capability, no new capability.
artyhoo added a commit that referenced this pull request Jun 10, 2026
…ring (one-click-installer S5) (#452)

SCOPE 1: setup.d/bridge-guided.sh:32 had two bugs in the state=up branch:
(a) bare relative path to setup-runtime-bridge.sh broke when cwd != repo
root (lib is sourced, so $0 is the caller); (b) consumers installed via
install.sh have no packages/runtime-bridge/ at all -> unconditional fail.
Fix (Option C, dual-implementation §3 graceful degrade): resolve root via
BASH_SOURCE, run the script by absolute path when present (framework
repo), else print a docs/runtime-bridge-setup.md pointer and return 0.
Paired-negative (script absent) + positive (script present, cwd=/tmp)
cases added to tests/install-sh/bridge-guided.test.sh; falsifier
verified: new cases FAIL=3 against the old lib code.

SCOPE 2: .github/workflows/audit-self.yml — wire the 5 install-sh tests
from S1-S3 (#443-#447) as per-file steps in principles-meta-tests, after
the runtime-bridge opt-IN gate step (convention from #445).
transform-internal-refs.test.sh was already wired; not duplicated.

Plan Task 9 verification: full install-sh suite green (6 files, all
FAIL=0), e2e dry-run in /tmp throwaway wrote nothing, shellcheck clean
(2 pre-existing SC2317 info on the lib-only sentinel pattern, intended).

Prior-art: skipped — graceful-fallback fix + CI wiring + verification, no new capability (./setup shipped S3, spec §11).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant