@haposoft/cafekit 0.16.6 → 0.18.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.
- package/README.md +14 -22
- package/bin/__tests__/codex-hooks-ownership.test.js +2 -2
- package/bin/__tests__/codex-hooks.test.js +0 -36
- package/bin/__tests__/codex-native.test.js +46 -88
- package/bin/__tests__/develop-contract.test.js +26 -57
- package/bin/__tests__/docs-sync-on-demand.test.js +93 -0
- package/bin/__tests__/grok-envelope.test.js +0 -56
- package/bin/__tests__/hook-payload.test.js +4 -6
- package/bin/__tests__/legacy-authority-decoupled.test.js +159 -0
- package/bin/__tests__/legacy-hooks-retired.test.js +221 -0
- package/bin/__tests__/omp-bridge.test.js +20 -17
- package/bin/__tests__/omp-hooks.test.js +0 -19
- package/bin/__tests__/optional-skill-inventory.test.js +112 -4
- package/bin/__tests__/orca-session.test.js +0 -2
- package/bin/__tests__/package-inventory.test.js +100 -541
- package/bin/__tests__/runtime-dir.test.js +0 -3
- package/bin/__tests__/runtime-schema.test.js +3 -2
- package/bin/__tests__/skill-routing-source.test.js +27 -15
- package/bin/__tests__/spec-narrowing.test.js +0 -27
- package/bin/__tests__/specs-v2-execution-closeout.test.js +4 -69
- package/bin/__tests__/ui-ux-skill.test.js +101 -0
- package/bin/__tests__/usage-hook-retired.test.js +114 -0
- package/bin/__tests__/validator-grounding.test.js +9 -28
- package/bin/phases/codex-runtime.js +24 -0
- package/bin/phases/omp-runtime.js +22 -0
- package/package.json +1 -1
- package/src/claude/CLAUDE.md +3 -10
- package/src/claude/agents/brainstormer.md +7 -3
- package/src/claude/agents/code-auditor.md +35 -50
- package/src/claude/agents/debugger.md +5 -79
- package/src/claude/agents/deployer.md +3 -5
- package/src/claude/agents/docs-keeper.md +2 -7
- package/src/claude/agents/implementer.md +6 -9
- package/src/claude/agents/inspector.md +2 -3
- package/src/claude/agents/project-manager.md +7 -15
- package/src/claude/agents/researcher.md +9 -3
- package/src/claude/agents/spec-maker.md +11 -11
- package/src/claude/hooks/__tests__/fixtures/statusline-default.golden +1 -1
- package/src/claude/hooks/__tests__/spec-gate.test.js +112 -3
- package/src/claude/hooks/__tests__/spec-state-touched.test.js +134 -0
- package/src/claude/hooks/__tests__/state.test.js +68 -0
- package/src/claude/hooks/__tests__/statusline.test.js +140 -11
- package/src/claude/hooks/agent.cjs +2 -1
- package/src/claude/hooks/lib/context.cjs +0 -89
- package/src/claude/hooks/lib/hook-payload.cjs +2 -2
- package/src/claude/hooks/rules.cjs +2 -1
- package/src/claude/hooks/session.cjs +0 -1
- package/src/claude/hooks/spec-gate.cjs +18 -28
- package/src/claude/hooks/spec-state.cjs +95 -1
- package/src/claude/hooks/state.cjs +21 -2
- package/src/claude/migration-manifest.json +30 -15
- package/src/claude/rules/ai-dev-rules.md +1 -1
- package/src/claude/rules/hook-protocols.md +8 -15
- package/src/claude/rules/manage-docs.md +9 -23
- package/src/claude/rules/orchestrator.md +3 -4
- package/src/claude/rules/review-audit-self-decision.md +3 -3
- package/src/claude/rules/skill-domain-routing.md +1 -3
- package/src/claude/rules/skill-workflow-routing.md +4 -5
- package/src/claude/rules/state-sync.md +3 -12
- package/src/claude/rules/workflow.md +10 -18
- package/src/claude/runtime.schema.json +5 -3
- package/src/claude/scripts/generate-skill-catalog.cjs +7 -6
- package/src/claude/scripts/provenance.cjs +23 -5
- package/src/claude/scripts/spec-receipt.cjs +52 -6
- package/src/claude/scripts/spec-resolver.cjs +1 -2
- package/src/claude/scripts/validate-spec-output.cjs +5 -32
- package/src/claude/scripts/workflow-policy.cjs +22 -10
- package/src/claude/settings/settings.json +1 -32
- package/src/claude/skills/{question → ask}/SKILL.md +9 -75
- package/src/claude/skills/brainstorm/SKILL.md +43 -131
- package/src/claude/skills/code-review/SKILL.md +48 -17
- package/src/claude/skills/code-review/references/spec-compliance-review.md +2 -3
- package/src/claude/skills/code-review/references/verification-gate.md +22 -27
- package/src/claude/skills/debug/SKILL.md +29 -149
- package/src/claude/skills/develop/SKILL.md +27 -36
- package/src/claude/skills/develop/references/parallel-waves.md +0 -8
- package/src/claude/skills/develop/references/quality-gate.md +15 -13
- package/src/claude/skills/docs/SKILL.md +2 -2
- package/src/claude/skills/docs/references/update-workflow.md +1 -1
- package/src/claude/skills/fix/SKILL.md +153 -0
- package/src/claude/skills/{hotfix → fix}/references/diagnosis-protocol.md +2 -2
- package/src/claude/skills/{hotfix → fix}/references/parallel-patterns.md +2 -2
- package/src/claude/skills/{hotfix → fix}/references/prevention-gate.md +3 -3
- package/src/claude/skills/{hotfix → fix}/references/review-cycle.md +1 -1
- package/src/claude/skills/git/SKILL.md +48 -9
- package/src/claude/skills/git/references/commit-protocols.md +35 -16
- package/src/claude/skills/git/references/worktree-blueprint.md +42 -6
- package/src/claude/skills/orca/SKILL.md +9 -8
- package/src/claude/skills/research/SKILL.md +2 -0
- package/src/claude/skills/scout/SKILL.md +61 -0
- package/src/claude/skills/{inspect → scout}/references/internal-inspection.md +26 -10
- package/src/claude/skills/specs/SKILL.md +22 -29
- package/src/claude/skills/specs/references/review.md +8 -6
- package/src/claude/skills/specs/references/templates.md +38 -44
- package/src/claude/skills/sync/SKILL.md +8 -15
- package/src/claude/skills/sync/references/rebind-and-audit.md +59 -0
- package/src/claude/skills/sync/references/sync-protocols.md +4 -13
- package/src/claude/skills/test/SKILL.md +22 -3
- package/src/claude/skills/test/references/execution-strategy.md +83 -0
- package/src/claude/skills/test/references/failure-triage.md +1 -1
- package/src/claude/skills/ui-ux/LICENSE +21 -0
- package/src/claude/skills/ui-ux/SKILL.md +497 -0
- package/src/claude/skills/ui-ux/references/brand-tokens.md +90 -0
- package/src/claude/skills/ui-ux/references/budgets.md +113 -0
- package/src/claude/skills/ui-ux/references/checklist.md +271 -0
- package/src/claude/skills/ui-ux/references/components/accordion.md +246 -0
- package/src/claude/skills/ui-ux/references/components/avatar.md +153 -0
- package/src/claude/skills/ui-ux/references/components/banner.md +43 -0
- package/src/claude/skills/ui-ux/references/components/breadcrumb.md +201 -0
- package/src/claude/skills/ui-ux/references/components/button.md +142 -0
- package/src/claude/skills/ui-ux/references/components/card.md +113 -0
- package/src/claude/skills/ui-ux/references/components/charts.md +376 -0
- package/src/claude/skills/ui-ux/references/components/chat.md +132 -0
- package/src/claude/skills/ui-ux/references/components/choice-controls.md +369 -0
- package/src/claude/skills/ui-ux/references/components/comment-thread.md +17 -0
- package/src/claude/skills/ui-ux/references/components/description-list.md +116 -0
- package/src/claude/skills/ui-ux/references/components/empty-state.md +98 -0
- package/src/claude/skills/ui-ux/references/components/file-upload.md +107 -0
- package/src/claude/skills/ui-ux/references/components/inline-edit.md +128 -0
- package/src/claude/skills/ui-ux/references/components/input.md +161 -0
- package/src/claude/skills/ui-ux/references/components/list-row.md +56 -0
- package/src/claude/skills/ui-ux/references/components/loading.md +198 -0
- package/src/claude/skills/ui-ux/references/components/logo.md +147 -0
- package/src/claude/skills/ui-ux/references/components/otp-input.md +43 -0
- package/src/claude/skills/ui-ux/references/components/quantity-input.md +100 -0
- package/src/claude/skills/ui-ux/references/components/range-slider.md +16 -0
- package/src/claude/skills/ui-ux/references/components/small-controls.md +340 -0
- package/src/claude/skills/ui-ux/references/components/sortable-header.md +86 -0
- package/src/claude/skills/ui-ux/references/components/tag-input.md +14 -0
- package/src/claude/skills/ui-ux/references/components/timeline.md +38 -0
- package/src/claude/skills/ui-ux/references/components/tree.md +30 -0
- package/src/claude/skills/ui-ux/references/design-process.md +650 -0
- package/src/claude/skills/ui-ux/references/layouts/app-kanban.html +303 -0
- package/src/claude/skills/ui-ux/references/layouts/app.md +1369 -0
- package/src/claude/skills/ui-ux/references/layouts/form.md +430 -0
- package/src/claude/skills/ui-ux/references/layouts/overlay.md +552 -0
- package/src/claude/skills/ui-ux/references/layouts/pricing.md +204 -0
- package/src/claude/skills/ui-ux/references/locked-rules.md +35 -0
- package/src/claude/skills/ui-ux/references/principles.md +408 -0
- package/src/claude/skills/ui-ux/references/refactor.md +245 -0
- package/src/claude/skills/ui-ux/references/responsive.md +195 -0
- package/src/claude/skills/ui-ux/references/review.md +528 -0
- package/src/claude/skills/ui-ux/references/rules-color.md +623 -0
- package/src/claude/skills/ui-ux/references/rules-form.md +235 -0
- package/src/claude/skills/ui-ux/references/rules-state.md +680 -0
- package/src/claude/skills/ui-ux/references/rules-type.md +369 -0
- package/src/claude/skills/ui-ux/references/styles.md +311 -0
- package/src/claude/skills/ui-ux/references/system.md +219 -0
- package/src/claude/skills/ui-ux/references/tailwind-v4-traps.md +237 -0
- package/src/claude/skills/ui-ux/references/tokens.css +362 -0
- package/src/claude/skills/ui-ux/scripts/lint-skill.mjs +216 -0
- package/src/claude/skills/ui-ux/scripts/package.json +9 -0
- package/src/claude/skills/ui-ux/scripts/probe.mjs +4447 -0
- package/src/claude/skills/ui-ux-pro-max/SKILL.md +1 -1
- package/src/claude/status.cjs +149 -144
- package/src/codex/AGENTS.md +8 -13
- package/src/codex/hooks/agent.cjs +2 -1
- package/src/codex/hooks/lib/spec-receipt.cjs +5 -0
- package/src/codex/hooks/lib/spec-utils.cjs +0 -7
- package/src/codex/hooks/rules.cjs +2 -1
- package/src/codex/hooks/session.cjs +0 -2
- package/src/codex/hooks/spec-gate.cjs +8 -18
- package/src/codex/hooks.json +0 -20
- package/src/codex/rules/state-sync.md +3 -12
- package/src/common/AGENTS.md +2 -2
- package/src/omp/extensions/cafekit-bridge.mjs +6 -6
- package/src/claude/hooks/__tests__/completion-authority.test.js +0 -990
- package/src/claude/hooks/__tests__/semantic-review-authority.test.js +0 -259
- package/src/claude/hooks/completion-authority-check.cjs +0 -56
- package/src/claude/hooks/completion-authority-state.cjs +0 -527
- package/src/claude/hooks/completion-authority.cjs +0 -163
- package/src/claude/hooks/semantic-review-authority.cjs +0 -154
- package/src/claude/hooks/task-scaffold-guard.cjs +0 -114
- package/src/claude/hooks/usage.cjs +0 -197
- package/src/claude/skills/delegate/SKILL.md +0 -124
- package/src/claude/skills/delegate/references/codex-delegation.md +0 -71
- package/src/claude/skills/delegate/references/grok-delegation.md +0 -84
- package/src/claude/skills/hotfix/SKILL.md +0 -289
- package/src/claude/skills/inspect/SKILL.md +0 -142
- package/src/claude/skills/loop/SKILL.md +0 -114
- package/src/claude/skills/loop/references/bounded-loop-protocol.md +0 -104
- package/src/claude/skills/loop/references/metric-and-guard-contract.md +0 -76
- package/src/claude/skills/route/SKILL.md +0 -94
- package/src/claude/skills/route/references/agent-timing.md +0 -46
- package/src/claude/skills/route/references/chaining-patterns.md +0 -53
- package/src/claude/skills/route/references/task-taxonomy.md +0 -48
- package/src/codex/hooks/completion-authority-check.cjs +0 -67
- package/src/codex/hooks/completion-authority-state.cjs +0 -527
- package/src/codex/hooks/completion-authority.cjs +0 -109
- package/src/codex/hooks/semantic-review-authority.cjs +0 -130
- package/src/codex/hooks/task-scaffold-guard.cjs +0 -63
- /package/src/claude/skills/{question → ask}/templates/question.md +0 -0
- /package/src/claude/skills/{hotfix → fix}/references/escalation-tactics.md +0 -0
- /package/src/claude/skills/{hotfix → fix}/references/workflow-specialized.md +0 -0
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
# Delegating to Grok CLI (Grok Build)
|
|
2
|
-
|
|
3
|
-
Verified against grok 0.2.101 (2026-07). Re-check `grok --help` if flags fail.
|
|
4
|
-
|
|
5
|
-
## Preflight
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
which grok && grok --version
|
|
9
|
-
grok models # available model IDs
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
## Non-interactive dispatch
|
|
13
|
-
|
|
14
|
-
Two forms:
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
# single-turn from a brief file (preferred for delegation)
|
|
18
|
-
grok --prompt-file plans/<slug>-task.md \
|
|
19
|
-
--worktree=<slug> \
|
|
20
|
-
--check \
|
|
21
|
-
--permission-mode acceptEdits \
|
|
22
|
-
--allow "Bash(npm:*)" --allow "Bash(node:*)" \
|
|
23
|
-
--output-format plain
|
|
24
|
-
|
|
25
|
-
# short single-turn prompt
|
|
26
|
-
grok -p "<prompt>"
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
Run in a background shell and poll the output.
|
|
30
|
-
|
|
31
|
-
### Key flags
|
|
32
|
-
|
|
33
|
-
| Flag | Notes |
|
|
34
|
-
|---|---|
|
|
35
|
-
| `--prompt-file <path>` | single-turn prompt from file |
|
|
36
|
-
| `-p, --single <prompt>` | single-turn inline prompt |
|
|
37
|
-
| `--worktree=<name>` | built-in git worktree isolation (grok-managed; see pitfalls) |
|
|
38
|
-
| `--check` | appends a self-verification loop (headless only) — use it |
|
|
39
|
-
| `--permission-mode <mode>` | `default` \| `acceptEdits` \| `auto` \| `dontAsk` \| `bypassPermissions` \| `plan` |
|
|
40
|
-
| `--allow "<RULE>"` / `--deny "<RULE>"` | permission rules, Claude Code syntax: `Bash(npm:*)`, `Write`, `Edit` |
|
|
41
|
-
| `-m <model>` / `--reasoning-effort` | model + effort overrides |
|
|
42
|
-
| `--max-turns <N>` | hard cap on agent turns |
|
|
43
|
-
| `--json-schema '<schema>'` | structured final output |
|
|
44
|
-
| `--output-format plain\|json\|streaming-json` | headless output format |
|
|
45
|
-
| `--resume <SESSION_ID>` | continue a session (context preserved) |
|
|
46
|
-
| `--best-of-n <N>` | run task N ways in parallel, pick best (headless) |
|
|
47
|
-
|
|
48
|
-
## Permission model — the #1 pitfall
|
|
49
|
-
|
|
50
|
-
`--permission-mode acceptEdits` **does not reliably unblock file writes in headless runs**; grok may report "Write tool blocked" and quietly degrade to a **design-only** response that reads like progress. It still exits 0.
|
|
51
|
-
|
|
52
|
-
Mitigations:
|
|
53
|
-
- Add explicit allow rules for write tools on the first dispatch: `--allow "Write" --allow "Edit" --allow "StrReplace"` alongside `--allow "Bash(npm:*)" --allow "Bash(node:*)"`.
|
|
54
|
-
- After ~30s, grep the output for `blocked`/`chặn` — catch degradation early.
|
|
55
|
-
- If the run finished design-only: **resume the same session** with widened allows and an explicit apply instruction; grok picks up its own design and implements without re-exploring:
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
grok --resume <SESSION_ID> --no-plan \
|
|
59
|
-
--permission-mode acceptEdits \
|
|
60
|
-
--allow "Write" --allow "Edit" --allow "StrReplace" \
|
|
61
|
-
--allow "Bash(npm:*)" --allow "Bash(node:*)" \
|
|
62
|
-
--check -p "Continue: apply the designed changes, run tests, report results."
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
Even with allows granted, shell may still be policy-restricted (runs finish with "npm test BLOCKED — shell not pre-approved"). That's fine: **you run the Evidence commands yourself during verification** — do not loosen to `bypassPermissions` just to make the agent self-verify.
|
|
66
|
-
|
|
67
|
-
## Worktree pitfalls
|
|
68
|
-
|
|
69
|
-
- `--worktree=<name>` worktrees are **grok-managed**: they may not appear in the target repo's `git worktree list` and `grok worktree list` may still say "No worktrees found". **Do not trust either listing** — after the run, check `git status` in the main repo to find where changes actually landed. In practice (0.2.101, resumed sessions) grok can write **directly into the main working tree** despite the flag.
|
|
70
|
-
- Consequence: always take a stash-backup snapshot before dispatch (`git stash push -u -m "backup: ..." && git stash apply -q`), and treat the main tree as potentially modified.
|
|
71
|
-
|
|
72
|
-
## Session management
|
|
73
|
-
|
|
74
|
-
```bash
|
|
75
|
-
grok sessions list # ids + summaries
|
|
76
|
-
grok --resume <SESSION_ID> [flags] -p "..." # continue with same context
|
|
77
|
-
grok export <SESSION_ID> # transcript as Markdown
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## Quirks
|
|
81
|
-
|
|
82
|
-
- Grok reads the target repo's `CLAUDE.md` and obeys it (including tone rules) — repo constraints apply automatically, but so do repo-wide bans; account for that in the brief.
|
|
83
|
-
- `--check` produces a self-verification section in the final report — useful signal, **not** a substitute for your independent verification.
|
|
84
|
-
- Exit code 0 means the CLI ran, not that the task succeeded. Judge by diff + your own Evidence runs.
|
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: cf:fix
|
|
3
|
-
description: "Use when asked to FIX a bug, error, test failure, CI/CD issue, type error, lint error, log error, UI issue, or code problem. Uses cf:debug for evidence-first diagnosis before any code change."
|
|
4
|
-
user-invocable: true
|
|
5
|
-
when_to_use: "Invoke to fix a bug or failure with scout-first diagnosis before change."
|
|
6
|
-
category: dev-tools
|
|
7
|
-
keywords: [hotfix, fix, bug, diagnosis]
|
|
8
|
-
argument-hint: "[issue] --quick|--parallel|--from-debug"
|
|
9
|
-
metadata:
|
|
10
|
-
author: haposoft
|
|
11
|
-
version: "2.0.0"
|
|
12
|
-
---
|
|
13
|
-
# Fix — root-cause repair workflow
|
|
14
|
-
|
|
15
|
-
Fix the diagnosed root cause, prove the fix with fresh evidence, and leave no
|
|
16
|
-
side effects. Evidence first, fix second.
|
|
17
|
-
|
|
18
|
-
## Arguments
|
|
19
|
-
|
|
20
|
-
- `--quick` - Reduced-depth path for trivial issues (lint, type errors, syntax); still scout-first
|
|
21
|
-
- `--parallel` - Fix independent issues concurrently, only through the Delegation Gate below
|
|
22
|
-
- `--from-debug` - Start from an existing `cf:debug` report and validate its contract before accepting it
|
|
23
|
-
|
|
24
|
-
Default: deterministic scout-first fix. There is no initial mode selection step.
|
|
25
|
-
|
|
26
|
-
## Proportional depth
|
|
27
|
-
|
|
28
|
-
Choose the smallest adequate depth from the diagnosed evidence. Depth vocabulary
|
|
29
|
-
follows `cf:debug`:
|
|
30
|
-
|
|
31
|
-
- **Quick/local:** one deterministic syntax, lint, type, or isolated-test failure
|
|
32
|
-
with obvious local scope. Quick mode only reduces depth; it never skips scout, pre-fix evidence, diagnosis, or before/after verification.
|
|
33
|
-
- **Standard:** a diagnosed root cause inside one bounded area. Fix plus a
|
|
34
|
-
regression test that fails without the fix and passes with it.
|
|
35
|
-
- **Incident/deep:** production impact, multiple components, intermittent
|
|
36
|
-
behavior, data/security risk, or concurrency. Consume the full Incident/deep
|
|
37
|
-
debug handoff (timeline, elimination path, recurrence candidates), implement in
|
|
38
|
-
stages, and verify each stage.
|
|
39
|
-
|
|
40
|
-
Depth changes evidence breadth, never the gates: scout, diagnosis, before/after
|
|
41
|
-
proof, and the side-effect gate apply at every depth.
|
|
42
|
-
|
|
43
|
-
## Bounded repair frame
|
|
44
|
-
|
|
45
|
-
Quick/local does not add a separate framing ceremony when the issue and diagnosis
|
|
46
|
-
already establish the repaired behavior and proof. For Standard or Incident/deep,
|
|
47
|
-
or whenever scope or risk remains ambiguous after diagnosis, record four short
|
|
48
|
-
fields before choosing an implementation:
|
|
49
|
-
|
|
50
|
-
- **Outcome:** the observable repaired behavior.
|
|
51
|
-
- **Constraints:** compatibility, safety, ownership, rollout, and time boundaries.
|
|
52
|
-
- **Non-goals:** adjacent behavior the repair must not absorb.
|
|
53
|
-
- **Acceptance:** the exact reproduction plus broader evidence that proves completion.
|
|
54
|
-
|
|
55
|
-
Derive repository-owned facts from scout and diagnosis. Ask the user only for a
|
|
56
|
-
missing user-owned decision that could materially change the repair. This frame
|
|
57
|
-
does not select a solution, widen the issue into feature work, or run before the
|
|
58
|
-
root cause is proven.
|
|
59
|
-
|
|
60
|
-
<HARD-GATE>
|
|
61
|
-
Do not propose or implement a fix before Steps 1-2 (scout + diagnosis) complete.
|
|
62
|
-
A symptom patch without a diagnosed root cause is a failed fix.
|
|
63
|
-
The exact root-cause contract in Step 2 is mandatory; answer each field in one concrete sentence.
|
|
64
|
-
An answer containing 'probably', 'I think', 'something with', or 'maybe' is not an answer; gather evidence instead.
|
|
65
|
-
If 3+ fix attempts fail, stop, question the architecture, and discuss with the user.
|
|
66
|
-
</HARD-GATE>
|
|
67
|
-
|
|
68
|
-
<HARD-GATE-SCOUT-FIRST>
|
|
69
|
-
Fix always scouts before asking broad clarification questions, forming hypotheses, or changing files.
|
|
70
|
-
Collect these scout outputs first:
|
|
71
|
-
1. Project type, language(s), framework(s), and package/test runner from repo files.
|
|
72
|
-
2. Exact file(s) where the symptom surfaces and their direct callers/dependents.
|
|
73
|
-
3. Related tests covering the affected area.
|
|
74
|
-
4. Recent commits touching affected files: `git log --oneline -10 -- <affected-files>`.
|
|
75
|
-
5. Existing patterns/conventions for this kind of fix.
|
|
76
|
-
Then state a concise 3-6 bullet codebase-context summary before Step 2.
|
|
77
|
-
Do not ask generic questions before this step unless there is no repo, no error text, and no observable artifact to inspect.
|
|
78
|
-
</HARD-GATE-SCOUT-FIRST>
|
|
79
|
-
|
|
80
|
-
<HARD-GATE-NO-SIDE-EFFECTS>
|
|
81
|
-
The fix is not done until Step 5 proves:
|
|
82
|
-
1. The original symptom no longer reproduces with the exact pre-fix command/user flow.
|
|
83
|
-
2. Modified files and transitively affected modules still pass relevant tests.
|
|
84
|
-
3. Blast-radius workflows have no business-logic regression.
|
|
85
|
-
4. No new lint/type/build errors were introduced.
|
|
86
|
-
5. Public contracts are unchanged unless intentionally called out: function signatures, exported types, response shapes, DB schemas, env vars.
|
|
87
|
-
|
|
88
|
-
If verification reveals a side effect or regression, stop and present 2-4 concrete options to the user:
|
|
89
|
-
- Revert this fix and try a different root-cause angle
|
|
90
|
-
- Keep the fix and update <dependent files> to match the new contract
|
|
91
|
-
- Narrow the fix to <subset> so the regression disappears
|
|
92
|
-
- Accept the change — the old behavior was itself a bug
|
|
93
|
-
Do not silently patch around the regression.
|
|
94
|
-
</HARD-GATE-NO-SIDE-EFFECTS>
|
|
95
|
-
|
|
96
|
-
## Delegation Gate
|
|
97
|
-
|
|
98
|
-
Dispatch subagents (parallel scouts, hypothesis tests, deep research, or
|
|
99
|
-
`--parallel` fix trees) only when all three conditions hold:
|
|
100
|
-
|
|
101
|
-
- The user explicitly requested or permitted delegation or parallel agents.
|
|
102
|
-
- The active runtime exposes an Explore/delegation capability.
|
|
103
|
-
- The work splits into at least two distinct, non-overlapping scopes with useful independent work.
|
|
104
|
-
|
|
105
|
-
Otherwise continue sequentially in the main agent with focused local evidence.
|
|
106
|
-
Task-tracking tools are an optional visibility fallback, never a required step;
|
|
107
|
-
a concise markdown checklist is always sufficient.
|
|
108
|
-
|
|
109
|
-
## Process Flow
|
|
110
|
-
|
|
111
|
-
```mermaid
|
|
112
|
-
flowchart TD
|
|
113
|
-
A[Issue Input] --> B[Step 1: Scout via cf:scout]
|
|
114
|
-
B --> C[Step 2: Diagnose via cf:debug]
|
|
115
|
-
C --> D[Step 3: Select Depth]
|
|
116
|
-
D --> E[Step 4: Implement Fix]
|
|
117
|
-
E --> F[Step 5: Verify + Prevent]
|
|
118
|
-
F --> G[Side-Effect Gate]
|
|
119
|
-
G -->|Pass| H[Step 6: Finalize]
|
|
120
|
-
G -->|Regression risk| C
|
|
121
|
-
F -->|Fail, <3 attempts| C
|
|
122
|
-
F -->|Fail, 3+ attempts| I[Question architecture with user]
|
|
123
|
-
H --> J[Report]
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
If prose conflicts with this flow, follow the diagram.
|
|
127
|
-
|
|
128
|
-
---
|
|
129
|
-
|
|
130
|
-
## Step 1: Scout
|
|
131
|
-
|
|
132
|
-
Understand the affected codebase before forming any hypotheses. Activate
|
|
133
|
-
`cf:scout` or perform an equivalent focused local scout (`rg` plus targeted
|
|
134
|
-
reads) to map the blast radius.
|
|
135
|
-
|
|
136
|
-
| Path | Scout depth |
|
|
137
|
-
|------|-------------|
|
|
138
|
-
| Quick/local | Minimal - project type, affected file(s), direct callers/dependents, related tests, recent commits |
|
|
139
|
-
| Standard and deeper | Full - module boundaries, test coverage, call chains, recent changes, existing patterns |
|
|
140
|
-
| `--parallel` | Per-issue independent scouts, one scope each, only through the Delegation Gate |
|
|
141
|
-
|
|
142
|
-
**Output:** `✓ Step 1: Scouted — [N] files mapped, [M] dependencies, [K] tests found`
|
|
143
|
-
|
|
144
|
-
---
|
|
145
|
-
|
|
146
|
-
## Step 2: Diagnose via `cf:debug`
|
|
147
|
-
|
|
148
|
-
Evidence-based root cause analysis; no guessing. Use `cf:debug`, or validate
|
|
149
|
-
an existing debug report when `--from-debug` is provided. See
|
|
150
|
-
`references/diagnosis-protocol.md` for the Fix-local checklist.
|
|
151
|
-
|
|
152
|
-
Diagnosis chain:
|
|
153
|
-
|
|
154
|
-
1. **Capture pre-fix state:** exact error messages, failing test output, stack traces. This is the baseline for Step 5.
|
|
155
|
-
2. **Observe:** read the actual error; locate where it occurs and when it started (`git log -p`).
|
|
156
|
-
3. **Hypothesize:** form 2-3 hypotheses, each with confirm/refute evidence and a quick test.
|
|
157
|
-
4. **Test:** validate each hypothesis against codebase evidence with focused local reads; test hypotheses in parallel only through the Delegation Gate.
|
|
158
|
-
5. **Trace root cause:** symptom → immediate cause → contributing factor → root cause.
|
|
159
|
-
6. **Escalate:** if 2+ hypotheses fail, apply `references/escalation-tactics.md`.
|
|
160
|
-
|
|
161
|
-
**Exact root-cause contract:**
|
|
162
|
-
- Symptom: exact observable failure
|
|
163
|
-
- Reproduction: command, user flow, CI job, log trigger, or route
|
|
164
|
-
- Expected vs actual behavior
|
|
165
|
-
- Trigger: event or input that activated the failure, or `unknown`
|
|
166
|
-
- Root cause: file:line, config, environment, dependency, or data source
|
|
167
|
-
- Contributing factors: conditions that raised likelihood or impact but are not sufficient causes, or `none evidenced`
|
|
168
|
-
- Why now: recent change, dependency drift, data state, environment, timing, or load
|
|
169
|
-
- Evidence chain: observations proving the cause
|
|
170
|
-
- Blast radius: affected files, modules, tests, users, workflows, or release paths
|
|
171
|
-
|
|
172
|
-
With `--from-debug`, validate the report before accepting it:
|
|
173
|
-
|
|
174
|
-
- the exact root-cause contract above is complete;
|
|
175
|
-
- `Evidence Timeline` is present — a skipped timeline is valid in either producer form (`Timeline: skipped - <reason>` or `- skipped: <reason>`);
|
|
176
|
-
- `Elimination Path` records the decisive observation for each removed or retained candidate;
|
|
177
|
-
- `Recurrence-Prevention Handoff`, when present, carries evidence-backed candidates only.
|
|
178
|
-
|
|
179
|
-
A report missing required fields routes back to diagnosis (`cf:debug`); it
|
|
180
|
-
does not enter implementation.
|
|
181
|
-
|
|
182
|
-
If any contract field is vague or missing file:line/config/env evidence, keep
|
|
183
|
-
diagnosing or ask the user for the specific missing artifact. Do not implement.
|
|
184
|
-
|
|
185
|
-
**Output:** `✓ Step 2: Diagnosed — Root cause: [summary], Evidence: [brief], Scope: [N files]`
|
|
186
|
-
|
|
187
|
-
---
|
|
188
|
-
|
|
189
|
-
## Step 3: Select Depth + Bound Repair
|
|
190
|
-
|
|
191
|
-
Apply the Proportional depth rule above. For 2+ independent issues (or
|
|
192
|
-
`--parallel`), evaluate the Delegation Gate; when it is closed, fix the issues
|
|
193
|
-
sequentially. Track progress with the runtime's task surface when available, or
|
|
194
|
-
a markdown checklist otherwise.
|
|
195
|
-
|
|
196
|
-
For Standard and Incident/deep, complete the bounded repair frame above. Quick
|
|
197
|
-
records no separate frame unless scope or risk is still ambiguous.
|
|
198
|
-
|
|
199
|
-
**Output:** `✓ Step 3: [Depth] selected — [workflow]`
|
|
200
|
-
|
|
201
|
-
---
|
|
202
|
-
|
|
203
|
-
## Step 4: Implement Fix
|
|
204
|
-
|
|
205
|
-
Rules:
|
|
206
|
-
- Fix the root cause, not the symptom. Follow diagnosis findings.
|
|
207
|
-
- Minimal changes only; follow existing code patterns.
|
|
208
|
-
- One logical change per commit boundary.
|
|
209
|
-
|
|
210
|
-
Workflows by depth:
|
|
211
|
-
- **Quick:** apply the minimal fix from completed scout + diagnosis, run the exact pre-fix command plus typecheck/lint immediately, report before/after proof.
|
|
212
|
-
- **Standard:** implement the fix, add or update a regression test that fails without the fix and passes with it, run the relevant suite.
|
|
213
|
-
- **Incident/deep:** after diagnosis, research only unresolved external facts. If
|
|
214
|
-
multiple cause-aligned remedies or an architecture decision remain, use
|
|
215
|
-
`cf:brainstorm` to compare 2-3 options against the bounded repair frame, then
|
|
216
|
-
write a concise staged implementation plan with dependencies and proof per
|
|
217
|
-
stage. When diagnosis leaves one safe direct repair, skip research and
|
|
218
|
-
brainstorm, record why it satisfies the frame, and implement it. Delegated
|
|
219
|
-
research follows the Delegation Gate; implementation starts only after the
|
|
220
|
-
direction is resolved.
|
|
221
|
-
- **Parallel:** one independent issue per agent, each following Steps 1-5, dispatched only through the Delegation Gate; aggregate results on completion.
|
|
222
|
-
|
|
223
|
-
**Output:** `✓ Step 4: Fixed — [N] files changed`
|
|
224
|
-
|
|
225
|
-
---
|
|
226
|
-
|
|
227
|
-
## Step 5: Verify + Prevent
|
|
228
|
-
|
|
229
|
-
1. **Iron-law verification:** run the exact commands from the pre-fix state capture and compare output. No claims without fresh command output from the current run.
|
|
230
|
-
2. **Regression test:** must fail without the fix and pass with it.
|
|
231
|
-
3. **Full check:** typecheck + lint + build + test (see `references/parallel-patterns.md` Pattern C).
|
|
232
|
-
4. **Prevention guard (Standard+):** see `references/prevention-gate.md`; consume the debug report's recurrence candidates when present.
|
|
233
|
-
5. **Side-effect gate:** sweep the full blast radius from Step 2 against the five checks in the gate above.
|
|
234
|
-
6. **Review:** trigger `cf:code-review`; see `references/review-cycle.md`.
|
|
235
|
-
|
|
236
|
-
Verification and review report `PASS | PASS_WITH_WARNINGS | FAIL | BLOCKED`.
|
|
237
|
-
The definition of `PASS` defers to `cf:code-review`. `PASS_WITH_WARNINGS`
|
|
238
|
-
routes through the same remediation or user-pause path as `FAIL` and never
|
|
239
|
-
auto-accepts. `BLOCKED` is terminal for the cycle; resolve the blocker instead
|
|
240
|
-
of retrying. A review-only result is not execution proof; completion claims
|
|
241
|
-
require fresh command output.
|
|
242
|
-
|
|
243
|
-
If verification fails: under 3 attempts, loop back to Step 2 and re-diagnose
|
|
244
|
-
with the new evidence; at 3+ attempts, stop and discuss with the user. Never
|
|
245
|
-
weaken, delete, or mock a failing assertion to obtain green.
|
|
246
|
-
|
|
247
|
-
**Output:** `✓ Step 5: Verified + Prevented — [before/after comparison], [N] tests added`
|
|
248
|
-
|
|
249
|
-
---
|
|
250
|
-
|
|
251
|
-
## Step 6: Finalize
|
|
252
|
-
|
|
253
|
-
1. **Report:** root cause, changes made, files affected, prevention measures, side-effect sweep result, and any remaining limitations.
|
|
254
|
-
2. **Docs update:** if API or behavior changed, update only the affected existing docs through the docs flow.
|
|
255
|
-
3. **Commit:** ask the user before committing; use conventional commits.
|
|
256
|
-
|
|
257
|
-
**Output:** `✓ Step 6: Complete — [action taken]`
|
|
258
|
-
|
|
259
|
-
---
|
|
260
|
-
|
|
261
|
-
## Output Format
|
|
262
|
-
|
|
263
|
-
Unified step markers (emit after each step):
|
|
264
|
-
```
|
|
265
|
-
✓ Step 1: Scouted — [N] files, [M] deps
|
|
266
|
-
✓ Step 2: Diagnosed — Root cause: [summary]
|
|
267
|
-
✓ Step 3: [Depth] selected — [workflow]
|
|
268
|
-
✓ Step 4: Fixed — [N] files changed
|
|
269
|
-
✓ Step 5: Verified + Prevented — [tests added], [guards added]
|
|
270
|
-
✓ Step 6: Complete — [action taken]
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
## Specialized Paths
|
|
274
|
-
|
|
275
|
-
Use `references/workflow-specialized.md` as a progressively disclosed overlay
|
|
276
|
-
after Step 1 scout for CI/CD failures, test suite failures, TypeScript type
|
|
277
|
-
errors, UI/visual issues, and application log errors. Load only the matching
|
|
278
|
-
section. Specialized paths add category-specific evidence and proof; they do
|
|
279
|
-
not replace the six-step flow, weaken diagnosis, or broaden the repair scope.
|
|
280
|
-
|
|
281
|
-
## References
|
|
282
|
-
|
|
283
|
-
Load as needed:
|
|
284
|
-
- `references/diagnosis-protocol.md` — Structured root cause analysis and the exact root-cause contract
|
|
285
|
-
- `references/escalation-tactics.md` — What to do when hypotheses fail (Inversion, Scale Game)
|
|
286
|
-
- `references/prevention-gate.md` — Defense-in-depth validation after fix
|
|
287
|
-
- `references/review-cycle.md` — Review verdict handling and required user-pause conditions
|
|
288
|
-
- `references/parallel-patterns.md` — Delegation Gate patterns for parallel work
|
|
289
|
-
- `references/workflow-specialized.md` — CI/CD, test, TypeScript, UI-specific workflows
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: cf:scout
|
|
3
|
-
description: "Fast scoped codebase discovery using local search first and user-permitted Explore delegation only for broad independent scopes. Use for file discovery, task context, entrypoints, call paths, and blast radius."
|
|
4
|
-
user-invocable: true
|
|
5
|
-
when_to_use: "Invoke for fast scoped codebase discovery and file location."
|
|
6
|
-
category: discovery
|
|
7
|
-
keywords: [scout, inspect, discovery, search, context]
|
|
8
|
-
argument-hint: "[search-target]"
|
|
9
|
-
metadata:
|
|
10
|
-
author: haposoft
|
|
11
|
-
version: "2.1.0"
|
|
12
|
-
---
|
|
13
|
-
# Scout
|
|
14
|
-
|
|
15
|
-
Fast, token-efficient codebase discovery that uses focused local search by default
|
|
16
|
-
and delegates only when parallel scouting has a concrete benefit.
|
|
17
|
-
|
|
18
|
-
## Arguments
|
|
19
|
-
- Default: Scout the named target with local `rg` and targeted reads. For a
|
|
20
|
-
genuinely broad scope, use the conditional delegation route in
|
|
21
|
-
`./references/internal-inspection.md`.
|
|
22
|
-
|
|
23
|
-
## When to Use
|
|
24
|
-
|
|
25
|
-
- Feature spanning multiple directories; user wants to find/locate/search files
|
|
26
|
-
- Debugging that needs file relationships; project structure questions
|
|
27
|
-
- Before multi-area changes, review, debug, or impact analysis
|
|
28
|
-
|
|
29
|
-
## Preflight Scope Gate (MANDATORY)
|
|
30
|
-
|
|
31
|
-
Before scanning:
|
|
32
|
-
1. Detect repo-root or root-wide scans such as `.`, `/`, `./`, `**/*`, `**/*.ts`, or similar broad patterns without a scoped directory.
|
|
33
|
-
2. Apply the built-in no-scan lists below.
|
|
34
|
-
3. Prefer file-type or glob hints whenever possible.
|
|
35
|
-
|
|
36
|
-
**When scope is too broad:** use a **2-phase approach** — lightweight structure
|
|
37
|
-
mapping first, then parallel agents only when the Delegation Gate is open.
|
|
38
|
-
|
|
39
|
-
### Phase 1 — Structure Map
|
|
40
|
-
|
|
41
|
-
Map the top-level layout in the main agent. A single Explore agent may do this
|
|
42
|
-
only when the Delegation Gate below is already open:
|
|
43
|
-
1. List immediate children of the scope root (dirs + key config; monorepo markers)
|
|
44
|
-
2. Rough file count per discovered directory
|
|
45
|
-
3. Return a division plan of 1–10 logical sub-scopes (path/glob, est. files, focus)
|
|
46
|
-
|
|
47
|
-
Complete the structure map before Phase 2.
|
|
48
|
-
|
|
49
|
-
### Phase 2 — Conditional Parallel Explore
|
|
50
|
-
|
|
51
|
-
1. Follow the structure map; merge scopes < 10 files; split scopes > 100 files
|
|
52
|
-
2. If the Delegation Gate is open, spawn Explore agents on distinct sub-scopes;
|
|
53
|
-
otherwise scout the sub-scopes sequentially in the main agent
|
|
54
|
-
3. Aggregate into the Scout Report; offer deeper follow-up on specific areas
|
|
55
|
-
|
|
56
|
-
**Fallback to AskUserQuestion:** if the structure map still leaves multiple
|
|
57
|
-
plausible targets and the choice would materially change the scan, offer 2–4
|
|
58
|
-
concrete scopes from findings, then continue with the selected scope.
|
|
59
|
-
|
|
60
|
-
## Built-in No-Scan Guidance
|
|
61
|
-
|
|
62
|
-
### `NO_SCAN_PATHS`
|
|
63
|
-
- `.git/`, `node_modules/`, `dist/`, `build/`, `.next/`, `coverage/`
|
|
64
|
-
- `tmp/`, `temp/`, `vendor/`, `artifacts/`, `secrets/`, `private/`
|
|
65
|
-
|
|
66
|
-
### `NO_SCAN_CONTENT_HINTS`
|
|
67
|
-
- private keys, token dumps, credential exports, `.env` secrets
|
|
68
|
-
- generated bundles, binary blobs
|
|
69
|
-
|
|
70
|
-
## Workflow
|
|
71
|
-
|
|
72
|
-
### 1. Analyze Task
|
|
73
|
-
- Parse search targets; identify directories, patterns, file types
|
|
74
|
-
- Estimate scan size and whether the work divides into independent scopes
|
|
75
|
-
|
|
76
|
-
### 2. Choose The Smallest Route
|
|
77
|
-
|
|
78
|
-
| Condition | Route |
|
|
79
|
-
|---|---|
|
|
80
|
-
| Named files/directories or focused scope (about 50 files or fewer) | Main-agent `rg` plus targeted reads; do not delegate |
|
|
81
|
-
| Medium scope that still fits one coherent search | Main-agent scouting; narrow before considering delegation |
|
|
82
|
-
| Broad scope with two or more independent areas | Structure map, then evaluate the Delegation Gate |
|
|
83
|
-
|
|
84
|
-
Do not use the file estimate alone to justify agents. A focused 100-file search
|
|
85
|
-
may still be cheaper locally; a smaller cross-system search may justify two
|
|
86
|
-
independent scopes.
|
|
87
|
-
|
|
88
|
-
### 3. Delegation Gate
|
|
89
|
-
|
|
90
|
-
Delegate only when all are true:
|
|
91
|
-
|
|
92
|
-
- The user explicitly requested or permitted subagents, delegation, or parallel work.
|
|
93
|
-
- The active runtime exposes an Explore/delegation capability.
|
|
94
|
-
- At least two non-overlapping scopes have useful independent work.
|
|
95
|
-
|
|
96
|
-
If any condition is false, continue in the main agent with scoped `rg`, file
|
|
97
|
-
listing, and targeted reads. Do not ask for delegation merely to complete an
|
|
98
|
-
ordinary focused scout.
|
|
99
|
-
|
|
100
|
-
### 4. Divide And Scout
|
|
101
|
-
|
|
102
|
-
For local scouting, search the shortlisted scopes sequentially and stop when the
|
|
103
|
-
question is answered. For delegated scouting, load
|
|
104
|
-
`./references/internal-inspection.md`, split by logical boundaries, and ensure
|
|
105
|
-
no overlap.
|
|
106
|
-
|
|
107
|
-
- Skip task registration for two or fewer agents.
|
|
108
|
-
- For three or more agents, use the live task/plan surface when available.
|
|
109
|
-
- Prompt each agent with exact directories/files and a read-only boundary.
|
|
110
|
-
|
|
111
|
-
### 5. Collect Results
|
|
112
|
-
- Timeout: 3 minutes per agent (skip non-responders; log in report)
|
|
113
|
-
- Update live task/plan state when one was used; aggregate; list unresolved questions at end
|
|
114
|
-
|
|
115
|
-
## Report Format
|
|
116
|
-
|
|
117
|
-
```markdown
|
|
118
|
-
# Scout Report
|
|
119
|
-
|
|
120
|
-
## Relevant Files
|
|
121
|
-
- `path/to/file.ts` - Brief description
|
|
122
|
-
- ...
|
|
123
|
-
|
|
124
|
-
## Patterns
|
|
125
|
-
- Key patterns observed
|
|
126
|
-
|
|
127
|
-
## Unresolved Questions
|
|
128
|
-
- Any gaps in findings
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
## Rules
|
|
132
|
-
|
|
133
|
-
- Keep scope narrow. Do not use `cf:scout` as a runtime policy engine.
|
|
134
|
-
- Prefer listing files first, then reading only the shortlisted files.
|
|
135
|
-
- Never encourage scanning ignored/generated/sensitive areas from the no-scan list.
|
|
136
|
-
- Keep reports concise and actionable.
|
|
137
|
-
- Ensure no overlap between agent scopes.
|
|
138
|
-
- Skip non-responding agents, do not retry.
|
|
139
|
-
|
|
140
|
-
## References
|
|
141
|
-
|
|
142
|
-
- `./references/internal-inspection.md` - Conditional Explore delegation
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: cf:loop
|
|
3
|
-
description: "Run an explicit, bounded optimization loop against a numeric metric while a separate correctness guard protects the result."
|
|
4
|
-
user-invocable: true
|
|
5
|
-
when_to_use: "Use only when the user explicitly requests measurable iterative optimization and supplies a safe Metric and Guard contract."
|
|
6
|
-
category: utilities
|
|
7
|
-
keywords: [loop, optimization, benchmark, metric, experiment]
|
|
8
|
-
argument-hint: "<goal>"
|
|
9
|
-
metadata:
|
|
10
|
-
author: haposoft
|
|
11
|
-
version: "1.0.0"
|
|
12
|
-
---
|
|
13
|
-
# Loop — bounded metric optimization
|
|
14
|
-
|
|
15
|
-
Loop is explicit-only. Never auto-route ordinary implementation, debugging, or
|
|
16
|
-
research into Loop. It optimizes one numeric outcome under a separate correctness
|
|
17
|
-
Guard; it does not guarantee improvement or replace Test/Review.
|
|
18
|
-
|
|
19
|
-
Live-agent adherence to this written contract is `[UNPROVEN]` without a host run.
|
|
20
|
-
The safety boundary is cooperative: commands must already be trusted by the user
|
|
21
|
-
or repository. No instruction-only workflow can contain a malicious executable
|
|
22
|
-
without an OS sandbox.
|
|
23
|
-
|
|
24
|
-
## 1. Preflight before mutation
|
|
25
|
-
|
|
26
|
-
Load `references/metric-and-guard-contract.md` and freeze every field before any
|
|
27
|
-
worktree, process, patch, or file mutation:
|
|
28
|
-
|
|
29
|
-
- Goal and canonical repository root.
|
|
30
|
-
- Scope: contained regular tracked text paths; symlink, untracked, binary, and
|
|
31
|
-
submodule policy. Default is reject each unsupported kind.
|
|
32
|
-
- Pinned base OID plus primary tracked/untracked status. Reject dirty in-scope
|
|
33
|
-
state; record but never import or clean out-of-scope dirt.
|
|
34
|
-
- Metric argv, unit, `higher|lower`, sample count, IEEE-754 binary64 numeric and
|
|
35
|
-
rounding policy, fixed aggregation/noise rule, minimum delta, timeout, and
|
|
36
|
-
reproducible baseline environment.
|
|
37
|
-
- Distinct immutable Guard argv and timeout for code mutation. Metric and Guard
|
|
38
|
-
may not be the same command or validate the same sole outcome.
|
|
39
|
-
- Frozen positive iteration and wall-clock budgets; explicit success,
|
|
40
|
-
no-improvement, drift, failure, timeout, and cancellation stops.
|
|
41
|
-
- Unique run identity, exact disposable root, ownership marker, upfront cleanup
|
|
42
|
-
consent, handoff mode/destination, retention, and cleanup owner.
|
|
43
|
-
|
|
44
|
-
Missing, ambiguous, unsafe, or non-reproducible input returns `BLOCKED` without
|
|
45
|
-
mutation. A subjective score, a metric that can be edited by the loop, or code
|
|
46
|
-
mutation without a distinct Guard is ineligible.
|
|
47
|
-
|
|
48
|
-
## 2. Establish isolation and baseline
|
|
49
|
-
|
|
50
|
-
Load `references/bounded-loop-protocol.md`. Create a never-reused canonical temp
|
|
51
|
-
root and ownership marker, then add a detached Git worktree at the pinned OID.
|
|
52
|
-
Do not create a branch or commit. Necessary common-Git-dir worktree metadata is
|
|
53
|
-
the only allowed primary-repository metadata effect; primary worktree bytes,
|
|
54
|
-
index, branch, and refs remain untouched.
|
|
55
|
-
|
|
56
|
-
Screen each trusted command as an argv vector and run it with `cwd` fixed to the
|
|
57
|
-
canonical detached root. The executable is a separately approved external
|
|
58
|
-
realpath; only path-valued target arguments must resolve inside the detached
|
|
59
|
-
root. Never use `eval`, `sh -c`, `bash -c`, `zsh -c`,
|
|
60
|
-
`cmd /c`, PowerShell `-Command`, inline interpreter code, Git `-C`, `--git-dir`,
|
|
61
|
-
`--work-tree`, destructive Git operations, path traversal, or an absolute target
|
|
62
|
-
outside the detached root. Use a minimal fixed environment and redact secrets.
|
|
63
|
-
|
|
64
|
-
Capture the complete detached-worktree tracked/untracked manifest before and
|
|
65
|
-
after every Metric and Guard run, subtracting only an exact immutable cache
|
|
66
|
-
allowlist frozen at preflight. Any other oracle mutation is drift. Establish
|
|
67
|
-
baseline samples on pinned bytes before allowing a candidate.
|
|
68
|
-
|
|
69
|
-
## 3. Iterate one attributable change
|
|
70
|
-
|
|
71
|
-
For every iteration:
|
|
72
|
-
|
|
73
|
-
1. Create a fresh unique detached worktree from pinned base and apply only the
|
|
74
|
-
accepted-best patch, if one exists. Never restore in place.
|
|
75
|
-
2. Make exactly one bounded hypothesis change inside Scope. Multiple unrelated
|
|
76
|
-
changes are forbidden. Reject unexpected,
|
|
77
|
-
untracked, binary, symlink, submodule, or out-of-scope bytes.
|
|
78
|
-
3. Fingerprint candidate bytes, run Metric samples, fingerprint again, then run
|
|
79
|
-
Guard on those identical bytes and fingerprint once more.
|
|
80
|
-
4. Reject on nonzero exit, timeout, malformed/non-finite/multi-value output,
|
|
81
|
-
oracle mutation, Guard failure, or any source/environment/contract drift.
|
|
82
|
-
5. Accept only when Guard passes and improvement over current best is strictly
|
|
83
|
-
greater than both the frozen minimum delta and calculated noise threshold.
|
|
84
|
-
Record the candidate as a base-bound accepted-best patch; otherwise discard
|
|
85
|
-
only that iteration's owned disposable environment.
|
|
86
|
-
|
|
87
|
-
Do not edit Metric, Guard, tests, benchmarks, datasets, budgets, or thresholds
|
|
88
|
-
to win; their frozen digests are revalidated before every candidate.
|
|
89
|
-
Stop at the first budget, cancellation, drift, ownership, cleanup, or repeated
|
|
90
|
-
no-improvement condition named in preflight.
|
|
91
|
-
|
|
92
|
-
## 4. Failure and process ownership
|
|
93
|
-
|
|
94
|
-
Launch every command in an isolated process group on POSIX or Job Object on
|
|
95
|
-
Windows. If the runtime cannot terminate the whole process tree, refuse to run.
|
|
96
|
-
On timeout/cancel, terminate, escalate to kill, reap, and verify quiescence before
|
|
97
|
-
cleanup. Never reuse a timed-out path. If descendants, path ownership, or cleanup
|
|
98
|
-
is uncertain, retain exact residue and return `BLOCKED`; never use
|
|
99
|
-
`git reset --hard`, `git clean`, broad deletion, or unrelated recovery.
|
|
100
|
-
|
|
101
|
-
## 5. Handoff
|
|
102
|
-
|
|
103
|
-
Return baseline, best value/noise, the exact keep formula, accepted/rejected
|
|
104
|
-
iteration ledger, Guard evidence, stop reason, remaining limits, and live-proof
|
|
105
|
-
status. A successful handoff is a redacted tracked-text patch bound to base OID,
|
|
106
|
-
complete scoped file manifest, and lowercase SHA-256. Reject secret-bearing,
|
|
107
|
-
untracked, binary, incomplete, or stale output unless a separately approved
|
|
108
|
-
bundle contract exists.
|
|
109
|
-
|
|
110
|
-
Use only the preflight-selected handoff mode: inline ephemeral patch, or an exact
|
|
111
|
-
user-approved path outside the primary worktree with retention and cleanup owner.
|
|
112
|
-
Never apply, commit, push, merge, cherry-pick, deploy, publish, or write an
|
|
113
|
-
artifact into the primary worktree implicitly. The user reviews and explicitly
|
|
114
|
-
authorizes any later application through the normal Develop/Test/Review flow.
|