@sabaiway/agent-workflow-kit 22.2.0 → 23.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +49 -1
  2. package/README.md +1 -1
  3. package/SKILL.md +1 -1
  4. package/bridges/antigravity-cli-bridge/SKILL.md +11 -10
  5. package/bridges/antigravity-cli-bridge/bin/agy-jev.test.mjs +56 -7
  6. package/bridges/antigravity-cli-bridge/bin/agy-review.sh +81 -63
  7. package/bridges/antigravity-cli-bridge/bin/agy-review.test.mjs +0 -21
  8. package/bridges/antigravity-cli-bridge/bin/agy.sh +86 -12
  9. package/bridges/antigravity-cli-bridge/capability.json +4 -5
  10. package/bridges/antigravity-cli-bridge/references/models-and-flags.md +3 -3
  11. package/bridges/antigravity-cli-bridge/service-facts.txt +11 -0
  12. package/bridges/antigravity-cli-bridge/setup/README.md +1 -1
  13. package/bridges/codex-cli-bridge/SKILL.md +23 -24
  14. package/bridges/codex-cli-bridge/bin/codex-exec-jev.test.mjs +82 -47
  15. package/bridges/codex-cli-bridge/bin/codex-exec.sh +133 -52
  16. package/bridges/codex-cli-bridge/bin/codex-review-jev.test.mjs +44 -14
  17. package/bridges/codex-cli-bridge/bin/codex-review.sh +103 -30
  18. package/bridges/codex-cli-bridge/capability.json +7 -8
  19. package/bridges/codex-cli-bridge/references/driving-codex.md +6 -7
  20. package/bridges/codex-cli-bridge/references/sandbox-and-flags.md +8 -11
  21. package/bridges/codex-cli-bridge/service-facts.txt +9 -0
  22. package/bridges/codex-cli-bridge/setup/README.md +3 -3
  23. package/capability.json +1 -1
  24. package/package.json +1 -1
  25. package/references/modes/recommendations.md +3 -3
  26. package/references/modes/velocity.md +1 -1
  27. package/tools/bridge-sandbox-recipe.mjs +9 -6
  28. package/tools/bridge-state-dirs.mjs +2 -2
  29. package/tools/detect-backends.mjs +23 -15
  30. package/tools/manifest/schema.md +28 -47
  31. package/tools/manifest/validate.mjs +22 -60
  32. package/tools/procedures.mjs +1 -1
  33. package/tools/services/antigravity.json +17 -0
  34. package/tools/services/codex.json +15 -0
  35. package/tools/services/index.mjs +127 -0
  36. package/tools/services/jev.json +12 -0
@@ -30,7 +30,7 @@ The **consent route** for a harness item: run its `check:` line in the sandbox a
30
30
 
31
31
  A variant's posture note, where its key has one, is printed by `init` from this installed mode doc (the one source); a variant without a note shows its preview, and a harness variant also the check's lines.
32
32
 
33
- - `bridge-tier` — the lane is harness and env-dependent: the agent applies the item on the chat yes after the check, writing the project `.claude/settings.json`; `init` previews `velocity-profile --bridge-tier` and applies it on the terminal y as the route the user may take instead. It wires the USED bridges from the project's effective recipes and host readiness: each used review wrapper's `code`-mode allow rule (a wrapper then runs UNATTENDED: it reads any repo file it is pointed at and sends the assembled payload to its subscription backend), the quoted grounding pre-step rule when `agy-review` is used, `codex-review *` / `agy-review *` in `sandbox.excludedCommands`, and `codex-exec *` where an execute slot delegates (no execution allow rule: it keeps its prompt). It also seeds the used bridges' declared hosts (`networkHosts`) in `sandbox.network.allowedDomains` and resolved state dirs (`writableDirs`), home-relative where under home, in `sandbox.filesystem.allowWrite`. Where the host honours the settings sandbox keys, an excluded wrapper runs outside the sandbox, every sandboxed command of the project can reach the seeded hosts, and every sandboxed command can write the seeded state dirs. The item fires while an allow rule, a `*` exclusion, a host or a state dir of a used bridge is missing. Its `recipe:` line names each missing entry by kind (allow rules, exclusions, hosts, state dirs), then what the execution wrapper `codex-exec` needs where an execute slot delegates, then, when the project settings enable the sandbox, "once added, wired where the host honors the settings sandbox keys", or "host condition unchecked" with the reason.
33
+ - `bridge-tier` — the lane is harness and env-dependent: the agent applies the item on the chat yes after the check, writing the project `.claude/settings.json`; `init` previews `velocity-profile --bridge-tier` and applies it on the terminal y as the route the user may take instead. It wires the USED bridges from the project's effective recipes and host readiness: each used review wrapper's `code`-mode allow rule (a wrapper then runs UNATTENDED: it reads any repo file it is pointed at and sends the assembled payload to its subscription backend), the quoted grounding pre-step rule when `agy-review` is used, `codex-review *` / `agy-review *` in `sandbox.excludedCommands`, and `codex-exec *` where an execute slot delegates (no execution allow rule: it keeps its prompt). It also seeds the used bridges' hosts in `sandbox.network.allowedDomains` and resolved state dirs, home-relative where under home, in `sandbox.filesystem.allowWrite`; both come from the kit service fragments (`agent-workflow-kit/tools/services/`) their manifests name in `services`. Where the host honours the settings sandbox keys, an excluded wrapper runs outside the sandbox, every sandboxed command of the project can reach the seeded hosts, and every sandboxed command can write the seeded state dirs. The item fires while an allow rule, a `*` exclusion, a host or a state dir of a used bridge is missing. Its `recipe:` line names each missing entry by kind (allow rules, exclusions, hosts, state dirs), then what the execution wrapper `codex-exec` needs where an execute slot delegates, then, when the project settings enable the sandbox, "once added, wired where the host honors the settings sandbox keys", or "host condition unchecked" with the reason.
34
34
 
35
35
  - `read-lane` — enabling the opt-in read-only compound lane auto-approves *compounds* (and singles) of the seeded read-only core that carry ZERO shell metaprogramming: an UNATTENDED trust extension, bounded by the audited read-only core (never a command outside it; prompt-bypass only, never a sandbox bypass) and applied regardless of which of those core commands you seeded as individual settings rules. It is a PROJECT-PERSISTENT declaration in `docs/ai/lanes.json` — every future session, subagents' Bash too where the host fires hooks on subagent Bash, and (committed) every checkout. The item renders while the hook is wired and the lane is off, whatever the placed hook's bytes; its apply is the `gate-hook --read-lane` preview, whose own currency check refuses a stale hook (a pre-1.48 hook never reads `lanes.json`). A stale or absent hook under it is a planned file of the kit item `gate-hook.not-current`, applied before the offers. The agent applies the enable offer on the chat yes, and the kit item with no question after the check; `init` applies that kit item on its one y as the route the user may take instead. Risk profile: a bounded read-only trust-posture extension — no write/exec exposure beyond the audited core.
36
36
  - `worktrees-dir` — the agent applies the item on the chat yes after the check: one `sandbox.filesystem.allowWrite` entry naming the worktrees parent itself, written to this copy's `.claude/settings.local.json` only, never the committed project settings, the parent created when missing. `init` applies it on the batch terminal yes as the route the user may take instead. Where the host honors the key, the entry widens the OS-sandbox WRITE surface to the whole parent dir: every sibling path under it (other repositories included) becomes agent-writable, for every later session and every worktree provisioned afterwards. Narrow it BEFORE the first apply: point `docs/ai/worktrees.json` `parentDir` at a dedicated dir — no apply removes an entry, so an earlier one stays until the user deletes it. A parent that is the home or holds it renders `worktrees-dir.home` instead, the user's own step. **Convergence** is two-path: a declared `sandbox.filesystem.allowWrite` entry covering the probed dir (either settings scope — `~` and `~/…` resolve against home, and coverage is path-segment-aware, so a grant on a sibling or on a child never counts), or the dir-bound acknowledgement `worktreesDirAck` in the family-owned `docs/ai/acks.json`, recorded by the `ack-write --lane worktrees-dir` line the `recipe:` line carries — the ack fallback for a host that ignores the key, run only on the user's word, instead of the grant; against a trusted host NO no ack renders. Neither is proof of write CAPABILITY: the provision preflight's real create+delete probe stays the runtime truth, and the ack is bound to the **resolved probe dir**, so the item re-fires only when that resolved dir changes. Risk profile: a real write-surface widening where honored — scope it deliberately.
