@bonesofspring/ai-rules 0.2.21 → 0.2.22
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/package.json +1 -1
- package/presets/_shared/core/agent-team/agent-artifact-contracts.md +2 -0
- package/presets/_shared/core/meta/preset-twin-sync.md +1 -1
- package/presets/claude/android-kotlin/agents/build-verifier.md +2 -0
- package/presets/claude/android-kotlin/agents/code-reviewer.md +2 -0
- package/presets/claude/android-kotlin/agents/debugger.md +1 -0
- package/presets/claude/android-kotlin/agents/feature-developer.md +3 -0
- package/presets/claude/android-kotlin/agents/qa-tester.md +2 -0
- package/presets/claude/android-kotlin/agents/task-router.md +4 -0
- package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +51 -11
- package/presets/claude/android-kotlin/rules/tooling-and-review/preset-twin-sync.md +1 -1
- package/presets/claude/go/agents/build-verifier.md +4 -0
- package/presets/claude/go/agents/code-reviewer.md +4 -0
- package/presets/claude/go/agents/debugger.md +4 -0
- package/presets/claude/go/agents/feature-developer.md +5 -0
- package/presets/claude/go/agents/qa-tester.md +4 -0
- package/presets/claude/go/agents/task-router.md +4 -0
- package/presets/claude/go/hooks/chain-team-phases.sh +51 -11
- package/presets/claude/go/rules/tooling-and-review/preset-twin-sync.md +1 -1
- package/presets/claude/ios-swift/agents/build-verifier.md +2 -0
- package/presets/claude/ios-swift/agents/code-reviewer.md +2 -0
- package/presets/claude/ios-swift/agents/debugger.md +1 -0
- package/presets/claude/ios-swift/agents/feature-developer.md +3 -0
- package/presets/claude/ios-swift/agents/qa-tester.md +2 -0
- package/presets/claude/ios-swift/agents/task-router.md +4 -0
- package/presets/claude/ios-swift/hooks/chain-team-phases.sh +51 -11
- package/presets/claude/ios-swift/rules/tooling-and-review/preset-twin-sync.md +1 -1
- package/presets/claude/java/agents/build-verifier.md +4 -0
- package/presets/claude/java/agents/code-reviewer.md +4 -0
- package/presets/claude/java/agents/debugger.md +4 -0
- package/presets/claude/java/agents/feature-developer.md +5 -0
- package/presets/claude/java/agents/qa-tester.md +4 -0
- package/presets/claude/java/agents/task-router.md +4 -0
- package/presets/claude/java/hooks/chain-team-phases.sh +51 -11
- package/presets/claude/java/rules/tooling-and-review/preset-twin-sync.md +1 -1
- package/presets/claude/mcp-ts/agents/build-verifier.md +4 -0
- package/presets/claude/mcp-ts/agents/feature-developer.md +5 -0
- package/presets/claude/mcp-ts/agents/task-router.md +1 -1
- package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +51 -11
- package/presets/claude/mcp-ts/rules/tooling-and-review/preset-twin-sync.md +1 -1
- package/presets/claude/next/agents/build-verifier.md +2 -0
- package/presets/claude/next/agents/code-reviewer.md +2 -0
- package/presets/claude/next/agents/debugger.md +4 -0
- package/presets/claude/next/agents/feature-developer.md +3 -0
- package/presets/claude/next/agents/qa-tester.md +4 -0
- package/presets/claude/next/agents/unit-test-generator.md +1 -1
- package/presets/claude/next/agents/unit-test-planner.md +1 -1
- package/presets/claude/next/hooks/chain-team-phases.sh +51 -11
- package/presets/claude/next/rules/api-and-data/http-client.md +1 -1
- package/presets/claude/next/rules/architecture/reference-features.md +1 -1
- package/presets/claude/next/rules/testing/README.md +1 -1
- package/presets/claude/next/rules/testing/tests-e2e-structure.md +2 -0
- package/presets/claude/next/rules/testing/tests-unit.md +3 -5
- package/presets/claude/next/rules/tooling-and-review/preset-twin-sync.md +1 -1
- package/presets/claude/next/rules/ui-and-accessibility/react-ui.md +1 -1
- package/presets/claude/next/skills/playwright-e2e/SKILL.md +5 -3
- package/presets/claude/next/skills/unit-testing/SKILL.md +6 -4
- package/presets/claude/nuxt/agents/build-verifier.md +2 -0
- package/presets/claude/nuxt/agents/code-reviewer.md +2 -0
- package/presets/claude/nuxt/agents/debugger.md +4 -0
- package/presets/claude/nuxt/agents/feature-developer.md +3 -0
- package/presets/claude/nuxt/agents/qa-tester.md +4 -0
- package/presets/claude/nuxt/hooks/chain-team-phases.sh +51 -11
- package/presets/claude/nuxt/rules/tooling-and-review/preset-twin-sync.md +1 -1
- package/presets/claude/php-hexagonal/agents/build-verifier.md +4 -0
- package/presets/claude/php-hexagonal/agents/code-reviewer.md +4 -0
- package/presets/claude/php-hexagonal/agents/debugger.md +4 -0
- package/presets/claude/php-hexagonal/agents/feature-developer.md +5 -0
- package/presets/claude/php-hexagonal/agents/qa-tester.md +4 -0
- package/presets/claude/php-hexagonal/agents/task-router.md +4 -0
- package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +51 -11
- package/presets/claude/php-hexagonal/rules/tooling-and-review/preset-twin-sync.md +1 -1
- package/presets/claude/php-laravel/agents/build-verifier.md +4 -0
- package/presets/claude/php-laravel/agents/code-reviewer.md +4 -0
- package/presets/claude/php-laravel/agents/debugger.md +4 -0
- package/presets/claude/php-laravel/agents/feature-developer.md +5 -0
- package/presets/claude/php-laravel/agents/qa-tester.md +4 -0
- package/presets/claude/php-laravel/agents/task-router.md +1 -0
- package/presets/claude/php-laravel/hooks/chain-team-phases.sh +51 -11
- package/presets/claude/php-laravel/rules/tooling-and-review/preset-twin-sync.md +1 -1
- package/presets/claude/svelte/agents/build-verifier.md +2 -0
- package/presets/claude/svelte/agents/code-reviewer.md +2 -0
- package/presets/claude/svelte/agents/debugger.md +4 -0
- package/presets/claude/svelte/agents/feature-developer.md +3 -0
- package/presets/claude/svelte/agents/qa-tester.md +4 -0
- package/presets/claude/svelte/hooks/chain-team-phases.sh +51 -11
- package/presets/claude/svelte/rules/tooling-and-review/preset-twin-sync.md +1 -1
- package/presets/cursor/android-kotlin/agents/build-verifier.md +2 -0
- package/presets/cursor/android-kotlin/agents/code-reviewer.md +2 -0
- package/presets/cursor/android-kotlin/agents/debugger.md +1 -0
- package/presets/cursor/android-kotlin/agents/feature-developer.md +3 -0
- package/presets/cursor/android-kotlin/agents/qa-tester.md +2 -0
- package/presets/cursor/android-kotlin/agents/task-router.md +4 -0
- package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +51 -11
- package/presets/cursor/android-kotlin/rules/preset-twin-sync.mdc +1 -1
- package/presets/cursor/go/agents/build-verifier.md +4 -0
- package/presets/cursor/go/agents/code-reviewer.md +4 -0
- package/presets/cursor/go/agents/debugger.md +4 -0
- package/presets/cursor/go/agents/feature-developer.md +5 -0
- package/presets/cursor/go/agents/qa-tester.md +4 -0
- package/presets/cursor/go/agents/task-router.md +4 -0
- package/presets/cursor/go/hooks/chain-team-phases.sh +51 -11
- package/presets/cursor/go/rules/preset-twin-sync.mdc +1 -1
- package/presets/cursor/ios-swift/agents/build-verifier.md +2 -0
- package/presets/cursor/ios-swift/agents/code-reviewer.md +2 -0
- package/presets/cursor/ios-swift/agents/debugger.md +1 -0
- package/presets/cursor/ios-swift/agents/feature-developer.md +3 -0
- package/presets/cursor/ios-swift/agents/qa-tester.md +2 -0
- package/presets/cursor/ios-swift/agents/task-router.md +4 -0
- package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +51 -11
- package/presets/cursor/ios-swift/rules/preset-twin-sync.mdc +1 -1
- package/presets/cursor/java/agents/build-verifier.md +4 -0
- package/presets/cursor/java/agents/code-reviewer.md +4 -0
- package/presets/cursor/java/agents/debugger.md +4 -0
- package/presets/cursor/java/agents/feature-developer.md +5 -0
- package/presets/cursor/java/agents/qa-tester.md +4 -0
- package/presets/cursor/java/agents/task-router.md +4 -0
- package/presets/cursor/java/hooks/chain-team-phases.sh +51 -11
- package/presets/cursor/java/rules/preset-twin-sync.mdc +1 -1
- package/presets/cursor/mcp-ts/agents/build-verifier.md +4 -0
- package/presets/cursor/mcp-ts/agents/feature-developer.md +5 -0
- package/presets/cursor/mcp-ts/agents/task-router.md +1 -1
- package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +51 -11
- package/presets/cursor/mcp-ts/rules/preset-twin-sync.mdc +1 -1
- package/presets/cursor/next/agents/build-verifier.md +2 -0
- package/presets/cursor/next/agents/code-reviewer.md +2 -0
- package/presets/cursor/next/agents/debugger.md +4 -0
- package/presets/cursor/next/agents/feature-developer.md +3 -0
- package/presets/cursor/next/agents/qa-tester.md +4 -0
- package/presets/cursor/next/agents/unit-test-generator.md +1 -1
- package/presets/cursor/next/agents/unit-test-planner.md +1 -1
- package/presets/cursor/next/hooks/chain-team-phases.sh +51 -11
- package/presets/cursor/next/rules/http-client.mdc +1 -1
- package/presets/cursor/next/rules/preset-twin-sync.mdc +1 -1
- package/presets/cursor/next/rules/react-ui.mdc +1 -1
- package/presets/cursor/next/rules/reference-features.mdc +1 -1
- package/presets/cursor/next/rules/tests-e2e-structure.mdc +2 -0
- package/presets/cursor/next/rules/tests-unit.mdc +3 -5
- package/presets/cursor/next/skills/playwright-e2e/SKILL.md +5 -3
- package/presets/cursor/next/skills/unit-testing/SKILL.md +6 -4
- package/presets/cursor/nuxt/agents/build-verifier.md +2 -0
- package/presets/cursor/nuxt/agents/code-reviewer.md +2 -0
- package/presets/cursor/nuxt/agents/debugger.md +4 -0
- package/presets/cursor/nuxt/agents/feature-developer.md +3 -0
- package/presets/cursor/nuxt/agents/qa-tester.md +4 -0
- package/presets/cursor/nuxt/hooks/chain-team-phases.sh +51 -11
- package/presets/cursor/nuxt/rules/preset-twin-sync.mdc +1 -1
- package/presets/cursor/php-hexagonal/agents/build-verifier.md +4 -0
- package/presets/cursor/php-hexagonal/agents/code-reviewer.md +4 -0
- package/presets/cursor/php-hexagonal/agents/debugger.md +4 -0
- package/presets/cursor/php-hexagonal/agents/feature-developer.md +5 -0
- package/presets/cursor/php-hexagonal/agents/qa-tester.md +4 -0
- package/presets/cursor/php-hexagonal/agents/task-router.md +4 -0
- package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +51 -11
- package/presets/cursor/php-hexagonal/rules/preset-twin-sync.mdc +1 -1
- package/presets/cursor/php-laravel/agents/build-verifier.md +4 -0
- package/presets/cursor/php-laravel/agents/code-reviewer.md +4 -0
- package/presets/cursor/php-laravel/agents/debugger.md +4 -0
- package/presets/cursor/php-laravel/agents/feature-developer.md +5 -0
- package/presets/cursor/php-laravel/agents/qa-tester.md +4 -0
- package/presets/cursor/php-laravel/agents/task-router.md +1 -0
- package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +51 -11
- package/presets/cursor/php-laravel/rules/preset-twin-sync.mdc +1 -1
- package/presets/cursor/svelte/agents/build-verifier.md +2 -0
- package/presets/cursor/svelte/agents/code-reviewer.md +2 -0
- package/presets/cursor/svelte/agents/debugger.md +4 -0
- package/presets/cursor/svelte/agents/feature-developer.md +3 -0
- package/presets/cursor/svelte/agents/qa-tester.md +4 -0
- package/presets/cursor/svelte/hooks/chain-team-phases.sh +51 -11
- package/presets/cursor/svelte/rules/preset-twin-sync.mdc +1 -1
- package/scripts/check-preset-structure.sh +10 -0
- package/scripts/check-preset-token-budget.sh +100 -0
- package/scripts/check-task-router-intents.sh +141 -0
- package/scripts/test-agent-task-metrics-hooks.mjs +99 -1
- package/scripts/test-chain-team-phases-coverage.mjs +100 -1
- package/scripts/test-task-router-intents-fixtures.mjs +109 -0
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: unit-testing
|
|
3
|
-
description: Plans, generates, and heals unit tests for mappers, thunks, HTTP client behavior, and React components using
|
|
3
|
+
description: Plans, generates, and heals unit tests for mappers, thunks, HTTP client behavior, and React components using mirrored paths under app/__tests__/unit and tests-unit rules. Use for unit test planning, generation, or fixing failing unit tests.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Unit Testing
|
|
7
7
|
|
|
8
8
|
## Project Layout
|
|
9
9
|
|
|
10
|
-
-
|
|
10
|
+
- Test root: `app/__tests__/unit`.
|
|
11
|
+
- Mirror formula: `app/src/<rel>` → `app/__tests__/unit/<rel>` (drop `app/src`, preserve the relative path).
|
|
12
|
+
- Place specs at the deepest mirrored folder of the module under test; do not colocate tests under `app/src/**`.
|
|
11
13
|
- Legacy `*.test.ts` / `*.test.tsx` — do not rename without a separate task.
|
|
12
14
|
- Runner: Jest or Vitest as configured in the target repo; components use `@testing-library/react`.
|
|
13
15
|
|
|
@@ -17,11 +19,11 @@ Follow **`rules/testing/tests-unit.md`**.
|
|
|
17
19
|
|
|
18
20
|
Write or update `.claude/team/tasks/<slug>/unit-test-plan.md`.
|
|
19
21
|
|
|
20
|
-
Each scenario needs a Russian `it()` title (capital letter after each sentence). Cover mappers, thunks, client behavior branches, and component interactions per AC.
|
|
22
|
+
Each scenario needs a Russian `it()` title (capital letter after each sentence). Cover mappers, thunks, client behavior branches, and component interactions per AC. Record the mirrored target path under `app/__tests__/unit/`.
|
|
21
23
|
|
|
22
24
|
## Generator
|
|
23
25
|
|
|
24
|
-
Implement specs from `unit-test-plan.md
|
|
26
|
+
Implement specs from `unit-test-plan.md` under the mirrored `app/__tests__/unit/` path. Import the source under test through the `@/` alias. Reuse project test-store, HTTP mocks, and existing test utilities. Do not change production code.
|
|
25
27
|
|
|
26
28
|
## Healer
|
|
27
29
|
|
|
@@ -96,6 +96,8 @@ Write the owned terminal receipt described under **Artifact contract**. If **FAI
|
|
|
96
96
|
|
|
97
97
|
Do not fix code — report only. Do not advance to code-reviewer until PASS.
|
|
98
98
|
|
|
99
|
+
**Receipt binding.** When writing the terminal receipt to `artifact-manifest.json`, set `entry.receipt.attemptId = <attemptId supplied by the orchestrator>` (the orchestrator provides this via `attemptId` on invocation). The hook at `chain-team-phases.sh:readBoundReceiptOutcome` rejects entries whose `attemptId` does not match the current attempt, or whose `Date.parse(timestamps.completedAt) < Date.parse(attemptStartedAt)`. A missing or stale attemptId causes `awaiting_artifact_receipt` stalls. <!-- shared-core: receipt-binding -->
|
|
100
|
+
|
|
99
101
|
## Artifact contract
|
|
100
102
|
|
|
101
103
|
- **Authoritative inputs:** read `.claude/team/tasks/<slug>/artifact-manifest.json` first; consume handoff `artifactInputIds` when supplied, otherwise consume the manifest entries for brief/decomposition, implementation evidence, pipeline scope, and changed files.
|
|
@@ -54,6 +54,8 @@ Write the owned terminal receipt described under **Artifact contract**. If **REQ
|
|
|
54
54
|
|
|
55
55
|
Do not mix this output with retrospective facilitation — keep review and retro separate.
|
|
56
56
|
|
|
57
|
+
**Receipt binding.** When writing the terminal receipt to `artifact-manifest.json`, set `entry.receipt.attemptId = <attemptId supplied by the orchestrator>` (the orchestrator provides this via `attemptId` on invocation). The hook at `chain-team-phases.sh:readBoundReceiptOutcome` rejects entries whose `attemptId` does not match the current attempt, or whose `Date.parse(timestamps.completedAt) < Date.parse(attemptStartedAt)`. A missing or stale attemptId causes `awaiting_artifact_receipt` stalls. <!-- shared-core: receipt-binding -->
|
|
58
|
+
|
|
57
59
|
## Design guidance
|
|
58
60
|
|
|
59
61
|
- Load `design-guidance` (rule stem) when assessing structure, smells, or pattern fit.
|
|
@@ -80,3 +80,7 @@ Do not perform formal code review or write e2e plans — those are separate agen
|
|
|
80
80
|
|
|
81
81
|
- When writing or changing code, load / follow rule `anti-sycophancy-discipline`.
|
|
82
82
|
- When acting on review feedback (`changes_requested` / human comments): verify each item against the codebase before implementing; no performative agreement.
|
|
83
|
+
|
|
84
|
+
## Receipt binding
|
|
85
|
+
|
|
86
|
+
> **Receipt binding.** When writing the terminal receipt to `artifact-manifest.json`, set `entry.receipt.attemptId = <attemptId supplied by the orchestrator>` (the orchestrator provides this via `attemptId` on invocation). The hook at `chain-team-phases.sh:readBoundReceiptOutcome` rejects entries whose `attemptId` does not match the current attempt, or whose `Date.parse(timestamps.completedAt) < Date.parse(attemptStartedAt)`. A missing or stale attemptId causes `awaiting_artifact_receipt` stalls. <!-- shared-core: receipt-binding -->
|
|
@@ -12,6 +12,7 @@ You are a senior frontend developer working in a Nuxt 3 monorepo with strict lay
|
|
|
12
12
|
2. Read `status.json` — proceed if `in_progress`, `approved`, or `retryAfterFix`.
|
|
13
13
|
3. Read `pipeline.json` for step context and scope.
|
|
14
14
|
4. Follow the **`feature-delivery` skill** (layer order, reference features, validation handoff).
|
|
15
|
+
5. **Verify carry-over at HEAD before applying** (refactor intent only). When the brief comes from a prior review's carry-over findings list, for each item run `git show HEAD:<path>` or `grep` to confirm the finding still applies at the current HEAD; if the file already contains the fix (carry-over was closed in a prior uncommitted batch), mark it as **NO-OP at HEAD** in `implementation.md` and skip the edit; if the file is unchanged, apply the fix and cite file:line. Target ≤2 NO-OP items per refactor pipeline.
|
|
15
16
|
|
|
16
17
|
## Task execution rules
|
|
17
18
|
|
|
@@ -39,6 +40,8 @@ Emit the owned implementation receipt with outcome `completed`. Handoff: tasks d
|
|
|
39
40
|
|
|
40
41
|
Do not perform formal code review — that is the code-reviewer subagent's job.
|
|
41
42
|
|
|
43
|
+
**Receipt binding.** When writing the terminal receipt to `artifact-manifest.json`, set `entry.receipt.attemptId = <attemptId supplied by the orchestrator>` (the orchestrator provides this via `attemptId` on invocation). The hook at `chain-team-phases.sh:readBoundReceiptOutcome` rejects entries whose `attemptId` does not match the current attempt, or whose `Date.parse(timestamps.completedAt) < Date.parse(attemptStartedAt)`. A missing or stale attemptId causes `awaiting_artifact_receipt` stalls. <!-- shared-core: receipt-binding -->
|
|
44
|
+
|
|
42
45
|
## Design guidance
|
|
43
46
|
|
|
44
47
|
- Load `design-guidance` (rule stem) when assessing structure, smells, or pattern fit.
|
|
@@ -52,3 +52,7 @@ Provide summary:
|
|
|
52
52
|
## Design guidance
|
|
53
53
|
|
|
54
54
|
- Load `design-guidance` (rule stem) when assessing structure, smells, or pattern fit.
|
|
55
|
+
|
|
56
|
+
## Receipt binding
|
|
57
|
+
|
|
58
|
+
> **Receipt binding.** When writing the terminal receipt to `artifact-manifest.json`, set `entry.receipt.attemptId = <attemptId supplied by the orchestrator>` (the orchestrator provides this via `attemptId` on invocation). The hook at `chain-team-phases.sh:readBoundReceiptOutcome` rejects entries whose `attemptId` does not match the current attempt, or whose `Date.parse(timestamps.completedAt) < Date.parse(attemptStartedAt)`. A missing or stale attemptId causes `awaiting_artifact_receipt` stalls. <!-- shared-core: receipt-binding -->
|
|
@@ -64,10 +64,20 @@ const STACK = 'nuxt';
|
|
|
64
64
|
const PLATFORM = 'claude';
|
|
65
65
|
|
|
66
66
|
function waitForMetricsLock() {
|
|
67
|
+
// OD-1: real advisory lock via create-exclusive (fs.openSync(_, 'wx')).
|
|
68
|
+
// The previous impl spun on Atomics.wait against an unrelated SharedArrayBuffer
|
|
69
|
+
// and never blocked on the lock file, so two concurrent subagentStop events
|
|
70
|
+
// could both acquire the lock and corrupt metrics.json. Retry EEXIST with a
|
|
71
|
+
// 10 ms sleep up to 200 attempts (2 s ceiling). On any other error, throw.
|
|
67
72
|
for (let attempt = 0; attempt < 200; attempt += 1) {
|
|
68
|
-
try {
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
try {
|
|
74
|
+
const fd = fs.openSync(METRICS_LOCK, 'wx');
|
|
75
|
+
try { fs.closeSync(fd); } catch {}
|
|
76
|
+
return;
|
|
77
|
+
} catch (error) {
|
|
78
|
+
if (!error || error.code !== 'EEXIST') throw error;
|
|
79
|
+
const until = Date.now() + 10;
|
|
80
|
+
while (Date.now() < until) { /* 10 ms busy-wait */ }
|
|
71
81
|
}
|
|
72
82
|
}
|
|
73
83
|
throw new Error('metrics lock timeout');
|
|
@@ -76,7 +86,7 @@ let taskLockHeld = false;
|
|
|
76
86
|
function releaseTaskLock() {
|
|
77
87
|
if (!taskLockHeld) return;
|
|
78
88
|
taskLockHeld = false;
|
|
79
|
-
try { fs.
|
|
89
|
+
try { fs.unlinkSync(METRICS_LOCK); } catch {}
|
|
80
90
|
}
|
|
81
91
|
waitForMetricsLock();
|
|
82
92
|
taskLockHeld = true;
|
|
@@ -104,7 +114,7 @@ function mutateMetrics(mutator) {
|
|
|
104
114
|
fs.writeFileSync(temporary, JSON.stringify(metrics, null, 2) + '\n');
|
|
105
115
|
fs.renameSync(temporary, METRICS_PATH);
|
|
106
116
|
} finally {
|
|
107
|
-
if (acquiredHere) { try { fs.
|
|
117
|
+
if (acquiredHere) { try { fs.unlinkSync(METRICS_LOCK); } catch {} }
|
|
108
118
|
}
|
|
109
119
|
}
|
|
110
120
|
function appendMetric(event) { mutateMetrics((metrics) => metrics.events.push({ eventId: `${metrics.task.runId}:${Date.now()}:${Math.random().toString(16).slice(2)}`, ...event })); }
|
|
@@ -483,7 +493,19 @@ function legacyFlow() {
|
|
|
483
493
|
|
|
484
494
|
|
|
485
495
|
if (hookInput.action === 'end_human_gate') {
|
|
486
|
-
|
|
496
|
+
status.awaitingHumanGate = false;
|
|
497
|
+
// A2 (retro §8): pin a single runId per pipeline so subsequent events don't
|
|
498
|
+
// fragment the metrics ledger across multiple runId sequences. Prefer
|
|
499
|
+
// metrics.json.task.runId when metrics already exist, then status.metricsRunId,
|
|
500
|
+
// then mint a fresh seed only on first ever emit.
|
|
501
|
+
try {
|
|
502
|
+
if (fs.existsSync(METRICS_PATH)) {
|
|
503
|
+
const existing = JSON.parse(fs.readFileSync(METRICS_PATH, 'utf8'));
|
|
504
|
+
if (existing && existing.task && typeof existing.task.runId === 'string') {
|
|
505
|
+
status.metricsRunId = existing.task.runId;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
} catch {}
|
|
487
509
|
if (status.state === 'awaiting_approval') {
|
|
488
510
|
status.state = 'in_progress';
|
|
489
511
|
status.phase = status.phase === 'human_gate' ? 'executing' : status.phase;
|
|
@@ -522,11 +544,29 @@ if (hookInput.action === 'end_human_gate') {
|
|
|
522
544
|
}
|
|
523
545
|
}
|
|
524
546
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
547
|
+
// A2 (retro §8): if gate closes the final human gate of the pipeline
|
|
548
|
+
// (no resume happens, or current step's gate was the last), surface
|
|
549
|
+
// state="awaiting_approval" so a subsequent /task-continue doesn't misinterpret
|
|
550
|
+
// the post-gate idle state as "still in progress".
|
|
551
|
+
{
|
|
552
|
+
let gateWasTerminal = false;
|
|
553
|
+
if (!hookInput.activateNext && fs.existsSync(pipelinePath)) {
|
|
554
|
+
try {
|
|
555
|
+
const pipe = JSON.parse(fs.readFileSync(pipelinePath, 'utf8'));
|
|
556
|
+
const steps = pipe.steps || [];
|
|
557
|
+
const idx = typeof status.pipelineIndex === 'number' ? status.pipelineIndex : 0;
|
|
558
|
+
const cur = steps[idx];
|
|
559
|
+
const gates = Array.isArray(pipe.humanGates) ? pipe.humanGates : [];
|
|
560
|
+
const hasGate = (step) => Array.isArray(gates) && gates.some((g) => typeof g === 'string' && getStepAgents(step).some((a) => g === `after:${a}`));
|
|
561
|
+
if (cur && hasGate(cur)) gateWasTerminal = true;
|
|
562
|
+
} catch {}
|
|
563
|
+
}
|
|
564
|
+
writeStatus({
|
|
565
|
+
awaitingHumanGate: false,
|
|
566
|
+
state: gateWasTerminal ? 'awaiting_approval' : status.state,
|
|
567
|
+
phase: status.phase,
|
|
568
|
+
});
|
|
569
|
+
}
|
|
530
570
|
process.stdout.write(JSON.stringify({ ok: true, action: 'end_human_gate', activeHumanGateEventId: status.activeHumanGateEventId || null }));
|
|
531
571
|
process.exit(0);
|
|
532
572
|
}
|
|
@@ -36,7 +36,7 @@ Cursor `.mdc` — **SoT per stack**. Claude topic `.md` — derived twin.
|
|
|
36
36
|
- **Domain** rules: ≥15 body lines (FAIL if thin without documented alias reason).
|
|
37
37
|
- **Thin aliases** (`agent-team-intake`, `technical-retro`): may be shorter (soft) if they only point to a command/skill.
|
|
38
38
|
- **Slim-companion rules** (UI-edit bundle, slim app-cores, slim tooling): may be shorter than 15 lines **if and only if** the body is a pointer into shared-core / stack-prose (no standalone prose). Examples live in stack `rules/README.md` (e.g. `cursor/next/rules/README.md` "UI-edit bundle" intent).
|
|
39
|
-
-
|
|
39
|
+
- Mechanical enforcement lives in `packages/ai-rules/scripts/check-preset-token-budget.sh` — see `SLIM_COMPANION_ALLOWLIST` (the 53 stems accepted as slim pointers) and `MIN_SLIM_BODY_LINES` (5-line floor). Slim-companion rules with a body of 6–14 lines whose stem is **not** in the allowlist are reported as slim violations by the script.
|
|
40
40
|
|
|
41
41
|
## Severity (build-verifier)
|
|
42
42
|
|
|
@@ -65,3 +65,7 @@ Document PASS/FAIL in `validation-report.md`.
|
|
|
65
65
|
|
|
66
66
|
13. **Product-specs assets (FAIL):** package must ship `presets/_shared/assets/docs-specs/INDEX.md`, `_templates/page.md`, `_templates/feature.md`. Cursor+Claude twins for `product-specs` and `product-specs-authoring` must embed matching shared-core markers; both stems **requestable** (`alwaysApply: false` / Claude `paths: docs/specs/**`) — never session-start.
|
|
67
67
|
14. **Optional consumer check (WARN default):** `scripts/check-product-specs.sh` + schema stub may exist for opt-in consumer CI; **FAIL** only with `--strict` or AC that requires named specs — do not force consumer CI.
|
|
68
|
+
|
|
69
|
+
## Receipt binding
|
|
70
|
+
|
|
71
|
+
> **Receipt binding.** When writing the terminal receipt to `artifact-manifest.json`, set `entry.receipt.attemptId = <attemptId supplied by the orchestrator>` (the orchestrator provides this via `attemptId` on invocation). The hook at `chain-team-phases.sh:readBoundReceiptOutcome` rejects entries whose `attemptId` does not match the current attempt, or whose `Date.parse(timestamps.completedAt) < Date.parse(attemptStartedAt)`. A missing or stale attemptId causes `awaiting_artifact_receipt` stalls. <!-- shared-core: receipt-binding -->
|
|
@@ -49,3 +49,7 @@ Write `.claude/team/tasks/<slug>/review.md` with verdict APPROVE | REQUEST_CHANG
|
|
|
49
49
|
- **Owned outputs:** `review.md`; upsert only the manifest entry assigned by handoff (`artifactOutputId`; fallback `review`) and preserve all foreign entries.
|
|
50
50
|
- **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `changes_requested`. Bind it to the supplied `attemptId` when present.
|
|
51
51
|
- **Shared state:** never create or mutate `status.json` or `metrics.json`; the orchestration runtime/hook owns lifecycle, gates, retries, attempts, and timestamps.
|
|
52
|
+
|
|
53
|
+
## Receipt binding
|
|
54
|
+
|
|
55
|
+
> **Receipt binding.** When writing the terminal receipt to `artifact-manifest.json`, set `entry.receipt.attemptId = <attemptId supplied by the orchestrator>` (the orchestrator provides this via `attemptId` on invocation). The hook at `chain-team-phases.sh:readBoundReceiptOutcome` rejects entries whose `attemptId` does not match the current attempt, or whose `Date.parse(timestamps.completedAt) < Date.parse(attemptStartedAt)`. A missing or stale attemptId causes `awaiting_artifact_receipt` stalls. <!-- shared-core: receipt-binding -->
|
|
@@ -42,3 +42,7 @@ If a Sentry/Datadog (or similar) MCP is ready and the task is a production error
|
|
|
42
42
|
|
|
43
43
|
- When writing or changing code, load / follow rule `anti-sycophancy-discipline`.
|
|
44
44
|
- When acting on review feedback (`changes_requested` / human comments): verify each item against the codebase before implementing; no performative agreement.
|
|
45
|
+
|
|
46
|
+
## Receipt binding
|
|
47
|
+
|
|
48
|
+
> **Receipt binding.** When writing the terminal receipt to `artifact-manifest.json`, set `entry.receipt.attemptId = <attemptId supplied by the orchestrator>` (the orchestrator provides this via `attemptId` on invocation). The hook at `chain-team-phases.sh:readBoundReceiptOutcome` rejects entries whose `attemptId` does not match the current attempt, or whose `Date.parse(timestamps.completedAt) < Date.parse(attemptStartedAt)`. A missing or stale attemptId causes `awaiting_artifact_receipt` stalls. <!-- shared-core: receipt-binding -->
|
|
@@ -11,6 +11,7 @@ Implement PHP features following hexagonal boundaries.
|
|
|
11
11
|
1. Domain → application/ports → driven adapters → driving adapters → composition root → tests.
|
|
12
12
|
2. Read `feature-delivery-workflow.mdc`, `architecture-boundaries.mdc`, layer globs.
|
|
13
13
|
3. After `*.php` edits: invoke `post-change-test.mdc` (+ `php-tooling.mdc`).
|
|
14
|
+
4. **Verify carry-over at HEAD before applying** (refactor intent only). When the brief comes from a prior review's carry-over findings list, for each item run `git show HEAD:<path>` or `grep` to confirm the finding still applies at the current HEAD; if the file already contains the fix, mark it as **NO-OP at HEAD** in `implementation.md` and skip the edit; if the file is unchanged, apply the fix and cite file:line. Target ≤2 NO-OP items per refactor pipeline.
|
|
14
15
|
|
|
15
16
|
## Do / Don't
|
|
16
17
|
|
|
@@ -89,3 +90,7 @@ Load requestable rule `mcp-usage` when verifying third-party library APIs (Conte
|
|
|
89
90
|
- **Owned outputs:** `implementation.md` plus changed implementation/test paths; upsert only the manifest entry assigned by handoff (`artifactOutputId`; fallback `implementation`) and preserve all foreign entries.
|
|
90
91
|
- **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present.
|
|
91
92
|
- **Shared state:** never create or mutate `status.json` or `metrics.json`; the orchestration runtime/hook owns lifecycle, gates, retries, attempts, and timestamps.
|
|
93
|
+
|
|
94
|
+
## Receipt binding
|
|
95
|
+
|
|
96
|
+
> **Receipt binding.** When writing the terminal receipt to `artifact-manifest.json`, set `entry.receipt.attemptId = <attemptId supplied by the orchestrator>` (the orchestrator provides this via `attemptId` on invocation). The hook at `chain-team-phases.sh:readBoundReceiptOutcome` rejects entries whose `attemptId` does not match the current attempt, or whose `Date.parse(timestamps.completedAt) < Date.parse(attemptStartedAt)`. A missing or stale attemptId causes `awaiting_artifact_receipt` stalls. <!-- shared-core: receipt-binding -->
|
|
@@ -22,3 +22,7 @@ Coordinate with existing plans under `.claude/team/tasks/<slug>/`.
|
|
|
22
22
|
## Design guidance
|
|
23
23
|
|
|
24
24
|
- Load `design-guidance` (rule stem) when assessing structure, smells, or pattern fit.
|
|
25
|
+
|
|
26
|
+
## Receipt binding
|
|
27
|
+
|
|
28
|
+
> **Receipt binding.** When writing the terminal receipt to `artifact-manifest.json`, set `entry.receipt.attemptId = <attemptId supplied by the orchestrator>` (the orchestrator provides this via `attemptId` on invocation). The hook at `chain-team-phases.sh:readBoundReceiptOutcome` rejects entries whose `attemptId` does not match the current attempt, or whose `Date.parse(timestamps.completedAt) < Date.parse(attemptStartedAt)`. A missing or stale attemptId causes `awaiting_artifact_receipt` stalls. <!-- shared-core: receipt-binding -->
|
|
@@ -74,6 +74,10 @@ Keep top-level `profile` and emit this top-level object in every new `pipeline.j
|
|
|
74
74
|
- Use concrete flags: `public-contract`, `cross-layer`, `security-sensitive`, `migration`, `destructive`, `concurrency-state`, `external-dependency`, `unclear-acceptance-criteria`, `broad-test-surface`, `behavior-regression`.
|
|
75
75
|
- `routingReasons` must be non-empty and explain profile, gates, specialists, skips, or checkpoints; never write “standard by default.”
|
|
76
76
|
- `estimatedWorkPackages` is an integer ≥1; `openDecisionCount` is an integer ≥0. Do not lower complexity because implementation is familiar.
|
|
77
|
+
- Add **api-contract-reviewer** for new/changed backend contracts — before developer.
|
|
78
|
+
- Add **accessibility-reviewer** / **security-reviewer** after build-verifier (parallel when both apply).
|
|
79
|
+
- Add **tech-writer** when docs/changelog requested.
|
|
80
|
+
|
|
77
81
|
|
|
78
82
|
## Model tiers (`steps[].model`)
|
|
79
83
|
|
|
@@ -66,10 +66,20 @@ const STACK = 'php-hexagonal';
|
|
|
66
66
|
const PLATFORM = 'claude';
|
|
67
67
|
|
|
68
68
|
function waitForMetricsLock() {
|
|
69
|
+
// OD-1: real advisory lock via create-exclusive (fs.openSync(_, 'wx')).
|
|
70
|
+
// The previous impl spun on Atomics.wait against an unrelated SharedArrayBuffer
|
|
71
|
+
// and never blocked on the lock file, so two concurrent subagentStop events
|
|
72
|
+
// could both acquire the lock and corrupt metrics.json. Retry EEXIST with a
|
|
73
|
+
// 10 ms sleep up to 200 attempts (2 s ceiling). On any other error, throw.
|
|
69
74
|
for (let attempt = 0; attempt < 200; attempt += 1) {
|
|
70
|
-
try {
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
try {
|
|
76
|
+
const fd = fs.openSync(METRICS_LOCK, 'wx');
|
|
77
|
+
try { fs.closeSync(fd); } catch {}
|
|
78
|
+
return;
|
|
79
|
+
} catch (error) {
|
|
80
|
+
if (!error || error.code !== 'EEXIST') throw error;
|
|
81
|
+
const until = Date.now() + 10;
|
|
82
|
+
while (Date.now() < until) { /* 10 ms busy-wait */ }
|
|
73
83
|
}
|
|
74
84
|
}
|
|
75
85
|
throw new Error('metrics lock timeout');
|
|
@@ -78,7 +88,7 @@ let taskLockHeld = false;
|
|
|
78
88
|
function releaseTaskLock() {
|
|
79
89
|
if (!taskLockHeld) return;
|
|
80
90
|
taskLockHeld = false;
|
|
81
|
-
try { fs.
|
|
91
|
+
try { fs.unlinkSync(METRICS_LOCK); } catch {}
|
|
82
92
|
}
|
|
83
93
|
waitForMetricsLock();
|
|
84
94
|
taskLockHeld = true;
|
|
@@ -106,7 +116,7 @@ function mutateMetrics(mutator) {
|
|
|
106
116
|
fs.writeFileSync(temporary, JSON.stringify(metrics, null, 2) + '\n');
|
|
107
117
|
fs.renameSync(temporary, METRICS_PATH);
|
|
108
118
|
} finally {
|
|
109
|
-
if (acquiredHere) { try { fs.
|
|
119
|
+
if (acquiredHere) { try { fs.unlinkSync(METRICS_LOCK); } catch {} }
|
|
110
120
|
}
|
|
111
121
|
}
|
|
112
122
|
function appendMetric(event) { mutateMetrics((metrics) => metrics.events.push({ eventId: `${metrics.task.runId}:${Date.now()}:${Math.random().toString(16).slice(2)}`, ...event })); }
|
|
@@ -481,7 +491,19 @@ function legacyFlow() {
|
|
|
481
491
|
|
|
482
492
|
|
|
483
493
|
if (hookInput.action === 'end_human_gate') {
|
|
484
|
-
|
|
494
|
+
status.awaitingHumanGate = false;
|
|
495
|
+
// A2 (retro §8): pin a single runId per pipeline so subsequent events don't
|
|
496
|
+
// fragment the metrics ledger across multiple runId sequences. Prefer
|
|
497
|
+
// metrics.json.task.runId when metrics already exist, then status.metricsRunId,
|
|
498
|
+
// then mint a fresh seed only on first ever emit.
|
|
499
|
+
try {
|
|
500
|
+
if (fs.existsSync(METRICS_PATH)) {
|
|
501
|
+
const existing = JSON.parse(fs.readFileSync(METRICS_PATH, 'utf8'));
|
|
502
|
+
if (existing && existing.task && typeof existing.task.runId === 'string') {
|
|
503
|
+
status.metricsRunId = existing.task.runId;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
} catch {}
|
|
485
507
|
if (status.state === 'awaiting_approval') {
|
|
486
508
|
status.state = 'in_progress';
|
|
487
509
|
status.phase = status.phase === 'human_gate' ? 'executing' : status.phase;
|
|
@@ -520,11 +542,29 @@ if (hookInput.action === 'end_human_gate') {
|
|
|
520
542
|
}
|
|
521
543
|
}
|
|
522
544
|
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
545
|
+
// A2 (retro §8): if gate closes the final human gate of the pipeline
|
|
546
|
+
// (no resume happens, or current step's gate was the last), surface
|
|
547
|
+
// state="awaiting_approval" so a subsequent /task-continue doesn't misinterpret
|
|
548
|
+
// the post-gate idle state as "still in progress".
|
|
549
|
+
{
|
|
550
|
+
let gateWasTerminal = false;
|
|
551
|
+
if (!hookInput.activateNext && fs.existsSync(pipelinePath)) {
|
|
552
|
+
try {
|
|
553
|
+
const pipe = JSON.parse(fs.readFileSync(pipelinePath, 'utf8'));
|
|
554
|
+
const steps = pipe.steps || [];
|
|
555
|
+
const idx = typeof status.pipelineIndex === 'number' ? status.pipelineIndex : 0;
|
|
556
|
+
const cur = steps[idx];
|
|
557
|
+
const gates = Array.isArray(pipe.humanGates) ? pipe.humanGates : [];
|
|
558
|
+
const hasGate = (step) => Array.isArray(gates) && gates.some((g) => typeof g === 'string' && getStepAgents(step).some((a) => g === `after:${a}`));
|
|
559
|
+
if (cur && hasGate(cur)) gateWasTerminal = true;
|
|
560
|
+
} catch {}
|
|
561
|
+
}
|
|
562
|
+
writeStatus({
|
|
563
|
+
awaitingHumanGate: false,
|
|
564
|
+
state: gateWasTerminal ? 'awaiting_approval' : status.state,
|
|
565
|
+
phase: status.phase,
|
|
566
|
+
});
|
|
567
|
+
}
|
|
528
568
|
process.stdout.write(JSON.stringify({ ok: true, action: 'end_human_gate', activeHumanGateEventId: status.activeHumanGateEventId || null }));
|
|
529
569
|
process.exit(0);
|
|
530
570
|
}
|
|
@@ -40,7 +40,7 @@ Cursor `.mdc` — **SoT per stack**. Claude topic `.md` — derived twin.
|
|
|
40
40
|
- **Domain** rules: ≥15 body lines (FAIL if thin without documented alias reason).
|
|
41
41
|
- **Thin aliases** (`agent-team-intake`, `technical-retro`): may be shorter (soft) if they only point to a command/skill.
|
|
42
42
|
- **Slim-companion rules** (UI-edit bundle, slim app-cores, slim tooling): may be shorter than 15 lines **if and only if** the body is a pointer into shared-core / stack-prose (no standalone prose). Examples live in stack `rules/README.md` (e.g. `cursor/next/rules/README.md` "UI-edit bundle" intent).
|
|
43
|
-
-
|
|
43
|
+
- Mechanical enforcement lives in `packages/ai-rules/scripts/check-preset-token-budget.sh` — see `SLIM_COMPANION_ALLOWLIST` (the 53 stems accepted as slim pointers) and `MIN_SLIM_BODY_LINES` (5-line floor). Slim-companion rules with a body of 6–14 lines whose stem is **not** in the allowlist are reported as slim violations by the script.
|
|
44
44
|
|
|
45
45
|
## Severity (build-verifier)
|
|
46
46
|
|
|
@@ -65,3 +65,7 @@ Document PASS/FAIL in `validation-report.md`.
|
|
|
65
65
|
|
|
66
66
|
13. **Product-specs assets (FAIL):** package must ship `presets/_shared/assets/docs-specs/INDEX.md`, `_templates/page.md`, `_templates/feature.md`. Cursor+Claude twins for `product-specs` and `product-specs-authoring` must embed matching shared-core markers; both stems **requestable** (`alwaysApply: false` / Claude `paths: docs/specs/**`) — never session-start.
|
|
67
67
|
14. **Optional consumer check (WARN default):** `scripts/check-product-specs.sh` + schema stub may exist for opt-in consumer CI; **FAIL** only with `--strict` or AC that requires named specs — do not force consumer CI.
|
|
68
|
+
|
|
69
|
+
## Receipt binding
|
|
70
|
+
|
|
71
|
+
> **Receipt binding.** When writing the terminal receipt to `artifact-manifest.json`, set `entry.receipt.attemptId = <attemptId supplied by the orchestrator>` (the orchestrator provides this via `attemptId` on invocation). The hook at `chain-team-phases.sh:readBoundReceiptOutcome` rejects entries whose `attemptId` does not match the current attempt, or whose `Date.parse(timestamps.completedAt) < Date.parse(attemptStartedAt)`. A missing or stale attemptId causes `awaiting_artifact_receipt` stalls. <!-- shared-core: receipt-binding -->
|
|
@@ -49,3 +49,7 @@ Write `.claude/team/tasks/<slug>/review.md` with verdict APPROVE | REQUEST_CHANG
|
|
|
49
49
|
- **Owned outputs:** `review.md`; upsert only the manifest entry assigned by handoff (`artifactOutputId`; fallback `review`) and preserve all foreign entries.
|
|
50
50
|
- **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `changes_requested`. Bind it to the supplied `attemptId` when present.
|
|
51
51
|
- **Shared state:** never create or mutate `status.json` or `metrics.json`; the orchestration runtime/hook owns lifecycle, gates, retries, attempts, and timestamps.
|
|
52
|
+
|
|
53
|
+
## Receipt binding
|
|
54
|
+
|
|
55
|
+
> **Receipt binding.** When writing the terminal receipt to `artifact-manifest.json`, set `entry.receipt.attemptId = <attemptId supplied by the orchestrator>` (the orchestrator provides this via `attemptId` on invocation). The hook at `chain-team-phases.sh:readBoundReceiptOutcome` rejects entries whose `attemptId` does not match the current attempt, or whose `Date.parse(timestamps.completedAt) < Date.parse(attemptStartedAt)`. A missing or stale attemptId causes `awaiting_artifact_receipt` stalls. <!-- shared-core: receipt-binding -->
|
|
@@ -42,3 +42,7 @@ If a Sentry/Datadog (or similar) MCP is ready and the task is a production error
|
|
|
42
42
|
|
|
43
43
|
- When writing or changing code, load / follow rule `anti-sycophancy-discipline`.
|
|
44
44
|
- When acting on review feedback (`changes_requested` / human comments): verify each item against the codebase before implementing; no performative agreement.
|
|
45
|
+
|
|
46
|
+
## Receipt binding
|
|
47
|
+
|
|
48
|
+
> **Receipt binding.** When writing the terminal receipt to `artifact-manifest.json`, set `entry.receipt.attemptId = <attemptId supplied by the orchestrator>` (the orchestrator provides this via `attemptId` on invocation). The hook at `chain-team-phases.sh:readBoundReceiptOutcome` rejects entries whose `attemptId` does not match the current attempt, or whose `Date.parse(timestamps.completedAt) < Date.parse(attemptStartedAt)`. A missing or stale attemptId causes `awaiting_artifact_receipt` stalls. <!-- shared-core: receipt-binding -->
|
|
@@ -11,6 +11,7 @@ Implement Laravel features following Laravel-first layer boundaries.
|
|
|
11
11
|
1. Routes → Form Request / Policy → Action/Service → Eloquent → Controller/Resource → optional Job/Event → tests.
|
|
12
12
|
2. Read `feature-delivery-workflow.mdc`, `architecture-boundaries.mdc`, layer globs.
|
|
13
13
|
3. After `*.php` edits: invoke `post-change-test.mdc` (+ `php-tooling.mdc`) → `php artisan test` / `composer test`.
|
|
14
|
+
4. **Verify carry-over at HEAD before applying** (refactor intent only). When the brief comes from a prior review's carry-over findings list, for each item run `git show HEAD:<path>` or `grep` to confirm the finding still applies at the current HEAD; if the file already contains the fix, mark it as **NO-OP at HEAD** in `implementation.md` and skip the edit; if the file is unchanged, apply the fix and cite file:line. Target ≤2 NO-OP items per refactor pipeline.
|
|
14
15
|
|
|
15
16
|
## Do / Don't
|
|
16
17
|
|
|
@@ -89,3 +90,7 @@ Load requestable rule `mcp-usage` when verifying third-party library APIs (Conte
|
|
|
89
90
|
- **Owned outputs:** `implementation.md` plus changed implementation/test paths; upsert only the manifest entry assigned by handoff (`artifactOutputId`; fallback `implementation`) and preserve all foreign entries.
|
|
90
91
|
- **Terminal receipt:** cover applicable AC/task IDs, list authoritative evidence paths, and emit `completed` or `blocked`. Bind it to the supplied `attemptId` when present.
|
|
91
92
|
- **Shared state:** never create or mutate `status.json` or `metrics.json`; the orchestration runtime/hook owns lifecycle, gates, retries, attempts, and timestamps.
|
|
93
|
+
|
|
94
|
+
## Receipt binding
|
|
95
|
+
|
|
96
|
+
> **Receipt binding.** When writing the terminal receipt to `artifact-manifest.json`, set `entry.receipt.attemptId = <attemptId supplied by the orchestrator>` (the orchestrator provides this via `attemptId` on invocation). The hook at `chain-team-phases.sh:readBoundReceiptOutcome` rejects entries whose `attemptId` does not match the current attempt, or whose `Date.parse(timestamps.completedAt) < Date.parse(attemptStartedAt)`. A missing or stale attemptId causes `awaiting_artifact_receipt` stalls. <!-- shared-core: receipt-binding -->
|
|
@@ -28,3 +28,7 @@ Coordinate with existing plans under `.claude/team/tasks/<slug>/`.
|
|
|
28
28
|
## Design guidance
|
|
29
29
|
|
|
30
30
|
- Load `design-guidance` (rule stem) when assessing structure, smells, or pattern fit.
|
|
31
|
+
|
|
32
|
+
## Receipt binding
|
|
33
|
+
|
|
34
|
+
> **Receipt binding.** When writing the terminal receipt to `artifact-manifest.json`, set `entry.receipt.attemptId = <attemptId supplied by the orchestrator>` (the orchestrator provides this via `attemptId` on invocation). The hook at `chain-team-phases.sh:readBoundReceiptOutcome` rejects entries whose `attemptId` does not match the current attempt, or whose `Date.parse(timestamps.completedAt) < Date.parse(attemptStartedAt)`. A missing or stale attemptId causes `awaiting_artifact_receipt` stalls. <!-- shared-core: receipt-binding -->
|
|
@@ -93,6 +93,7 @@ Keep top-level `profile` and emit this top-level object in every new `pipeline.j
|
|
|
93
93
|
- Use concrete flags: `public-contract`, `cross-layer`, `security-sensitive`, `migration`, `destructive`, `concurrency-state`, `external-dependency`, `unclear-acceptance-criteria`, `broad-test-surface`, `behavior-regression`.
|
|
94
94
|
- `routingReasons` must be non-empty and explain profile, gates, specialists, skips, or checkpoints; never write “standard by default.”
|
|
95
95
|
- `estimatedWorkPackages` is an integer ≥1; `openDecisionCount` is an integer ≥0. Do not lower complexity because implementation is familiar.
|
|
96
|
+
- Add **api-contract-reviewer** for new/changed backend contracts — before developer.
|
|
96
97
|
|
|
97
98
|
## Model tiers (`steps[].model`)
|
|
98
99
|
|
|
@@ -66,10 +66,20 @@ const STACK = 'php-laravel';
|
|
|
66
66
|
const PLATFORM = 'claude';
|
|
67
67
|
|
|
68
68
|
function waitForMetricsLock() {
|
|
69
|
+
// OD-1: real advisory lock via create-exclusive (fs.openSync(_, 'wx')).
|
|
70
|
+
// The previous impl spun on Atomics.wait against an unrelated SharedArrayBuffer
|
|
71
|
+
// and never blocked on the lock file, so two concurrent subagentStop events
|
|
72
|
+
// could both acquire the lock and corrupt metrics.json. Retry EEXIST with a
|
|
73
|
+
// 10 ms sleep up to 200 attempts (2 s ceiling). On any other error, throw.
|
|
69
74
|
for (let attempt = 0; attempt < 200; attempt += 1) {
|
|
70
|
-
try {
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
try {
|
|
76
|
+
const fd = fs.openSync(METRICS_LOCK, 'wx');
|
|
77
|
+
try { fs.closeSync(fd); } catch {}
|
|
78
|
+
return;
|
|
79
|
+
} catch (error) {
|
|
80
|
+
if (!error || error.code !== 'EEXIST') throw error;
|
|
81
|
+
const until = Date.now() + 10;
|
|
82
|
+
while (Date.now() < until) { /* 10 ms busy-wait */ }
|
|
73
83
|
}
|
|
74
84
|
}
|
|
75
85
|
throw new Error('metrics lock timeout');
|
|
@@ -78,7 +88,7 @@ let taskLockHeld = false;
|
|
|
78
88
|
function releaseTaskLock() {
|
|
79
89
|
if (!taskLockHeld) return;
|
|
80
90
|
taskLockHeld = false;
|
|
81
|
-
try { fs.
|
|
91
|
+
try { fs.unlinkSync(METRICS_LOCK); } catch {}
|
|
82
92
|
}
|
|
83
93
|
waitForMetricsLock();
|
|
84
94
|
taskLockHeld = true;
|
|
@@ -106,7 +116,7 @@ function mutateMetrics(mutator) {
|
|
|
106
116
|
fs.writeFileSync(temporary, JSON.stringify(metrics, null, 2) + '\n');
|
|
107
117
|
fs.renameSync(temporary, METRICS_PATH);
|
|
108
118
|
} finally {
|
|
109
|
-
if (acquiredHere) { try { fs.
|
|
119
|
+
if (acquiredHere) { try { fs.unlinkSync(METRICS_LOCK); } catch {} }
|
|
110
120
|
}
|
|
111
121
|
}
|
|
112
122
|
function appendMetric(event) { mutateMetrics((metrics) => metrics.events.push({ eventId: `${metrics.task.runId}:${Date.now()}:${Math.random().toString(16).slice(2)}`, ...event })); }
|
|
@@ -481,7 +491,19 @@ function legacyFlow() {
|
|
|
481
491
|
|
|
482
492
|
|
|
483
493
|
if (hookInput.action === 'end_human_gate') {
|
|
484
|
-
|
|
494
|
+
status.awaitingHumanGate = false;
|
|
495
|
+
// A2 (retro §8): pin a single runId per pipeline so subsequent events don't
|
|
496
|
+
// fragment the metrics ledger across multiple runId sequences. Prefer
|
|
497
|
+
// metrics.json.task.runId when metrics already exist, then status.metricsRunId,
|
|
498
|
+
// then mint a fresh seed only on first ever emit.
|
|
499
|
+
try {
|
|
500
|
+
if (fs.existsSync(METRICS_PATH)) {
|
|
501
|
+
const existing = JSON.parse(fs.readFileSync(METRICS_PATH, 'utf8'));
|
|
502
|
+
if (existing && existing.task && typeof existing.task.runId === 'string') {
|
|
503
|
+
status.metricsRunId = existing.task.runId;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
} catch {}
|
|
485
507
|
if (status.state === 'awaiting_approval') {
|
|
486
508
|
status.state = 'in_progress';
|
|
487
509
|
status.phase = status.phase === 'human_gate' ? 'executing' : status.phase;
|
|
@@ -520,11 +542,29 @@ if (hookInput.action === 'end_human_gate') {
|
|
|
520
542
|
}
|
|
521
543
|
}
|
|
522
544
|
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
545
|
+
// A2 (retro §8): if gate closes the final human gate of the pipeline
|
|
546
|
+
// (no resume happens, or current step's gate was the last), surface
|
|
547
|
+
// state="awaiting_approval" so a subsequent /task-continue doesn't misinterpret
|
|
548
|
+
// the post-gate idle state as "still in progress".
|
|
549
|
+
{
|
|
550
|
+
let gateWasTerminal = false;
|
|
551
|
+
if (!hookInput.activateNext && fs.existsSync(pipelinePath)) {
|
|
552
|
+
try {
|
|
553
|
+
const pipe = JSON.parse(fs.readFileSync(pipelinePath, 'utf8'));
|
|
554
|
+
const steps = pipe.steps || [];
|
|
555
|
+
const idx = typeof status.pipelineIndex === 'number' ? status.pipelineIndex : 0;
|
|
556
|
+
const cur = steps[idx];
|
|
557
|
+
const gates = Array.isArray(pipe.humanGates) ? pipe.humanGates : [];
|
|
558
|
+
const hasGate = (step) => Array.isArray(gates) && gates.some((g) => typeof g === 'string' && getStepAgents(step).some((a) => g === `after:${a}`));
|
|
559
|
+
if (cur && hasGate(cur)) gateWasTerminal = true;
|
|
560
|
+
} catch {}
|
|
561
|
+
}
|
|
562
|
+
writeStatus({
|
|
563
|
+
awaitingHumanGate: false,
|
|
564
|
+
state: gateWasTerminal ? 'awaiting_approval' : status.state,
|
|
565
|
+
phase: status.phase,
|
|
566
|
+
});
|
|
567
|
+
}
|
|
528
568
|
process.stdout.write(JSON.stringify({ ok: true, action: 'end_human_gate', activeHumanGateEventId: status.activeHumanGateEventId || null }));
|
|
529
569
|
process.exit(0);
|
|
530
570
|
}
|
|
@@ -38,7 +38,7 @@ Cursor `.mdc` — **SoT per stack**. Claude topic `.md` — derived twin.
|
|
|
38
38
|
- **Domain** rules: ≥15 body lines (FAIL if thin without documented alias reason).
|
|
39
39
|
- **Thin aliases** (`agent-team-intake`, `technical-retro`): may be shorter (soft) if they only point to a command/skill.
|
|
40
40
|
- **Slim-companion rules** (UI-edit bundle, slim app-cores, slim tooling): may be shorter than 15 lines **if and only if** the body is a pointer into shared-core / stack-prose (no standalone prose). Examples live in stack `rules/README.md` (e.g. `cursor/next/rules/README.md` "UI-edit bundle" intent).
|
|
41
|
-
-
|
|
41
|
+
- Mechanical enforcement lives in `packages/ai-rules/scripts/check-preset-token-budget.sh` — see `SLIM_COMPANION_ALLOWLIST` (the 53 stems accepted as slim pointers) and `MIN_SLIM_BODY_LINES` (5-line floor). Slim-companion rules with a body of 6–14 lines whose stem is **not** in the allowlist are reported as slim violations by the script.
|
|
42
42
|
|
|
43
43
|
## Severity (build-verifier)
|
|
44
44
|
|
|
@@ -96,6 +96,8 @@ Write the owned terminal receipt described under **Artifact contract**. If **FAI
|
|
|
96
96
|
|
|
97
97
|
Do not fix code — report only. Do not advance to code-reviewer until PASS.
|
|
98
98
|
|
|
99
|
+
**Receipt binding.** When writing the terminal receipt to `artifact-manifest.json`, set `entry.receipt.attemptId = <attemptId supplied by the orchestrator>` (the orchestrator provides this via `attemptId` on invocation). The hook at `chain-team-phases.sh:readBoundReceiptOutcome` rejects entries whose `attemptId` does not match the current attempt, or whose `Date.parse(timestamps.completedAt) < Date.parse(attemptStartedAt)`. A missing or stale attemptId causes `awaiting_artifact_receipt` stalls. <!-- shared-core: receipt-binding -->
|
|
100
|
+
|
|
99
101
|
## Artifact contract
|
|
100
102
|
|
|
101
103
|
- **Authoritative inputs:** read `.claude/team/tasks/<slug>/artifact-manifest.json` first; consume handoff `artifactInputIds` when supplied, otherwise consume the manifest entries for brief/decomposition, implementation evidence, pipeline scope, and changed files.
|
|
@@ -54,6 +54,8 @@ Write the owned terminal receipt described under **Artifact contract**. If **REQ
|
|
|
54
54
|
|
|
55
55
|
Do not mix this output with retrospective facilitation — keep review and retro separate.
|
|
56
56
|
|
|
57
|
+
**Receipt binding.** When writing the terminal receipt to `artifact-manifest.json`, set `entry.receipt.attemptId = <attemptId supplied by the orchestrator>` (the orchestrator provides this via `attemptId` on invocation). The hook at `chain-team-phases.sh:readBoundReceiptOutcome` rejects entries whose `attemptId` does not match the current attempt, or whose `Date.parse(timestamps.completedAt) < Date.parse(attemptStartedAt)`. A missing or stale attemptId causes `awaiting_artifact_receipt` stalls. <!-- shared-core: receipt-binding -->
|
|
58
|
+
|
|
57
59
|
## Design guidance
|
|
58
60
|
|
|
59
61
|
- Load `design-guidance` (rule stem) when assessing structure, smells, or pattern fit.
|
|
@@ -80,3 +80,7 @@ Do not perform formal code review or write e2e plans — those are separate agen
|
|
|
80
80
|
|
|
81
81
|
- When writing or changing code, load / follow rule `anti-sycophancy-discipline`.
|
|
82
82
|
- When acting on review feedback (`changes_requested` / human comments): verify each item against the codebase before implementing; no performative agreement.
|
|
83
|
+
|
|
84
|
+
## Receipt binding
|
|
85
|
+
|
|
86
|
+
> **Receipt binding.** When writing the terminal receipt to `artifact-manifest.json`, set `entry.receipt.attemptId = <attemptId supplied by the orchestrator>` (the orchestrator provides this via `attemptId` on invocation). The hook at `chain-team-phases.sh:readBoundReceiptOutcome` rejects entries whose `attemptId` does not match the current attempt, or whose `Date.parse(timestamps.completedAt) < Date.parse(attemptStartedAt)`. A missing or stale attemptId causes `awaiting_artifact_receipt` stalls. <!-- shared-core: receipt-binding -->
|
|
@@ -12,6 +12,7 @@ You are a senior frontend developer working in a SvelteKit monorepo with strict
|
|
|
12
12
|
2. Read `status.json` — proceed if `in_progress`, `approved`, or `retryAfterFix`.
|
|
13
13
|
3. Read `pipeline.json` for step context and scope.
|
|
14
14
|
4. Follow the **`feature-delivery` skill** (layer order, reference features, validation handoff).
|
|
15
|
+
5. **Verify carry-over at HEAD before applying** (refactor intent only). When the brief comes from a prior review's carry-over findings list, for each item run `git show HEAD:<path>` or `grep` to confirm the finding still applies at the current HEAD; if the file already contains the fix (carry-over was closed in a prior uncommitted batch), mark it as **NO-OP at HEAD** in `implementation.md` and skip the edit; if the file is unchanged, apply the fix and cite file:line. Target ≤2 NO-OP items per refactor pipeline.
|
|
15
16
|
|
|
16
17
|
## Task execution rules
|
|
17
18
|
|
|
@@ -39,6 +40,8 @@ Emit the owned implementation receipt with outcome `completed`. Handoff: tasks d
|
|
|
39
40
|
|
|
40
41
|
Do not perform formal code review — that is the code-reviewer subagent's job.
|
|
41
42
|
|
|
43
|
+
**Receipt binding.** When writing the terminal receipt to `artifact-manifest.json`, set `entry.receipt.attemptId = <attemptId supplied by the orchestrator>` (the orchestrator provides this via `attemptId` on invocation). The hook at `chain-team-phases.sh:readBoundReceiptOutcome` rejects entries whose `attemptId` does not match the current attempt, or whose `Date.parse(timestamps.completedAt) < Date.parse(attemptStartedAt)`. A missing or stale attemptId causes `awaiting_artifact_receipt` stalls. <!-- shared-core: receipt-binding -->
|
|
44
|
+
|
|
42
45
|
## Design guidance
|
|
43
46
|
|
|
44
47
|
- Load `design-guidance` (rule stem) when assessing structure, smells, or pattern fit.
|
|
@@ -52,3 +52,7 @@ Provide summary:
|
|
|
52
52
|
## Design guidance
|
|
53
53
|
|
|
54
54
|
- Load `design-guidance` (rule stem) when assessing structure, smells, or pattern fit.
|
|
55
|
+
|
|
56
|
+
## Receipt binding
|
|
57
|
+
|
|
58
|
+
> **Receipt binding.** When writing the terminal receipt to `artifact-manifest.json`, set `entry.receipt.attemptId = <attemptId supplied by the orchestrator>` (the orchestrator provides this via `attemptId` on invocation). The hook at `chain-team-phases.sh:readBoundReceiptOutcome` rejects entries whose `attemptId` does not match the current attempt, or whose `Date.parse(timestamps.completedAt) < Date.parse(attemptStartedAt)`. A missing or stale attemptId causes `awaiting_artifact_receipt` stalls. <!-- shared-core: receipt-binding -->
|