@@ -57,8 +57,8 @@ Only Claude Code on Linux/WSL2 is measured; Codex, Devin and agy as hosts and ma
57
57
  A first session may meet ordinary prompts until the autonomy render lands; a chat apply is promptless only where the host auto-allows sandboxed commands.
58
58
 
59
59
  - **Settings-native sandbox** (the harness reads the `.claude/settings.json` sandbox keys): where the harness honours the `--bridge-tier` wiring's `excludedCommands` entries (`codex-review *` / `agy-review *`, and `codex-exec *` where an execute slot delegates, keeping its prompt), the used bridges' wrappers run OUTSIDE the sandbox and never consult `allowedDomains`/`allowWrite` — nothing beyond the tier. A bare name matches only the argument-free command: observed 2026-10-06, Claude Code 2.1.291 ran an agent's plain `codex-review` inside its sandbox beside the bare entry; a harness may keep a `*`-excluded wrapper sandboxed too (unmeasured). There a recipe host outside `allowedDomains` is refused by the harness proxy or held for a network prompt (a refusal reads `Tunnel connection failed: 403` or `CONNECT tunnel failed, response 403` in the run). The lane for the hosts AND the state dirs is the `--bridge-tier` re-run: it seeds the used bridges' declared hosts into `sandbox.network.allowedDomains` and resolved state dirs into `sandbox.filesystem.allowWrite`, and the `bridge-tier` item offers it while any used-bridge surface is missing. Where the host honours the settings sandbox keys, every sandboxed command of the project can reach those hosts and every sandboxed command can write those state dirs.
60
- - **Harness-managed sandbox** (an IDE/session-imposed sandbox that ignores the settings keys) — a NARROWEST-SCOPE ladder: (1) prefer wrapper/command-SCOPED sandbox rules where the harness offers them (only the review wrappers gain the egress + state-dir writes); (2) a SESSION-scoped allowance (the manifest hosts + the resolved state dirs for the whole session) is an INFORMED WIDENING — it carries the same blast-radius class the `--bridge-tier` keys carry where a host honours them (every sandboxed command in the session gains that egress and write access to those state dirs), acceptable only as the maintainer's deliberate choice for a review-heavy session. (3) Else the per-run consented bypass. The kit writes no shape for this sandbox — the harness's own controls (its scoped rules, a session allowance, its consent at the point of action) govern there; an IDE-managed session sandbox was live-observed (2026-07-11/12) ignoring the settings security keys in BOTH scopes, and whether a session's sandbox honours them is not knowable from the advisor.
61
- - Either way the recipe is **observed-minimal, honestly incomplete** — a blocked host names itself at run time; the manifests record what was observed.
60
+ - **Harness-managed sandbox** (an IDE/session-imposed sandbox that ignores the settings keys) — a NARROWEST-SCOPE ladder: (1) prefer wrapper/command-SCOPED sandbox rules where the harness offers them (only the review wrappers gain the egress + state-dir writes); (2) a SESSION-scoped allowance (the hosts of the services the manifests name + the resolved state dirs for the whole session) is an INFORMED WIDENING — it carries the same blast-radius class the `--bridge-tier` keys carry where a host honours them (every sandboxed command in the session gains that egress and write access to those state dirs), acceptable only as the maintainer's deliberate choice for a review-heavy session. (3) Else the per-run consented bypass. The kit writes no shape for this sandbox — the harness's own controls (its scoped rules, a session allowance, its consent at the point of action) govern there; an IDE-managed session sandbox was live-observed (2026-07-11/12) ignoring the settings security keys in BOTH scopes, and whether a session's sandbox honours them is not knowable from the advisor.
61
+ - Either way the recipe is **observed-minimal, honestly incomplete** — a blocked host names itself at run time; the service fragments (`agent-workflow-kit/tools/services/`) record what was observed.
62
62
 
63
63
  **Invariants:** read-only (never writes, never commits, never runs a subscription CLI) · `--cwd` required · present-even-when-empty · verdict-first from frozen templates · probe failures degrade to stated skip lines · chat apply one-liners are cwd-independent (absolute tool paths + a pinned `--cwd`; the ONE exception is the `set-autonomy` item, a conversational skill invocation explicitly labeled *run IN the target project*) · the bare `sandbox-provision` item is the user's own step, pinned via a `cd <root> &&` prefix — the doctor reads its cwd · harness items carry a check and an apply bound to its digest; user items, including `family-freshness`, carry the user's own step · the used bridges' `sandbox.filesystem.allowWrite` and `sandbox.network.allowedDomains` are seeded only by the consented `velocity-profile --bridge-tier`; the worktrees grant is seeded into the local settings by the consented `velocity-profile --worktrees` · the `worktrees-dir` item converges on a declared `allowWrite` entry covering its probed dir in either scope, or on its `worktreesDirAck` in `docs/ai/acks.json`, recorded by the `ack-write` line its `recipe:` line carries, not by its apply line.
64
64
 
@@ -49,7 +49,7 @@ Honesty notes: tier entries get **NO PreToolUse-hook residual coverage — with
49
49
 
50
50
  **The boundary of that qualifier, stated so it is not guessed.** It covers claims about `sandbox.*` keys — the block whose honouring was observed to vary by host. It deliberately does NOT cover `permissions.*` semantics (an allow rule auto-approving a command, `local > project` precedence for a non-sandbox key): that is the harness's own documented permission model, the layer this whole mode rests on, and hedging it would say nothing true. **Stated residual:** which sentences count as settings-derived runtime claims is decided by review, not by a checker — deciding whether a sentence asserts a runtime effect is a question about prose meaning, and this family deliberately has no mechanism that judges that (the same limit that retired the byte-scanning deny rung). A new claim-bearing line therefore has to carry the qualifier by authorship; the acceptance criterion is that every line stating what a `sandbox.*` key DOES carries it, and the tests pin the surfaces that exist today. What does NOT change is the CLASSIFICATION: which red-line a key would weaken, and that a proven bridge-tier exclusion is a note rather than a weakening, are properties of the declaration and stay flat statements.
51
51
 
52
- **The `--bridge-tier` (own opt-in, AD-044).** Seeds the USED bridges from every recipe's review and execute slots in `docs/ai/orchestration.json`, resolved over host readiness to the effective recipe: a degraded recipe uses its resolved providers; an absent config takes the computed default. A bridge no slot uses gets nothing. Per used review role it seeds `Bash(<wrapper> code:*)` into `permissions.allow` and, with agy-review used, the quoted grounding pre-step rule. Per used role it seeds `<wrapper> *` into `sandbox.excludedCommands`, the manifest's `networkHosts` into `sandbox.network.allowedDomains`, and its resolved `writableDirs` into `sandbox.filesystem.allowWrite`, home-relative under the home and absolute outside it, with env overrides honoured. All entries land in the **project** `.claude/settings.json`, preserving existing entries and sibling keys. **Where the host honors the settings sandbox keys**, an exclusion means the wrapper runs outside the sandbox; a host means every sandboxed command of the project can reach it; a dir means every sandboxed command can write it — each widening is part of this consent. A session-imposed sandbox may ignore those keys; its lane is in `${CLAUDE_SKILL_DIR}/references/modes/recommendations.md`. An exclusion placed only in `settings.local.json` was live-observed NOT to route the command outside the sandbox (2026-07-11: the wrapper then starts sandboxed and dies on a read-only HOME), so hand-wiring the local file is no substitute for this tier. Under a harness-managed session sandbox (live-observed 2026-07-11/12) an IDE-managed sandbox ignores `sandbox.network.allowedDomains` and `sandbox.filesystem.allowWrite` in BOTH settings scopes — its own per-host consents govern egress, and the durable lanes there are the session sandbox config (the hosts plus the CLI state-dir writes) or the per-run consented bypass. Each bridge's observed egress hosts are declared in its `capability.json` `networkHosts` — the single documentation source (this doc retypes no host list); an apex domain is NOT covered by its `*.`-wildcard form, so the manifests carry both forms where observed. The upgrade Recommendations advisor's `bridge-tier` item offers this tier while any used-bridge surface is missing, its `recipe:` line naming each missing entry; an acknowledgement the retired session-sandbox-recipe item recorded in `docs/ai/acks.json` is never read, relabelled or removed — it keeps the meaning "seen". **Bare-entry reading (measured 2026-10-06):** an exclusion uses Bash rule syntax; a bare name matches only the argument-free command, so the tier writes the form with ` *`; an earlier bare entry stays and does not satisfy that surface. Where an execute slot delegates, codex-exec gets its exclusion, hosts and state dirs, but no allow rule, so a delegated run keeps its prompt. Only the code review mode is auto-allowed; plan/diff keep their prompt. The grounding rule uses the double-quoted absolute kit path the procedures advisor renders; an unseedable path is a stated skip. Its writer guard accepts only system-temp scratch or a fresh gitignored in-repo destination, refusing tracked, non-ignored, existing in-repo, outside-repo non-temp and symlink/non-regular destinations. The seeded byte-forms (this list IS the documented-invocation source for the bridge tier):
52
+ **The `--bridge-tier` (own opt-in, AD-044).** Seeds the USED bridges from every recipe's review and execute slots in `docs/ai/orchestration.json`, resolved over host readiness to the effective recipe: a degraded recipe uses its resolved providers; an absent config takes the computed default. A bridge no slot uses gets nothing. Per used review role it seeds `Bash(<wrapper> code:*)` into `permissions.allow` and, with agy-review used, the quoted grounding pre-step rule. Per used role it seeds `<wrapper> *` and the excluded commands of the services its manifest names into `sandbox.excludedCommands`, those services' hosts into `sandbox.network.allowedDomains`, and their resolved state dirs into `sandbox.filesystem.allowWrite`, home-relative under the home and absolute outside it, with env overrides honoured. All entries land in the **project** `.claude/settings.json`, preserving existing entries and sibling keys. **Where the host honors the settings sandbox keys**, an exclusion means the wrapper runs outside the sandbox; a host means every sandboxed command of the project can reach it; a dir means every sandboxed command can write it — each widening is part of this consent. A session-imposed sandbox may ignore those keys; its lane is in `${CLAUDE_SKILL_DIR}/references/modes/recommendations.md`. An exclusion placed only in `settings.local.json` was live-observed NOT to route the command outside the sandbox (2026-07-11: the wrapper then starts sandboxed and dies on a read-only HOME), so hand-wiring the local file is no substitute for this tier. Under a harness-managed session sandbox (live-observed 2026-07-11/12) an IDE-managed sandbox ignores `sandbox.network.allowedDomains` and `sandbox.filesystem.allowWrite` in BOTH settings scopes — its own per-host consents govern egress, and the durable lanes there are the session sandbox config (the hosts plus the CLI state-dir writes) or the per-run consented bypass. Each bridge's observed egress hosts come from the kit service fragments (`agent-workflow-kit/tools/services/`) its `capability.json` names in `services` — the single documentation source (this doc retypes no host list); an apex domain is NOT covered by its `*.`-wildcard form, so the fragments carry both forms where observed. The upgrade Recommendations advisor's `bridge-tier` item offers this tier while any used-bridge surface is missing, its `recipe:` line naming each missing entry; an acknowledgement the retired session-sandbox-recipe item recorded in `docs/ai/acks.json` is never read, relabelled or removed — it keeps the meaning "seen". **Bare-entry reading (measured 2026-10-06):** an exclusion uses Bash rule syntax; a bare name matches only the argument-free command, so the tier writes the form with ` *`; an earlier bare entry stays and does not satisfy that surface. Where an execute slot delegates, codex-exec gets its exclusion, hosts and state dirs, but no allow rule, so a delegated run keeps its prompt. Only the code review mode is auto-allowed; plan/diff keep their prompt. The grounding rule uses the double-quoted absolute kit path the procedures advisor renders; an unseedable path is a stated skip. Its writer guard accepts only system-temp scratch or a fresh gitignored in-repo destination, refusing tracked, non-ignored, existing in-repo, outside-repo non-temp and symlink/non-regular destinations. The seeded byte-forms (this list IS the documented-invocation source for the bridge tier):
53
53
 
54
54
  - `Bash(codex-review code:*)` — the review code-mode allow rule; `codex-review *` — its sandbox.excludedCommands entry.
55
55
  - `Bash(agy-review code:*)` — the review code-mode allow rule; `agy-review *` — its sandbox.excludedCommands entry; `Bash(node "${CLAUDE_SKILL_DIR}/tools/grounding.mjs":*)` — its quoted grounding pre-step rule.
@@ -1,4 +1,5 @@
1
- // bridge-sandbox-recipe.mjs — the one reader of the bundled bridges' declared sandbox surfaces and
1
+ // bridge-sandbox-recipe.mjs — the one reader of the bundled bridges' sandbox surfaces (their roles and
2
+ // the kit service fragments their manifests name, spec kit/services) and
2
3
  // the one derivation of the bridge tier (contract: bridges/velocity-profile, revision 4). The tier
3
4
  // writer, the advisor's delta, the danger check and the autonomy preview read the same
4
5
  // `bundledSandboxRecipe(usedBridges(...))`, so the four cannot drift.
@@ -13,6 +14,7 @@ import { ACTIVITIES, BACKEND_PRIORITY, REVIEW_CMD_ALIASES } from './carriers.mjs
13
14
  import { planRecipe, resolveActivityRecipe } from './recipes.mjs';
14
15
  import { isReadyMember } from './review-roster-resolve.mjs';
15
16
  import { isSeedablePathToken } from './repo-lex.mjs';
17
+ import { loadServiceFragments, mergeServices } from './services/index.mjs';
16
18
 
17
19
  // The review wrappers, spelled bare as invoked. Only their `code` mode is auto-allowed: a bare
18
20
  // `Bash(<wrapper>:*)` prefix would also cover the plan/diff file-argument modes, whose targets can
@@ -80,6 +82,7 @@ export const bundledSandboxRecipe = (used, deps = {}) => {
80
82
  const readFile = deps.readFile ?? readFileSync;
81
83
  const readDir = deps.readdir ?? readdirSync;
82
84
  const bundleRoot = deps.bundleRoot ?? DEFAULT_BUNDLE_ROOT;
85
+ const fragments = loadServiceFragments({ servicesDir: deps.servicesDir });
83
86
  const allow = [];
84
87
  const excludedCommands = [];
85
88
  const hosts = [];
@@ -116,11 +119,11 @@ export const bundledSandboxRecipe = (used, deps = {}) => {
116
119
  });
117
120
  }
118
121
  }
119
- if (Array.isArray(manifest.networkHosts)) for (const host of manifest.networkHosts) pushOnce(hosts, host);
120
- if (Array.isArray(manifest.writableDirs)) {
121
- for (const entry of manifest.writableDirs) {
122
- if (!dirEntries.some((taken) => JSON.stringify(taken) === JSON.stringify(entry))) dirEntries.push(entry);
123
- }
122
+ const services = mergeServices(manifest.services ?? [], fragments);
123
+ for (const command of services.excludedCommands) pushOnce(excludedCommands, command);
124
+ for (const host of services.hosts) pushOnce(hosts, host);
125
+ for (const entry of services.dirEntries) {
126
+ if (!dirEntries.some((taken) => JSON.stringify(taken) === JSON.stringify(entry))) dirEntries.push(entry);
124
127
  }
125
128
  }
126
129
  return { allow, excludedCommands, hosts, dirEntries, skips };
@@ -1,5 +1,5 @@
1
- // bridge-state-dirs.mjs — the one leaf that turns the bundled bridges' declared writable state dirs
2
- // (`writableDirs`) into `sandbox.filesystem.allowWrite` entries (contract: bridges/velocity-profile).
1
+ // bridge-state-dirs.mjs — the one leaf that turns kit service fragments' state dir entries, through
2
+ // mergeServices (spec kit/services), into `sandbox.filesystem.allowWrite` entries (contract: bridges/velocity-profile).
3
3
  // The bridge tier writes them, the advisor counts them, the danger check admits them, the autonomy
4
4
  // preview names them: one resolution, one home-relative spelling, one merge, so the four cannot drift.
5
5
  //
@@ -23,6 +23,7 @@ import { existsSync, statSync, accessSync, realpathSync, constants } from 'node:
23
23
  import { join } from 'node:path';
24
24
  import os from 'node:os';
25
25
  import { isDirectRun } from './direct-run.mjs';
26
+ import { loadServiceFragments } from './services/index.mjs';
26
27
  import { validateManifest, UNSUPPORTED, INVALID } from './manifest/validate.mjs';
27
28
 
28
29
  // Probe states. `unknown` (a wrapped fs error) NEVER counts as present in any readiness rule.
@@ -50,7 +51,7 @@ const EXPECTED_KIND = 'execution-backend';
50
51
 
51
52
  // The kit-owned registry: the per-backend facts the detector needs even when a bridge is NOT
52
53
  // installed (no manifest on disk to read). Kept in lockstep with the in-repo manifests by the
53
- // drift-guard test. `credential.env: null` → no env override exists (do not invent one).
54
+ // drift-guard test. Credential directories come from the named service fragment.
54
55
  // `roleCmds` is the role-keyed source of truth (role → the PATH wrapper cmd), mirroring each bridge
55
56
  // manifest `roles[role].cmd`, drift-guarded. Two derivations ride on it, both drift-guarded against the
56
57
  // manifests: `wrapperCmds` (the deduped set the readiness probe checks — a stale install missing one
@@ -85,7 +86,7 @@ const RAW_BACKENDS = [
85
86
  'nested-sandbox limit: codex-exec ships its OWN OS sandbox (bwrap workspace-write) and cannot run nested inside a harness sandbox (the FS turns read-only) — route it OUTSIDE the harness sandbox (excludedCommands / a per-run consented bypass) on the OBSERVED bwrap/EPERM failure, never a preemptive blanket',
86
87
  'exec posture banner: ONE stderr line before dispatch states the ACTUAL run posture — exec posture: model=… effort=… tier=… sandbox=jev-profile|workspace-write session=fresh|resume:<id> jev=… source=… timeout=… — from RESOLVED post-validation values; the resume id is validated pre-spend, control bytes in a model, effort, tier or timeout value refuse pre-spend, and a jev= reason shows a control byte as ?',
87
88
  'threat model: the sidecar byte and grammar screens detect corrupted input under a trusted parent environment. A hostile parent environment — including exported shell functions or PATH substitution of core/backend commands — is outside the threat model and can substitute the backend itself. Targeted shadow-proof resolution protects banner/dispatch honesty from accidental shadowing; it is not an environment security boundary',
88
- "the exec posture banner states what the run reaches in a jev= field: jev=api.typesafe.ai,docs.typesafe.ai when the run carries the permissions profile `jev` (Linux, codex-cli 0.160.0 or newer, a repository outside every temp root, a version and profile digest not recorded as refused), else jev=unreachable (<reason>) on today's workspace-write flags with network off; a run whose codex refuses the profile exits 72 with no success receipt and, for a refused profile key, records its version and digest when the state file can be written, so the next run on them takes today's flags; then a banner-only source=model:<s>,effort:<s> field — where each value came from: default, setting or environment — then a banner-only timeout=<duration|uncapped> field — exactly the duration handed to timeout(1), uncapped when no timeout/gtimeout binary caps the run; INFORMATIONAL only: none of the three is persisted in a receipt or session sidecar",
89
+ "the exec posture banner states what the run reaches in a jev= field: the run hosts its service-facts.txt lists when the run carries the permissions profile `jev` (Linux, codex-cli 0.160.0 or newer, a repository outside every temp root, a version and profile digest not recorded as refused), else jev=unreachable (<reason>) on today's workspace-write flags with network off; a run whose codex refuses the profile exits 72 with no success receipt and, for a refused profile key, records its version and digest when the state file can be written, so the next run on them takes today's flags; then a banner-only source=model:<s>,effort:<s> field — where each value came from: default, setting or environment — then a banner-only timeout=<duration|uncapped> field — exactly the duration handed to timeout(1), uncapped when no timeout/gtimeout binary caps the run; INFORMATIONAL only: none of the three is persisted in a receipt or session sidecar",
89
90
  'quote the posture banner verbatim when labeling this dispatch — the banner is the machine-stated posture; a prose re-type drifts',
90
91
  'every-run nested-sandbox scan (DUAL policy, deliberately two different rules): the scan runs on EVERY completed run, not only a failed one, because a run that SURVIVES the nested-sandbox failure exits 0 with an ungrounded answer and nothing said so. Failed run (rc != 0): the existing loose whole-trace combination rule prints the recovery hint. Successful run (rc == 0): a warning fires ONLY on precise per-item evidence — both a sandbox-mechanism token AND a permission/read-only failure token inside the aggregated_output of ONE command_execution item whose failure is PROVEN (a nonzero exit_code, or the serialized status "failed"); a null exit_code is never failure by itself, tokens split across two items never fire, and a successful command\'s output never fires. The answer is printed FIRST on stdout, then the warning on stderr. HONEST RESIDUAL: the exit status does NOT change on that lane (a distinct nonzero exit would give a heuristic scan DENY polarity, refusing real work whenever the scan over-warns), so an orchestrator keying on exit status alone can still bank an ungrounded answer — the stderr warning is the signal',
91
92
  ],
@@ -99,7 +100,7 @@ const RAW_BACKENDS = [
99
100
  continue: [],
100
101
  receipt: 'side effect — a successful review appends one JSON receipt line to <git dir>/agent-workflow-review-receipts.jsonl (AW_REVIEW_RECEIPTS overrides): fingerprint = sha256 over the canonical uncommitted-state payload (staged diff + unstaged diff + untracked-not-ignored contents — the review-payload domain; never-committable untracked paths — character/block devices, FIFOs, sockets — are excluded from the domain entirely, untracked symlinks/directories ride as name-only notes) in code mode, the artifact-file sha256 in plan mode; durationS = integer wall-clock seconds from CLI start through verdict parsing and the wrapper prints review duration: <n>s; blocking = the count of [blocker] and [major] lines (schema mode: findings with either severity; a payload whose findings cannot be counted fails the run, no receipt); artifactPath = the normalized realpath on plan receipts only (repo-relative inside the work tree, absolute otherwise), while a double quote, backslash or control byte refuses pre-spend because the receipt encoder cannot carry it; verdict parsed from the mandated literal verdict line (schema mode: the verdict field); always fresh:true (one-shot) + grounded:true (native AGENTS.md auto-merge, factsHash null); probe = whether the run relaxed the quality guards (CODEX_PROBE=1), written on EVERY receipt so it self-declares — the kit\'s review-state gate rejects a probe-marked receipt (a probe review never attests) and equally rejects an unmarked one (silence is not a declaration); posture = the ACTUAL run posture {model, effort, tier} (tier null on the standard tier), written on EVERY receipt (D5) — the gate rejects a receipt with an absent/invalid posture (a pre-D5 wrapper minted it; re-run the review), one stderr banner line states the same posture, and a posture value carrying control bytes refuses pre-spend in every mode; a run whose final message carries NO recognized \'Verdict: <ship|revise|rethink>\' line — empty or missing output included — exits 4 with NO receipt (D4: a FAILED review to RE-RUN, never a fatal session error); when the dispatch nonce seam is supplied — the AW_REVIEW_NONCE environment value or its plain-argument equivalent --nonce <n> (one seam: the flag assigns the same value; supplying both with different values refuses pre-spend) — under the safe grammar [A-Za-z0-9._-]{1,64} (anything else refuses pre-spend), the wrapper first mints the finding MANIFEST {schema, backend, nonce, fingerprint, findings} beside the receipts file (agent-workflow-finding-manifest-<backend>-<nonce>.json; atomic, no-clobber — a byte-identical rewrite is an idempotent no-op, different bytes refuse loudly) ORDERED before the receipt append — a failed manifest write EXCLUDES the receipt append, so a nonce-supplied dispatch can never land a receipt without its readable manifest; a nonce-less invocation adds NO nonce field and mints NO finding manifest (the existing wrapperVersion field still changes with each bridge release); a write failure warns, never fails the review',
101
102
  notes: [
102
- 'the review posture banner states what the run reaches in a jev= field: jev=api.typesafe.ai,docs.typesafe.ai when the run carries the read-only permissions profile `jev` (Linux, codex-cli 0.160.0 or newer, a version and profile digest not recorded as refused), else jev=unreachable (<reason>) under --sandbox read-only; a run whose codex refuses the profile exits 72 with no receipt; then a banner-only source=model:<s>,effort:<s> field — where each value came from: default, setting or environment — then a banner-only timeout=<duration> field — exactly the duration handed to timeout(1); the hard-timeout preflight fails CLOSED when no timeout/gtimeout binary exists (the wrapper refuses by name before any CLI run, so an uncapped review run can no longer happen), and none of the three fields enters the receipt posture or the D5 banner↔receipt parity',
103
+ 'the review posture banner states what the run reaches in a jev= field: the run hosts its service-facts.txt lists when the run carries the read-only permissions profile `jev` (Linux, codex-cli 0.160.0 or newer, a version and profile digest not recorded as refused), else jev=unreachable (<reason>) under --sandbox read-only; a run whose codex refuses the profile exits 72 with no receipt; then a banner-only source=model:<s>,effort:<s> field — where each value came from: default, setting or environment — then a banner-only timeout=<duration> field — exactly the duration handed to timeout(1); the hard-timeout preflight fails CLOSED when no timeout/gtimeout binary exists (the wrapper refuses by name before any CLI run, so an uncapped review run can no longer happen), and none of the three fields enters the receipt posture or the D5 banner↔receipt parity',
103
104
  'quote the posture banner verbatim when labeling this dispatch — the banner is the machine-stated posture; a prose re-type drifts',
104
105
  ],
105
106
  },
@@ -108,7 +109,7 @@ const RAW_BACKENDS = [
108
109
  // The per-backend receipt-deadline default (seconds) the capability block reports — the review
109
110
  // wrapper's built-in hard cap (CODEX_HARD_TIMEOUT review default), an OFFLINE registry fact.
110
111
  deadlineDefaultS: 1800,
111
- credential: { env: 'CODEX_HOME', default: '~/.codex', file: 'auth.json' },
112
+ credential: { service: 'codex', file: 'auth.json' },
112
113
  setupUrl: 'https://github.com/sabaiway/agent-workflow/blob/main/codex-cli-bridge/setup/README.md',
113
114
  setupPathLocal: 'setup/README.md',
114
115
  // The short canonical guided commands. Binary-install is platform-variant and longer, so it is
@@ -142,7 +143,7 @@ const RAW_BACKENDS = [
142
143
  receipt: "side effect — a successful review appends one JSON receipt line to <git dir>/agent-workflow-review-receipts.jsonl (AW_REVIEW_RECEIPTS overrides; plan/diff outside a git tree: warn + skip unless overridden): fingerprint = sha256 over the canonical uncommitted-state payload (staged diff + unstaged diff + untracked-not-ignored contents — the review-payload domain; never-committable untracked paths — character/block devices, FIFOs, sockets — are excluded from the domain entirely, untracked symlinks/directories ride as name-only notes) in code mode, the artifact-file sha256 in plan/diff mode; durationS = integer wall-clock seconds from CLI start through verdict parsing and the wrapper prints review duration: <n>s; blocking = the count of numbered items in the first ### Blocking section; artifactPath = the normalized realpath on plan/diff receipts only (repo-relative inside the work tree, absolute otherwise), while a double quote, backslash or control byte refuses pre-spend because the receipt encoder cannot carry it; verdict recorded verbatim from the mandated '### Verdict' section (SHIP / SHIP WITH NITS / REWORK); grounded = whether a NON-EMPTY --facts payload was supplied (code mode refuses pre-spend without one — no run, no receipt — unless --ungrounded/AGY_PROBE=1; in plan/diff an empty payload records grounded:false — fail-closed, the state gate rejects it), factsHash = sha256 of the facts payload; a continuation receipt is fresh:false (informational-only — it cannot attest the folded tree); probe = whether the run relaxed the quality guards (AGY_PROBE=1), written on EVERY receipt so it self-declares — the kit's review-state gate rejects a probe-marked receipt (a probe review never attests) and equally rejects an unmarked one (silence is not a declaration); posture = the ACTUAL run posture {model} (agy has no tier), written on EVERY receipt (D5) — the gate rejects a receipt with an absent/invalid posture (a pre-D5 wrapper minted it; re-run the review), one stderr banner line states the same posture, a one-off model (an explicitly empty AGY_MODEL included) refuses pre-spend unless AGY_PROBE=1, and a model string carrying control bytes refuses pre-spend in every mode; delivery = how the change set REACHED the model, currently emitted as 'inline' (the whole set rode one prompt — proven by construction) or 'fed' (a chunked feed whose per-part echo proof verified); REQUIRED on every agy code receipt and its ABSENCE is what stops a pre-fed-lane receipt attesting, while the gate accepts any well-formed declaration rather than a particular value; absent by construction on plan/diff/continuation receipts, which carry no change set; a run whose output carries NO recognized '### Verdict' section — empty output included — exits 4 with NO receipt (D4: a FAILED review to RE-RUN, never a fatal session error); when the dispatch nonce seam is supplied — the AW_REVIEW_NONCE environment value or its plain-argument equivalent --nonce <n> (one seam: the flag assigns the same value; supplying both with different values refuses pre-spend) — under the safe grammar [A-Za-z0-9._-]{1,64} (anything else refuses pre-spend), the wrapper first mints the finding MANIFEST {schema, backend, nonce, fingerprint, findings} beside the receipts file (agent-workflow-finding-manifest-<backend>-<nonce>.json; atomic, no-clobber — a byte-identical rewrite is an idempotent no-op, different bytes refuse loudly) ORDERED before the receipt append — a failed manifest write EXCLUDES the receipt append, so a nonce-supplied dispatch can never land a receipt without its readable manifest; a nonce-less invocation adds NO nonce field and mints NO finding manifest (the existing wrapperVersion field still changes with each bridge release); a write failure warns, never fails the review",
143
144
  notes: [
144
145
  'transport: every review dispatch drives the CLI in --output-format json (plus --disable-slash-commands) and the returned envelope is parsed in node (bin/agy-envelope.mjs) — the operator-facing invocations and flags above do NOT change, and on a ZERO exit the wrapper still PRINTS the review text, never JSON. A missing or unreadable envelope on a zero exit is a loud failure with NO receipt, never a downgraded verdict and never a fallback to raw-stdout parsing; a non-zero CLI exit keeps its own code and message, and publishes the captured stdout unchanged from the SINGLE dispatch or the FINAL fed turn (which may therefore be a JSON or partial payload — the envelope is parsed only on a zero exit); an INTERMEDIATE feed turn is the exception, its output stays private (Invariant E) and its failure prints only a named error. Enforced by a PRE-SPEND capability probe, not a version floor: agy --help must advertise --output-format and --disable-slash-commands, node must be >= 22, and bin/agy-envelope.mjs must be present — otherwise the review refuses before any run is spent and names the missing capability',
145
- 'pre-dispatch host-diff: before the FIRST dispatch of this bridge, diff its declared networkHosts against the live sandbox allow-list — a missing host is surfaced to the maintainer BEFORE dispatching, never fired into a known prompt',
146
+ 'pre-dispatch host-diff: before the FIRST dispatch of this bridge, diff the hosts of the services its manifest names against the live sandbox allow-list — a missing host is surfaced to the maintainer BEFORE dispatching, never fired into a known prompt',
146
147
  'the review posture banner appends a banner-only source=model:<s> field — where the model came from: default, setting or environment — then a banner-only timeout=<duration> field — exactly the duration agy-run hands to timeout(1); the hard-timeout preflight fails CLOSED when no timeout/gtimeout binary exists (the wrapper refuses by name before any CLI run, so an uncapped review run can no longer happen), and neither field enters the receipt posture or the D5 banner↔receipt parity',
147
148
  'quote the posture banner verbatim when labeling this dispatch — the banner is the machine-stated posture; a prose re-type drifts',
148
149
  ],
@@ -151,7 +152,7 @@ const RAW_BACKENDS = [
151
152
  bin: 'agy',
152
153
  // AGY_HARD_TIMEOUT's built-in review default is 30m — reported in seconds, an OFFLINE registry fact.
153
154
  deadlineDefaultS: 1800,
154
- credential: { env: null, default: '~/.gemini/antigravity-cli', file: 'antigravity-oauth-token' },
155
+ credential: { service: 'antigravity', file: 'antigravity-oauth-token' },
155
156
  setupUrl: 'https://github.com/sabaiway/agent-workflow/blob/main/antigravity-cli-bridge/setup/README.md',
156
157
  setupPathLocal: 'setup/README.md',
157
158
  guide: { setupRef: 'antigravity-cli-bridge/setup/README.md', loginCmd: 'agy', verifyCmd: 'echo "say OK" | agy-run -' },
@@ -263,13 +264,19 @@ const probeFile = (file, deps = {}) => {
263
264
  // "authed?" = existence of the credential-marker file (read-only). NEVER runs the subscription CLI.
264
265
  // Report wording is "credentials present/missing/unknown", never "authenticated".
265
266
  export const probeCredential = (entry, deps = {}) => {
266
- const dir = resolveDir(
267
- { env: entry.credential.env, default: entry.credential.default },
268
- deps.getenv ?? process.env,
269
- deps.home ?? os.homedir(),
270
- );
271
- const file = join(dir, entry.credential.file);
272
- return { state: probeFile(file, deps), path: file };
267
+ const service = entry.credential.service;
268
+ try {
269
+ const fragment = (deps.loadServiceFragments ?? loadServiceFragments)()?.[service];
270
+ if (!fragment) return { state: UNKNOWN, path: null, reason: `${service}: service fragment missing` };
271
+ if (!Array.isArray(fragment.writableDirs) || fragment.writableDirs.length !== 1) {
272
+ return { state: UNKNOWN, path: null, reason: `${service}: expected exactly one writableDirs entry` };
273
+ }
274
+ const dir = resolveDir(fragment.writableDirs[0], deps.getenv ?? process.env, deps.home ?? os.homedir());
275
+ const file = join(dir, entry.credential.file);
276
+ return { state: probeFile(file, deps), path: file };
277
+ } catch (error) {
278
+ return { state: UNKNOWN, path: null, reason: `${service}: ${error?.message ?? String(error)}` };
279
+ }
273
280
  };
274
281
 
275
282
  const computeReadiness = (manifestState, cli, credentials, wrappers) => {
@@ -348,7 +355,7 @@ export const detectBackend = (entry, deps = {}) => {
348
355
  manifestReason,
349
356
  skillDir: installed ? resolvedDir : null,
350
357
  cli: { bin: entry.bin, state: cliProbe.state, path: cliProbe.path ?? null },
351
- credentials: { state: credentials.state, path: credentials.path },
358
+ credentials: { state: credentials.state, path: credentials.path, ...(credentials.reason ? { reason: credentials.reason } : {}) },
352
359
  wrappers,
353
360
  readiness,
354
361
  setupHint,
@@ -384,7 +391,7 @@ export const guideFor = (status) => {
384
391
  if (status.credentials.state !== PRESENT) {
385
392
  out.push({
386
393
  need: 'credentials',
387
- hint: `sign in once (subscription): ${guide?.loginCmd ?? 'see the setup README'} (verify: ${guide?.verifyCmd ?? 'see the setup README'})`,
394
+ hint: status.credentials.reason ?? `sign in once (subscription): ${guide?.loginCmd ?? 'see the setup README'} (verify: ${guide?.verifyCmd ?? 'see the setup README'})`,
388
395
  });
389
396
  }
390
397
  return out;
@@ -400,6 +407,7 @@ const setupTarget = (s) => s.setupHint.local ?? s.setupHint.url;
400
407
  // Next-step hint per readiness. Deliberately never says "authenticated"/"authed" — only
401
408
  // "credentials present/missing" (detection is file-presence, not a live login check).
402
409
  const nextStep = (s) => {
410
+ if (s.credentials.reason) return s.credentials.reason;
403
411
  switch (s.readiness) {
404
412
  case READY:
405
413
  return null;
@@ -18,8 +18,7 @@ expansion), never via the shell. The validator is [`validate.mjs`](./validate.mj
18
18
  | `roles` | object | yes | keys ⊆ `provides`; see *Roles* |
19
19
  | `detect` | object | no | `installed` (skill on the machine) + `deployed` (substrate set up in cwd) |
20
20
  | `settings` | array | no | the bridge's **settings-file surface** (typed; see *Settings*). Unlike `contract`, a malformed entry **fails** `--strict`. |
21
- | `networkHosts` | string[] | no | the backend CLI's **observed egress host families** (see *Network hosts*). A malformed list **fails** `--strict`. |
22
- | `writableDirs` | object[] | no | the backend CLI's **writable state-dir declarations** — `{env, default}` entries (see *Writable dirs*). A malformed list **fails** `--strict`. |
21
+ | `services` | string[] | no | the ids of the kit service fragments the bridge uses — a non-empty list of unique ids (see *Services*); with it, `networkHosts` and `writableDirs` are refused. |
23
22
  | `modeCatalog` | object[] | no | the bridge's **user-facing operating modes** — what each mode is FOR and when to reach for it (see *Mode catalog*). A malformed block **fails** `--strict`. |
24
23
  | `install` / `uninstall` | object | no | `install.npm` is a package name, not a path |
25
24
  | `cost` / `quota` / `provenance` | misc | no | informational |
@@ -95,49 +94,31 @@ Wrappers never parse JSON at run time: each carries its own shell registry/valid
95
94
  drift-guarded set-equal to this block by the bridge `bin/*.test.mjs` suites (help section keys,
96
95
  `aw_settings_known` registry, `AW_SETTINGS_APPLIED` subset, `aw_settings_valid` typed arms).
97
96
 
98
- ## Network hosts (AD-044 Plan 4, consult-locked)
99
-
100
- `networkHosts` declares the hosts the backend CLI is **observed** to contact (synthetic examples:
101
- `*.api.backend.example`, `accounts.backend.example`; the real observed lists live in each bridge's
102
- `capability.json`) — the **single source** of the hosts `velocity-profile --bridge-tier` seeds
103
- into the project's `sandbox.network.allowedDomains` for every used bridge. Rules:
104
-
105
- - Each entry is a bare dotted hostname or a `*.family` wildcard — never a scheme/path/port.
106
- Entries must be unique. A malformed list **fails** `--strict` (the tier writes the entries into
107
- `sandbox.network.allowedDomains` and the Recommendations advisor renders them on its
108
- `bridge-tier` item's `recipe:` line).
109
- - **The `--bridge-tier` seed is the primary lane** (AD-172): for every used bridge it merges
110
- hosts into the project's `sandbox.network.allowedDomains` beside the wrapper's `<wrapper> *`
111
- exclusion (`codex-exec *` for the execution wrapper). A settings-native harness that drops the
112
- exclusion still admits them; that pre-allow widens egress
113
- for **every** sandboxed command, which the tier's consent states. A harness-managed sandbox
114
- that ignores the settings keys keeps the harness's own controls — its scoped rules, a session
115
- allowance, its consent at the point of action — and the kit writes no shape for it.
116
- - Observed-minimal, honestly incomplete: a blocked host names itself at run time — extend the
117
- manifest list where it was observed; the list records what was actually observed.
118
-
119
- ## Writable dirs (REC-UX-REWORK, D6)
120
-
121
- `writableDirs` declares the backend CLI's **writable state dirs** (credentials, session state) as
122
- `{env, default}` entries — a bare string cannot be truthful, because a wrapper resolves its state
123
- dir from an env override first (e.g. `CODEX_HOME` as `~`, `~/…`, absolute or relative), so the
124
- declared path is only the **default under no override**. Rules:
125
-
126
- - Each entry: `env` is `null` or an **UPPER_SNAKE_CASE env-var name**; `default` is a
127
- **`~/`-anchored or absolute POSIX path** — no globs, no trailing slash, no `..` traversal.
128
- Defaults must be unique. A malformed list **fails** `--strict` (the resolved dir is written into
129
- `sandbox.filesystem.allowWrite` and rendered on the Recommendations advisor's one-line `recipe:` line).
130
- - **Resolution is the advisor's, at run time, mirroring the wrapper's byte-semantics:** a
131
- NON-EMPTY env value wins (an EMPTY env value ≡ unset — the `${VAR:-default}` form); the
132
- wrapper's exact case-arms apply — `~`, `~/…` and absolute forms ride as-given, EVERY other
133
- form (including `~user/…`, which the wrappers never resolve as a home path) anchors like a
134
- relative path. The advisor anchors those to the **target project root** (its pinned `--cwd`),
135
- matching what a wrapper invoked from the project root resolves — the documented dispatch form
136
- (the wrapper itself anchors to its invocation `$PWD`); else the `default` applies.
137
- - **The `--bridge-tier` seeds every used bridge's state dirs**, home-relative under the home
138
- (absolute outside it), into `sandbox.filesystem.allowWrite` beside the wrapper's `<wrapper> *`
139
- exclusion (`codex-exec *` for the execution wrapper) — the advisor's `bridge-tier` item counts
140
- and names each missing dir.
97
+ ## Services
98
+
99
+ `services` names the kit service fragments under `agent-workflow-kit/tools/services/` that the
100
+ bridge uses. The module's `mergeServices` supplies their hosts, state dirs and excluded commands.
101
+ A fragment is a closed object of five required keys (`hosts`, `writableDirs`, `excludedCommands`,
102
+ `passedVariables`, `runReachesHosts`), enforced by the module's loader in
103
+ [`../services/index.mjs`](../services/index.mjs); the host and state-dir rules are the ones these
104
+ retired manifest fields carried.
105
+
106
+ A present `services` must be a non-empty array of unique string ids, each naming a loaded fragment. With that key present, `networkHosts` and `writableDirs` are
107
+ refused whatever their values. A manifest without `services` stays valid in its earlier shape:
108
+ no fragments are read and the retired keys are read by nothing. The validator loads fragments only
109
+ when `services` is present; a loader refusal makes the manifest invalid, naming the fragment file
110
+ or services directory, rather than throwing. An invalid manifest **fails** `--strict`.
111
+
112
+ **The `--bridge-tier` seed is the primary lane** (AD-172): for every used bridge it merges the
113
+ services' hosts into `sandbox.network.allowedDomains`, resolved state dirs into
114
+ `sandbox.filesystem.allowWrite` (home-relative under the home, absolute outside it, env overrides
115
+ honoured), and excluded commands after the used roles' `<wrapper> *` exclusions (`codex-exec *`
116
+ for the execution wrapper). The advisor's `bridge-tier` item counts and names each missing entry.
117
+ A settings-native harness that drops the exclusion still admits the hosts; that pre-allow widens
118
+ egress for **every** sandboxed command, which the tier's consent states. A harness-managed sandbox
119
+ that ignores the settings keys keeps its own controls — scoped rules, a session allowance and
120
+ consent at the point of action — and the kit writes no shape for it. The hosts record what was
121
+ observed: a blocked host names itself at run time, and its service fragment is the place to extend.
141
122
 
142
123
  ## Mode catalog (BRIDGE-MODES-CATALOG)
143
124
 
@@ -203,8 +184,8 @@ with no control characters — the surface is a terminal-width list and a pasted
203
184
  ## Path-field rules (Windows-safe, traversal-safe)
204
185
 
205
186
  These rules govern the **repo/project-relative path fields** enumerated below (`source`,
206
- `template`, `detect.*`) — NOT `writableDirs`, whose `default` entries are deliberately
207
- `~/`-anchored or absolute **host** paths under their own section's rules above.
187
+ `template`, `detect.*`). Service fragments' state-dir defaults are deliberately `~/`-anchored or
188
+ absolute **host** paths under the fragment rules in *Services* above.
208
189
 
209
190
  - **No absolute paths**, **no `..` traversal** in the fields below; **no unresolved placeholders**
210
191
  (`{{…}}` / `${…}`) in any field.
@@ -21,6 +21,7 @@
21
21
  import { readFileSync, existsSync } from 'node:fs';
22
22
  import { resolve, join, isAbsolute } from 'node:path';
23
23
  import { isDirectRun } from '../direct-run.mjs';
24
+ import { loadServiceFragments } from '../services/index.mjs';
24
25
 
25
26
  export const FAMILY = 'agent-workflow';
26
27
  export const SUPPORTED_SCHEMA = 1;
@@ -89,10 +90,6 @@ const CONTROL_CHAR_RE = /[\x00-\x1f\x7f]/;
89
90
  const hasTraversal = (p) => p.split(/[\\/]/).includes('..');
90
91
  const isUnresolved = (s) => /\{\{|\}\}|\$\{/.test(s);
91
92
 
92
- // A `networkHosts` entry: a bare dotted hostname, optionally a `*.` family wildcard — never a
93
- // scheme, a path, a port, or whitespace (the entry is pasted verbatim into an allowlist line).
94
- export const NETWORK_HOST_RE = /^(\*\.)?[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$/i;
95
-
96
93
  // Cross-platform "absolute-like": POSIX root (/x), Windows drive (C:\ or C:/), UNC (\\host),
97
94
  // or a leading backslash. node:path.isAbsolute() alone is platform-dependent, so a Windows path
98
95
  // would slip through unchecked on a POSIX CI runner — Windows-safety requires rejecting both.
@@ -436,7 +433,7 @@ const validateModeCatalog = (catalog, roles, errors) => {
436
433
  });
437
434
  };
438
435
 
439
- export const validateManifest = (skillDir) => {
436
+ export const validateManifest = (skillDir, options = {}) => {
440
437
  const manifestPath = join(skillDir, 'capability.json');
441
438
  let raw;
442
439
  try {
@@ -637,63 +634,28 @@ export const validateManifest = (skillDir) => {
637
634
  }
638
635
  }
639
636
 
640
- // `networkHosts` (AD-044 Plan 4, consult-locked): the backend CLI's OBSERVED egress host
641
- // families. `velocity-profile --bridge-tier` seeds them into sandbox.network.allowedDomains
642
- // for USED bridges (a recipe slot uses them, revision 4; AD-172); the pre-allow widens egress for EVERY
643
- // sandboxed command, stated at that consent. A malformed list FAILS --strict like `settings`:
644
- // the tier writes it and the Recommendations advisor renders it verbatim, so a bad entry would corrupt a seeded line.
645
- const networkHosts = manifest.networkHosts;
646
- if (networkHosts != null) {
647
- if (!Array.isArray(networkHosts) || networkHosts.length === 0) {
648
- errors.push('`networkHosts` must be a non-empty array of host strings');
649
- } else {
650
- const seenHosts = new Set();
651
- networkHosts.forEach((host, i) => {
652
- if (typeof host !== 'string' || !NETWORK_HOST_RE.test(host)) {
653
- errors.push(`\`networkHosts[${i}]\` must be a bare hostname or a *.family wildcard (${JSON.stringify(host)})`);
654
- return;
655
- }
656
- if (seenHosts.has(host)) errors.push(`duplicate networkHosts entry "${host}" (\`networkHosts[${i}]\`)`);
657
- else seenHosts.add(host);
658
- });
637
+ if (Object.hasOwn(manifest, 'services')) {
638
+ for (const key of ['networkHosts', 'writableDirs']) {
639
+ if (Object.hasOwn(manifest, key)) errors.push(`\`services\` must not coexist with retired key \`${key}\``);
659
640
  }
660
- }
661
-
662
- // `writableDirs` (REC-UX-REWORK, D6): {env, default} entries the tier RESOLVES (a NON-EMPTY
663
- // env value wins, else the default) and seeds home-relative into sandbox.filesystem.allowWrite
664
- // for USED bridges via `bridge-state-dirs.mjs`; the advisor's `bridge-tier` item counts and names them.
665
- // A malformed list FAILS --strict: the resolved dir is written into the settings and rendered
666
- // on the Recommendations advisor's ONE-LINE `recipe:` line.
667
- const writableDirs = manifest.writableDirs;
668
- if (writableDirs != null) {
669
- if (!Array.isArray(writableDirs) || writableDirs.length === 0) {
670
- errors.push('`writableDirs` must be a non-empty array of {env, default} entries');
671
- } else {
672
- const seenDefaults = new Set();
673
- writableDirs.forEach((entry, i) => {
674
- const at = `\`writableDirs[${i}]\``;
675
- if (entry == null || typeof entry !== 'object' || Array.isArray(entry)) {
676
- errors.push(`${at} must be an {env, default} object`);
677
- return;
678
- }
679
- if (entry.env !== null && (typeof entry.env !== 'string' || !/^[A-Z][A-Z0-9_]*$/.test(entry.env))) {
680
- errors.push(`${at}.env must be null or an UPPER_SNAKE_CASE env-var name (${JSON.stringify(entry.env)})`);
681
- }
682
- const dir = entry.default;
683
- if (typeof dir !== 'string' || !(dir.startsWith('~/') || dir.startsWith('/'))) {
684
- errors.push(`${at}.default must be a \`~/\`-anchored or absolute POSIX path (${JSON.stringify(dir)})`);
685
- return;
641
+ try {
642
+ const fragments = loadServiceFragments({ servicesDir: options.servicesDir });
643
+ const services = manifest.services;
644
+ if (!Array.isArray(services) || services.length === 0) {
645
+ errors.push('`services` must be a non-empty array of unique service ids');
646
+ } else {
647
+ const seenServices = new Set();
648
+ for (const id of services) {
649
+ if (typeof id !== 'string' || !Object.hasOwn(fragments, id)) {
650
+ errors.push(`\`services\` has an unknown or non-string id: ${JSON.stringify(id)}`);
651
+ } else if (seenServices.has(id)) {
652
+ errors.push(`\`services\` has a duplicate id: ${JSON.stringify(id)}`);
653
+ }
654
+ seenServices.add(id);
686
655
  }
687
- if (/[*?[\]]/.test(dir)) errors.push(`${at}.default must not carry glob characters ("${dir}")`);
688
- // The resolved dir is written into `allowWrite` and rendered on a ONE-LINE advisor line —
689
- // a control character (newline, CR, NUL, …) would break that line or the settings entry.
690
- // eslint-disable-next-line no-control-regex
691
- if (/[\x00-\x1f\x7f]/.test(dir)) errors.push(`${at}.default must not carry control characters (${JSON.stringify(dir)})`);
692
- if (dir.endsWith('/')) errors.push(`${at}.default must not end with a trailing slash ("${dir}")`);
693
- if (hasTraversal(dir)) errors.push(`${at}.default must not contain ".." traversal ("${dir}")`);
694
- if (seenDefaults.has(dir)) errors.push(`duplicate writableDirs default "${dir}" (${at})`);
695
- else seenDefaults.add(dir);
696
- });
656
+ }
657
+ } catch (error) {
658
+ errors.push(`\`services\`: ${error.message}`);
697
659
  }
698
660
  }
699
661
 
@@ -476,7 +476,7 @@ const costLanesAdvice = () => [
476
476
  ' • L2 subscription bridge (codex / agy) — reviews per the resolved recipe above, on each bridge\'s host posture (the model the user set, else the bridge default); a weaker model is the user\'s setting, never a per-call choice — a probe is the one route to a one-off and its review receipt never attests.',
477
477
  ' • L3 frontier — judgment: plan/fold/synthesis, ADR/handover/changelog-entry wording, persuasive copy, go/no-go, real code.',
478
478
  ' • A step with no named guardrail does not move down a lane; red lines never move down (council review models · real code · memory/copy wording · the maintainer approval asks).',
479
- ' • Sandbox lanes (under an OS sandbox): the L0 surfaces are sandbox-safe — gates/ledger/state/fold checks, git reads, plain no-network tests; the bridge wrappers are genuinely unsandboxed (network); npm-cache-touching commands are COMMAND-SHAPE dependent — first try the sandbox-safe shape (cache under $TMPDIR, offline/notifier off). Move ONLY the failing command out of the sandbox, never its class; BATCH consecutive unsandboxed calls. Pre-dispatch host-diff: before the FIRST dispatch of each bridge, diff its manifest networkHosts against the live sandbox allow-list — a missing host is surfaced to the maintainer BEFORE dispatching, never fired into a known prompt. Nested-sandbox honesty: a backend CLI shipping its OWN OS sandbox cannot run nested inside a harness sandbox — route it outside (excludedCommands / a per-run consented bypass) on the OBSERVED failure, never a preemptive blanket.',
479
+ ' • Sandbox lanes (under an OS sandbox): the L0 surfaces are sandbox-safe — gates/ledger/state/fold checks, git reads, plain no-network tests; the bridge wrappers are genuinely unsandboxed (network); npm-cache-touching commands are COMMAND-SHAPE dependent — first try the sandbox-safe shape (cache under $TMPDIR, offline/notifier off). Move ONLY the failing command out of the sandbox, never its class; BATCH consecutive unsandboxed calls. Pre-dispatch host-diff: before the FIRST dispatch of each bridge, diff the hosts of the services its manifest names against the live sandbox allow-list — a missing host is surfaced to the maintainer BEFORE dispatching, never fired into a known prompt. Nested-sandbox honesty: a backend CLI shipping its OWN OS sandbox cannot run nested inside a harness sandbox — route it outside (excludedCommands / a per-run consented bypass) on the OBSERVED failure, never a preemptive blanket.',
480
480
  ' • Prompt economy (autonomy-preserving dispatch): read-only fan-out (research/sweeps/extraction) runs ONLY on restricted-tool vehicles — a full-tool subagent for read-only work is a forbidden lane downgrade (invisible prompt-flood + blast radius), and a subagent is never told to shell out for facts obtainable read-only; the orchestrator\'s own shell form is ONE plain pipeline per call (a ;/&& chain or env-prefixed invocation never matches a prefix allow rule); a fan-out LAUNCHER that gates per call yields to the agent-spawn lane. Capability-gated: on a host with restricted-tool subagent vehicles use them; without restricted-tool vehicles (a host offering only full-tool agents included), read-only research stays in the orchestrator\'s own context — never a vehicle mandate a host cannot satisfy.',
481
481
  ' • Writer economy (autonomy-preserving dispatch): a stage\'s repeated WRITER commands batch into ONE invocation — combine a stage\'s writers via one batched write or one launcher per stage; never one writer call at a time (each write is its own prompt).',
482
482
  ' • The prompt-economy clause narrows TOOLS for read-only work only — judgment, code, synthesis stay at the frontier lane; a task that genuinely needs to run or write keeps a full-tool subagent. Honest limit: no deterministic gate classifies a dispatch — enforcement is the canon at the point of use + the placed vehicles + the retro loop.',
@@ -0,0 +1,17 @@
1
+ {
2
+ "hosts": [
3
+ "*.googleapis.com",
4
+ "accounts.google.com",
5
+ "antigravity-unleash.goog",
6
+ "lh3.googleusercontent.com"
7
+ ],
8
+ "writableDirs": [
9
+ {
10
+ "env": null,
11
+ "default": "~/.gemini/antigravity-cli"
12
+ }
13
+ ],
14
+ "excludedCommands": [],
15
+ "passedVariables": [],
16
+ "runReachesHosts": false
17
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "hosts": [
3
+ "chatgpt.com",
4
+ "*.chatgpt.com"
5
+ ],
6
+ "writableDirs": [
7
+ {
8
+ "env": "CODEX_HOME",
9
+ "default": "~/.codex"
10
+ }
11
+ ],
12
+ "excludedCommands": [],
13
+ "passedVariables": [],
14
+ "runReachesHosts": false
15
+ }