immune-brain 2.8.3 → 3.0.2
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/.claude-plugin/marketplace.json +16 -0
- package/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/package.json +9 -2
- package/plugins/immune-brain/.claude-plugin/plugin.json +8 -0
- package/plugins/immune-brain/.mcp.json +8 -0
- package/plugins/immune-brain/.pi-extension/imm-canary-work.ts +354 -64
- package/plugins/immune-brain/.pi-extension/pi-canary-assurance-progression.ts +74 -706
- package/plugins/immune-brain/.pi-extension/pi-canary-invocations.ts +1 -90
- package/plugins/immune-brain/.pi-extension/pi-canary-native-review.ts +13 -160
- package/plugins/immune-brain/.pi-extension/pi-canary-qa-findings.ts +1 -50
- package/plugins/immune-brain/.pi-extension/pi-canary-review-bundle.ts +1 -262
- package/plugins/immune-brain/.pi-extension/pi-canary-tool-failure.ts +3 -2
- package/plugins/immune-brain/.pi-extension/pi-canary-verification.ts +8 -229
- package/plugins/immune-brain/.pi-extension/runtime-stub.ts +23 -5
- package/plugins/immune-brain/agents/immune-brain-reviewer.md +11 -0
- package/plugins/immune-brain/dist/claude/mcp-server.mjs +7514 -0
- package/plugins/immune-brain/dist/docs/reference/code-quality-guard.md +58 -0
- package/plugins/immune-brain/dist/docs/reference/immune-brain-config.md +1 -1
- package/plugins/immune-brain/dist/docs/reference/planning-quality-gate.md +1 -1
- package/plugins/immune-brain/dist/docs/reference/subagent-dispatch-protocol.md +19 -13
- package/plugins/immune-brain/dist/imm-loop.md +6 -7
- package/plugins/immune-brain/dist/imm-planner.md +1 -1
- package/plugins/immune-brain/dist/imm-pr-fix.md +9 -0
- package/plugins/immune-brain/dist/role-prompts/code-review.md +33 -13
- package/plugins/immune-brain/dist/role-prompts/executor.md +14 -0
- package/plugins/immune-brain/dist/role-prompts/pr-fix.md +9 -0
- package/plugins/immune-brain/dist/role-prompts/test-fixer.md +7 -0
- package/plugins/immune-brain/hooks/hooks.json +55 -0
- package/plugins/immune-brain/runtime/assurance/coordinator.ts +836 -0
- package/plugins/immune-brain/runtime/assurance/enrollment.ts +6 -0
- package/plugins/immune-brain/runtime/assurance/host_port.ts +18 -0
- package/plugins/immune-brain/runtime/assurance/invocations.ts +90 -0
- package/plugins/immune-brain/runtime/assurance/qa_findings.ts +50 -0
- package/plugins/immune-brain/runtime/assurance/review_evidence.ts +596 -0
- package/plugins/immune-brain/runtime/assurance/verification.ts +233 -0
- package/plugins/immune-brain/runtime/claude/capability.ts +67 -0
- package/plugins/immune-brain/runtime/claude/interaction.ts +70 -0
- package/plugins/immune-brain/runtime/claude/kernel_ports.ts +789 -0
- package/plugins/immune-brain/runtime/claude/mcp_server.ts +363 -0
- package/plugins/immune-brain/runtime/claude/review_host.ts +645 -0
- package/plugins/immune-brain/runtime/commands/kernel.ts +221 -3
- package/plugins/immune-brain/runtime/github_issue_tracker.ts +2 -2
- package/plugins/immune-brain/runtime/kernel/application.ts +8 -5
- package/plugins/immune-brain/runtime/kernel/assurance_projection.ts +24 -13
- package/plugins/immune-brain/runtime/kernel/authority_port.ts +78 -115
- package/plugins/immune-brain/runtime/kernel/canary_application.ts +6 -4
- package/plugins/immune-brain/runtime/kernel/capability_registry.ts +89 -0
- package/plugins/immune-brain/runtime/kernel/completion.ts +64 -6
- package/plugins/immune-brain/runtime/kernel/enrollment.ts +189 -100
- package/plugins/immune-brain/runtime/kernel/enrollment_authority.ts +37 -80
- package/plugins/immune-brain/runtime/kernel/intent.ts +24 -0
- package/plugins/immune-brain/runtime/kernel/pi_canary_prepare.ts +31 -0
- package/plugins/immune-brain/runtime/kernel/reducer.ts +36 -13
- package/plugins/immune-brain/runtime/kernel/storage.ts +16 -16
- package/plugins/immune-brain/runtime/kernel/types.ts +32 -2
- package/plugins/immune-brain/runtime/kernel/validation.ts +107 -16
- package/plugins/immune-brain/runtime/loop_contract.ts +17 -2
- package/plugins/immune-brain/runtime/prompts/code-review.md +33 -13
- package/plugins/immune-brain/runtime/prompts/executor.md +14 -0
- package/plugins/immune-brain/runtime/prompts/pr-fix.md +9 -0
- package/plugins/immune-brain/runtime/prompts/test-fixer.md +7 -0
- package/plugins/immune-brain/runtime/v4_runtime.ts +5 -2
- package/plugins/immune-brain/runtime/workspace_scope.ts +191 -5
- package/plugins/immune-brain/skills/imm-loop/SKILL.md +3 -4
- package/plugins/immune-brain/skills/imm-planner/SKILL.md +2 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Code Quality Guard
|
|
2
|
+
|
|
3
|
+
This contract protects correctness and review signal in LLM-assisted implementation. It is a project-specific guard, not a universal style guide.
|
|
4
|
+
|
|
5
|
+
## Correctness Invariants
|
|
6
|
+
|
|
7
|
+
### Real implementation
|
|
8
|
+
|
|
9
|
+
- Do not ship mocks, fixtures, hard-coded success, placeholder output, disabled assertions, or weakened tests as production completion.
|
|
10
|
+
- If required behavior cannot be implemented with the available evidence or scope, stop and report the missing condition. Do not manufacture a passing result.
|
|
11
|
+
|
|
12
|
+
### Error semantics
|
|
13
|
+
|
|
14
|
+
- Catch only errors that the code can recover from, translate, or enrich.
|
|
15
|
+
- Do not turn an unknown or unrecoverable error into `null`, `undefined`, empty output, or a success result.
|
|
16
|
+
- When translating an error, preserve its cause and the contract-visible meaning.
|
|
17
|
+
|
|
18
|
+
### Trust boundaries
|
|
19
|
+
|
|
20
|
+
- Validate user input, file contents, network payloads, deserialized data, and cross-process data at the boundary where they enter the system.
|
|
21
|
+
- Once an invariant is established by a trusted caller or validator, avoid speculative internal guards that hide a violated invariant or change failure semantics.
|
|
22
|
+
|
|
23
|
+
### Dependency and API authenticity
|
|
24
|
+
|
|
25
|
+
- Verify new imports against the repository's installed dependencies or the standard library.
|
|
26
|
+
- Verify new third-party API calls against the installed version or repository source; do not rely on memory.
|
|
27
|
+
- Do not add a dependency for small, clear logic already served by local code or the platform.
|
|
28
|
+
|
|
29
|
+
### Behavior integrity
|
|
30
|
+
|
|
31
|
+
- Refactoring preserves observable inputs, outputs, errors, side effects, and ordering unless the accepted task authorizes a behavior change.
|
|
32
|
+
- Do not mix unrelated bug fixes, cleanup, or speculative refactors into the task.
|
|
33
|
+
|
|
34
|
+
### Executable relevance
|
|
35
|
+
|
|
36
|
+
- Do not add configuration, switches, extension points, exports, or production paths without a current caller or accepted requirement.
|
|
37
|
+
- Remove unused imports, dead branches, commented-out implementations, and duplicate domain rules introduced by the change.
|
|
38
|
+
|
|
39
|
+
## Maintainability Heuristics
|
|
40
|
+
|
|
41
|
+
Use these as contextual investigation signals, not universal gates:
|
|
42
|
+
|
|
43
|
+
- Names should communicate the domain meaning in their local context.
|
|
44
|
+
- Functions should have a coherent responsibility and a complexity that remains verifiable.
|
|
45
|
+
- Parameters should model a real input relationship rather than hide unrelated values.
|
|
46
|
+
- Comments should explain constraints or reasons that are not apparent from the code.
|
|
47
|
+
- Repetition is a problem when it duplicates domain knowledge, not merely because text looks similar.
|
|
48
|
+
- Introduce an abstraction when existing complexity or multiple real consumers justify it; do not add interfaces, factories, strategies, flags, or configuration for hypothetical future use.
|
|
49
|
+
|
|
50
|
+
There are no hard line-count, parameter-count, nesting, complexity, boolean-parameter, or identifier blacklist thresholds. A heuristic becomes review-relevant only when the current change creates a concrete correctness, regression, security, or material maintenance risk.
|
|
51
|
+
|
|
52
|
+
## Review Decision Policy
|
|
53
|
+
|
|
54
|
+
- `blocking`: a concrete correctness, security, error-state, dependency/API authenticity, test-integrity, or unauthorized-behavior defect.
|
|
55
|
+
- `advisory`: a concrete task-local maintenance risk worth fixing in this change, with an affected path and failure rationale.
|
|
56
|
+
- Pure formatting, naming preference, line count, parameter count, design taste, and hypothetical extensibility produce no finding.
|
|
57
|
+
- A passing Review has no findings. Do not turn low-value suggestions into `rework` merely to preserve them.
|
|
58
|
+
- Findings identify the affected path and risk. Review reports risks and verification criteria; it does not edit code or generate patches.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Immune-Brain Pi Preferences
|
|
2
2
|
|
|
3
|
-
Pi
|
|
3
|
+
Pi and Claude Code are supported code-agent hosts. Immune-Brain does not load an
|
|
4
4
|
agent-local TOML file or Immune-Brain-specific environment overrides. User and
|
|
5
5
|
project preferences belong in Pi-injected `AGENTS.md` instructions.
|
|
6
6
|
|
|
@@ -22,7 +22,7 @@ Apply the gate when the task touches one or more of these surfaces:
|
|
|
22
22
|
- **design-depth classification**: for a change with a Technical Design concern, record why it is Low, Medium, or High risk. Every new or revised Spec records `**Design risk**: Low|Medium|High` with an adjacent rationale. Medium/High risk requires a Technical Design baseline in the Spec; Low risk may remain concise only when it has no contract, ownership, security, persistence, compatibility, or multi-component concern.
|
|
23
23
|
- **Technical Design baseline**: keep the Spec as the single design authority and make each Plan Step reference the applicable decision or invariant instead of duplicating design prose.
|
|
24
24
|
- **design-view selection**: for Medium/High risk, select every materially relevant technical-design view from architecture layers, service/component interfaces, data flow, state transitions, and temporal sequence. Record selected views and why omitted views cannot affect the design. Low risk remains concise.
|
|
25
|
-
- **TaskIntent decomposition**: use Technical Design boundaries as one retain/split criterion with outcome, Verification, dependency, risk, rollback, compatibility, and authority. Split a successor TaskIntent only when a service, state-machine owner, migration, independently promotable layer, or sequence dependency needs independent verification, rollback, authorization, or settlement. Do not split merely because the design names several layers, files, or services, and do not revive prose Plan authority.
|
|
25
|
+
- **TaskIntent decomposition**: use Technical Design boundaries as one retain/split criterion with outcome, Verification, dependency, risk, rollback, compatibility, and authority. Split a successor TaskIntent only when a service, state-machine owner, migration, independently promotable layer, or sequence dependency needs independent verification, rollback, authorization, or settlement. A TaskIntent should normally change one primary trust-boundary invariant, but traversing several boundaries or updating both sides of one authority chain does not itself require a split. Split independently verifiable, reversible, authorizable, migratable, or settleable trust invariants. Keep multiple trust-boundary changes together only for one atomic security outcome whose split would create an unsafe or unusable intermediate state, and record that rationale in the Spec. Treat this as Planner judgment rather than a schema field or Enrollment counting rule. Do not split merely because the design names several layers, files, or services, and do not revive prose Plan authority.
|
|
26
26
|
- **Mermaid intent**: use Mermaid only when it clarifies structure, sequence, data flow, or state transitions; it is not a universal gate or a second source of truth. Every new or revised Spec records `**Diagram decision**: required|not_required` and a non-empty `**Diagram reason**:`. A `required` decision must include Mermaid; `not_required` explains why prose is sufficient.
|
|
27
27
|
- **Design Conformance**: before final closure, require Spec-to-implementation evidence. A local implementation mismatch routes to `rework`; a structural or intended design change routes to `replan` through Planner. QA cannot silently approve a design change.
|
|
28
28
|
- **Brainstorm traceability**: ensure every `BR-*` item listed in `Brainstorm manifest` is mapped in `Brainstorm Trace`.
|
|
@@ -56,11 +56,13 @@ Immune-Brain owns Role, evidence, authority, tool policy, and output contracts.
|
|
|
56
56
|
Pi Host owns model, provider, and thinking defaults. Immune-Brain does not define
|
|
57
57
|
model tiers, provider mapping, cost routing, or provider fallback.
|
|
58
58
|
|
|
59
|
-
Agent
|
|
60
|
-
host-native `Agent.model
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
Agent defaults to the current Pi session model. Only an explicit Parent requirement
|
|
60
|
+
selects another Pi-configured model through host-native `Agent.model`. Kernel
|
|
61
|
+
Review returns a complete foreground `Agent` envelope with empty `name`, `model`,
|
|
62
|
+
`thinking`, `resume`, and `schedule` fields so Pi Host resolves the Review agent
|
|
63
|
+
configuration. The Parent may use any compatible foreground Agent adapter and
|
|
64
|
+
submits the resulting structured verdict directly; lifecycle event matching is
|
|
65
|
+
not part of the local authority contract.
|
|
64
66
|
|
|
65
67
|
## Pi Agent Invocation
|
|
66
68
|
|
|
@@ -69,23 +71,27 @@ Agent:
|
|
|
69
71
|
subagent_type: "general-purpose"
|
|
70
72
|
description: "<role>/<lens> review"
|
|
71
73
|
prompt: <delegation packet>
|
|
72
|
-
|
|
74
|
+
name: <optional; empty for Kernel authority Review>
|
|
75
|
+
model: <optional Pi-configured model id; empty to inherit the Review agent config>
|
|
76
|
+
thinking: <optional; empty to inherit the Review agent config>
|
|
73
77
|
inherit_context: false
|
|
74
78
|
run_in_background: false
|
|
79
|
+
resume: ""
|
|
80
|
+
schedule: ""
|
|
75
81
|
```
|
|
76
82
|
|
|
77
|
-
Pi `Agent`
|
|
83
|
+
Pi `Agent` has no `readonly` parameter; the empty tool policy, child type, and prompt contract enforce the read-only boundary. The Parent starts one foreground Agent at a time and consumes its direct result before deciding whether another child is needed. Advisory and discovery work does not call `get_subagent_result` or depend on completion notifications or host `followUp`. Kernel Review uses `subagent_type: "Review"`; its structured verdict is submitted by the Parent and validated against the current immutable snapshot. Loop `arch-explorer` uses `subagent_type: "Explore"`; other advisory/discovery and Loop internal roles use `general-purpose`.
|
|
78
84
|
|
|
79
85
|
## Scheduling And Visibility
|
|
80
86
|
|
|
81
87
|
1. Planning、repository exploration、specialist advisory Review 和 work probe 必须 foreground 执行。Parent launches one child at a time,消费 direct terminal result,并在每个结果后 re-evaluates the remaining dispatch budget;不得把多个 foreground Agent 假定为并发 batch。
|
|
82
88
|
2. 普通 interactive advisory 不建立 acknowledgement deadline、后台 progress UI、completion push 或 late-notification recovery。活跃 Agent 使用 Pi 原生 foreground Tool row、host cancellation 和 steer。Footer 保持严格为空;No defined-value `setStatus` call is allowed。
|
|
83
|
-
3. Kernel Assurance runs in the foreground Tool call. `advance_assurance` awaits deterministic QA, emits bounded native updates, and returns
|
|
89
|
+
3. Kernel Assurance runs in the foreground Tool call. `advance_assurance` awaits deterministic QA, emits bounded native updates, and returns `review_ready` with foreground `Agent` parameters. The Parent invokes a reviewer, reads its direct result, and passes the structured verdict to `submit_review`. `request_authorization` is the only literal-user confirmation path. AbortSignal cancellation before authority commit and snapshot/CAS revalidation remain mandatory.
|
|
84
90
|
4. Kernel Assurance chat uses native Tool rendering only. It does not publish completion messages or wake a later parent turn; the direct Tool result is the continuation boundary. `awaiting_user` remains valid until the host-built authorization operation is confirmed and the immutable snapshot is revalidated.
|
|
85
91
|
5. Child 不得再次派发 child,nested delegation 一律禁止。Parent 保留综合与最终判断责任。
|
|
86
|
-
6. Kernel authority Review 对每个 immutable snapshot 恰好一个 primary reviewer,turn 预算按 workload 缩放(Quick 12 / Standard 16 / Heavy 24),并使用该 snapshot 对应的 Quick/Standard/Heavy 执行档位;不存在从 initial dispatch 起算的单一端到端总预算。Reviewer 必须先验证 immutable
|
|
87
|
-
7. Foreground assurance never sleeps, polls, or schedules a completion callback. One Tool call owns QA
|
|
88
|
-
8.
|
|
92
|
+
6. Kernel authority Review 对每个 immutable snapshot 恰好一个 primary reviewer,turn 预算按 workload 缩放(Quick 12 / Standard 16 / Heavy 24),并使用该 snapshot 对应的 Quick/Standard/Heavy 执行档位;不存在从 initial dispatch 起算的单一端到端总预算。Reviewer 必须先验证 immutable v5 manifest 的 `base_head`、`review_commit`、单一 parent、`review_tree` 与 `manifest_digest`,再用只读 Git 命令从 synthetic revision 获取源码;manifest 只有 metadata,不复制 source bytes,也不枚举 neighborhood files。审查只围绕 acceptance assertions 与 `changed_paths`,未变更路径只有在 acceptance、changed caller 或同一 state machine 直接需要时按需读取并注明理由;Reviewer 不探索无关 repository paths。对 settlement-class change,Reviewer 必须先枚举 immutable revision 内每条 terminal、cancellation、timeout 与 race path,再对全部路径给出判断;finding summary 必须以受影响路径开头。每个 acceptance 的执行结果已由 deterministic QA 在 review 前验证并内嵌于 manifest 的 `outcomes` 字段(acceptance_id -> {status, summary});Reviewer 不得重跑 descriptor,也不得把本地没有测试运行当作 finding——Review 只审 revision provenance、代码正确性、回归、安全与缺失测试。除该 reviewer 外,同一触发点最多两个相互独立的 advisory/discovery children;它们只能并行读,不能写 workflow state、关闭 QA 或产生 authority。
|
|
93
|
+
7. Foreground assurance never sleeps, polls, or schedules a completion callback. One Tool call owns QA; one Parent turn obtains and submits the reviewer verdict; one explicit authorization operation owns the critical-risk user decision.
|
|
94
|
+
8. `submit_review` validates the verdict contract, task identity, immutable snapshot digest, and fresh record/Intent/workspace/diff revisions before applying Review authority. Malformed verdicts are retryable without rebuilding evidence. Stale verdicts leave the TaskRecord unchanged and release the stale reservation. Local execution trusts the Parent to relay the reviewer verdict and does not require Agent lifecycle receipts.
|
|
89
95
|
9. The assurance Tool checks the immutable snapshot before each phase and returns a terminal structured state directly: `cancelled`, `rework`, `review_ready`, `awaiting_user`, `blocked`, or `settlement_unknown`. The commit boundary is non-cancellable. No silent task, status timer, completion notification, or result retrieval path is permitted.
|
|
90
96
|
|
|
91
97
|
## Result Synthesis
|
|
@@ -100,6 +106,6 @@ Parent workflow role 必须:
|
|
|
100
106
|
|
|
101
107
|
普通 advisory/discovery 的每次启动都消耗一个 candidate budget slot;失败、取消、timeout 或 result_untrusted 均丢弃该输出且不得自动重试。Parent 仅在剩余候选仍独立有用且 evidence budget 仍需要时继续,否则转 solo/fail-closed fallback,并记录 `dispatch_failed` 或 `child_timeout`。该规则不改变 Kernel authority Review 的显式恢复协议。Child 永远不获得实现、Plan write、workflow mutation 或 QA closure authority。
|
|
102
108
|
|
|
103
|
-
Kernel
|
|
109
|
+
If Kernel Review dispatch fails, the Parent does not call `submit_review`; the existing Review reservation and immutable evidence remain available for a later foreground retry. A malformed verdict may be corrected and resubmitted. A stale snapshot, explicit release, successful settlement, or session shutdown removes the reservation and evidence. There is no retry counter, dispatch receipt state machine, or provider-specific recovery path.
|
|
104
110
|
|
|
105
|
-
|
|
111
|
+
This protocol is provider- and host-adapter-agnostic for local execution.
|
|
@@ -19,8 +19,8 @@ Dispatch authorization follows the [shared Subagent Dispatch
|
|
|
19
19
|
Protocol](docs/reference/subagent-dispatch-protocol.md#authorization-authority).
|
|
20
20
|
Same-boundary `follow_up` is not a Plan mutation; it repeats the current
|
|
21
21
|
execution, QA, and originating review gate. All internal Agent dispatch
|
|
22
|
-
envelopes use `run_in_background: false` and return
|
|
23
|
-
|
|
22
|
+
envelopes use `run_in_background: false` and return a direct result to the Parent
|
|
23
|
+
before any workflow mutation.
|
|
24
24
|
|
|
25
25
|
## Workflow Profiles
|
|
26
26
|
|
|
@@ -52,7 +52,7 @@ Repeat this sequence; do not silently stop while a valid action remains:
|
|
|
52
52
|
1. Call `imm_loop_action` with `op: route` (or `dispatch_role` at a QA/review boundary) and follow the projected `next` authority.
|
|
53
53
|
2. Emit one progress line: `[target][phase] result | next: action`.
|
|
54
54
|
3. Execute exactly one allowed action:
|
|
55
|
-
- Kernel ownership: call `imm_kernel_canary` for that owned task. Freeze the completed artifacts, then call `advance_assurance`; when it returns `review_ready`, invoke the
|
|
55
|
+
- Kernel ownership: call `imm_kernel_canary` for that owned task. Freeze the completed artifacts, then call `advance_assurance`; when it returns `review_ready`, invoke the foreground reviewer and pass its structured verdict to `submit_review`. When the projection calls for `request_authorization`, `approve_breaking_intent_revision`, or `repair_authority_state`, invoke the exact Tool operation directly without asking the user for chat pre-confirmation. The native host interaction is the single authority decision.
|
|
56
56
|
- Active Step / `rework_needed`: follow the returned `executor` context in the current conversation, implement only the active Step or pending same-boundary `follow_up`, verify, record structured execution evidence through the Loop runtime action, and continue. A bounded test-only repair may request internal `test-fixer` with `focus_delta.specific_changes`; PR review or CI repair may request internal `pr-fix` with the current `plan_id`, changed-file boundary, and verification. Both return child evidence to the Parent and cannot widen scope.
|
|
57
57
|
- `awaiting_qa_decision`: call `imm_loop_action` with `op: dispatch_role`, role `qa`, the current projection, Plan verification, recorded evidence, and current target identity. Invoke the returned foreground Agent envelope exactly. A `rework` or `replan` must carry validated `notes`.
|
|
58
58
|
- `review_required`: map the exact `pending_review_gate` (`imm-code-review` or `imm-ui-review`) to the internal `code-review` or `ui-review` role and call `imm_loop_action` with `op: dispatch_role`, passing `pending_review_gate`, `review_changed_files`, and `review_changed_files_signature`. Invoke the returned foreground Agent envelope exactly. Record a validated pass, or open a same-boundary follow-up through the Loop runtime action.
|
|
@@ -150,9 +150,8 @@ single authority decision. This action is not a public Skill or CLI route. Do
|
|
|
150
150
|
not invoke the removed `imm-canary-work` Skill as a separate entry point.
|
|
151
151
|
Invalid or contradictory projections fail closed. After implementation and focused verification, freeze the artifacts and call
|
|
152
152
|
`imm_kernel_canary` `advance_assurance`. If it returns `review_ready`, invoke
|
|
153
|
-
the
|
|
154
|
-
`request_authorization` remains the user authorization boundary.
|
|
155
|
-
background
|
|
156
|
-
result polling. A terminal task leaves only an immutable task tombstone: it is
|
|
153
|
+
the foreground reviewer and pass its structured verdict to `submit_review`;
|
|
154
|
+
`request_authorization` remains the user authorization boundary. Foreground
|
|
155
|
+
results replace background continuation and result polling. A terminal task leaves only an immutable task tombstone: it is
|
|
157
156
|
never reactivated and never blocks unrelated v3 routing. The Kernel projection
|
|
158
157
|
is advisory; every Kernel mutation re-enters Kernel store-lock validation.
|
|
@@ -217,7 +217,7 @@ descriptors or add a mandatory user confirmation. Use the smallest `timeout_ms`
|
|
|
217
217
|
- **Design-Depth Classification**: Classify change design risk with the smallest sufficient tier: **Low risk** (copy, configuration, trivial rename, or contained local fix) may omit a separate Technical Design; **Medium risk** (non-trivial single-module behavior or internal contract) records affected components, decisions, invariants, failure behavior, and verification implications; **High risk** (cross-module/API/data-flow/state-machine, security, migration, concurrency, architecture ownership, cross-runtime/package-contract, or persisted-state work) records boundaries, interfaces or flow, alternatives, invariants, rollback/compatibility, and verification implications. Medium and High risk require Technical Design in the Spec. Do not classify a change as Low risk when it has a contract, ownership, security, persistence, compatibility, or multi-component concern. Every new or revised Spec records `**Design risk**: Low|Medium|High` with an adjacent rationale.
|
|
218
218
|
- **Design-view selection**: For Medium and High risk, select every materially relevant technical-design view from architecture layers, service/component interfaces, data flow, state transitions, and temporal sequence. Record a short `Design views` statement naming the selected views and why any omitted view cannot affect the design. Do not write empty architecture, interface, data-flow, state, or sequence sections. Low risk remains concise and may omit Technical Design. When a selected view is recorded, also record its required decision content: architecture layers need layer responsibilities, dependency direction, ownership, and prohibited coupling; service/component interfaces need inputs, outputs, errors, compatibility/versioning, and caller/callee ownership; data flow needs source, transformations, validation, destination, and failure handling; state transitions need states, legal transitions, trigger, invariant, terminal ownership, and recovery; temporal sequence needs ordered interactions, authority at each point, interruption behavior, and idempotency.
|
|
219
219
|
- **Technical Design Authority**: The Spec is the single Technical Design baseline. TaskIntent acceptance and scope reference the applicable design decisions or invariants without copying Technical Design prose. If discovery invalidates the baseline, stop execution and return to Planner to update the Spec and decide whether `replan` is required. TaskIntent and Initiative text do not duplicate Technical Design prose or become a prose Plan substitute.
|
|
220
|
-
- **TaskIntent decomposition**: Use the selected design boundaries as one retain/split criterion for TaskIntent slices. Keep work in one TaskIntent when the selected views describe one coherent executable slice with shared acceptance, risk treatment, rollback, and authority. Split a successor TaskIntent when a service boundary, state-machine owner, migration/compatibility boundary, independently promotable layer, or sequence dependency needs independent verification, rollback, authorization, or settlement. Do not split merely because the design names several layers, files, or services. This does not revive prose Plan, Roadmap, or Phase authority.
|
|
220
|
+
- **TaskIntent decomposition**: Use the selected design boundaries as one retain/split criterion for TaskIntent slices. Keep work in one TaskIntent when the selected views describe one coherent executable slice with shared acceptance, risk treatment, rollback, and authority. Split a successor TaskIntent when a service boundary, state-machine owner, migration/compatibility boundary, independently promotable layer, or sequence dependency needs independent verification, rollback, authorization, or settlement. Do not split merely because the design names several layers, files, or services. Treat trust-boundary changes as the same kind of decomposition evidence: a TaskIntent should normally change one primary trust-boundary invariant, while merely traversing several boundaries or updating both sides of one end-to-end authority chain does not require a split. Split separate trust invariants when they can be independently verified, rolled back, authorized, migrated, or settled. Keep multiple trust-boundary changes together only when they form one atomic security outcome and splitting would create an unsafe or unusable intermediate state; record that reason in the Spec. This is Planner judgment, not a TaskIntent schema field or an Enrollment counting rule. This does not revive prose Plan, Roadmap, or Phase authority.
|
|
221
221
|
- **Mermaid Use**: Mermaid is required only when a medium/high-risk design contains structure, sequence, data flow, or state transition relationships that a diagram materially clarifies. Mermaid is not a universal gate; a diagram supplements adjacent prose and never becomes a second design authority. Every new or revised Spec records `**Diagram decision**: required|not_required` and a non-empty `**Diagram reason**:`. A `required` decision must have a Mermaid block; `not_required` explains why prose is sufficient.
|
|
222
222
|
- **Verification**: Every step must name the result and verification path. If the evidence path is still hypothetical, do not label the step execution-ready.
|
|
223
223
|
- **Executable Scope**: Every new code-changing Step must declare one or more bounded project-relative paths in `- Scope: \`path\`, \`directory/\`, ...`. Runtime derives the actual Git delta and rejects evidence outside these paths. Keep Scope wide enough for the promised Result but never use an unbounded wildcard. Omitting `Scope` does not relax the boundary, it removes it: there is nothing to compare the delta against, so runtime records the evidence as `scope_boundary: undeclared` and review inherits a change set with no statement of what was supposed to change. `Discovery cache` does not substitute — it names paths worth reading, not paths this Step commits to changing.
|
|
@@ -55,6 +55,15 @@ uncertain. Never delegate push, merge, approval, or scope decisions.
|
|
|
55
55
|
When a blocker requires a product decision or work outside the PR's intended
|
|
56
56
|
scope, stop and report the exact decision or scope expansion needed.
|
|
57
57
|
|
|
58
|
+
## Code Quality Guard
|
|
59
|
+
|
|
60
|
+
Apply the packaged Code Quality Guard reference at
|
|
61
|
+
`docs/reference/code-quality-guard.md` when repairing implementation
|
|
62
|
+
blockers. Do not make a PR appear healthy by swallowing unexpected errors,
|
|
63
|
+
fabricating success, weakening tests, inventing APIs or dependencies, changing
|
|
64
|
+
unrelated behavior, or widening the blocker scope. Style-only preferences are
|
|
65
|
+
not repair blockers.
|
|
66
|
+
|
|
58
67
|
### 4. Verify and close out
|
|
59
68
|
|
|
60
69
|
Run the smallest checks that reproduce each blocker, then any repository check
|
|
@@ -1,15 +1,35 @@
|
|
|
1
1
|
# Internal role: code-review
|
|
2
2
|
|
|
3
|
-
You are the Immune-Brain read-only code review role inside Loop. Review
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
You are the Immune-Brain read-only code review role inside Loop. Review the
|
|
4
|
+
immutable Git revision and bounded evidence supplied by the Parent. For
|
|
5
|
+
`assurance_kernel/review_manifest/v5`, read the metadata manifest first, verify
|
|
6
|
+
`base_head`, `review_commit`, its single parent, `review_tree`, and
|
|
7
|
+
`manifest_digest`, then inspect source only with read-only Git commands such as
|
|
8
|
+
`git diff <base_head> <review_commit>` and `git show <review_commit>:<path>`.
|
|
9
|
+
Never read live worktree bytes as evidence, enumerate neighborhood files, or
|
|
10
|
+
infer task ownership from unchanged paths. Read an unchanged path only when an
|
|
11
|
+
acceptance assertion, changed caller, or same state machine directly requires
|
|
12
|
+
it, and cite the path and reason in the finding. The manifest is metadata only;
|
|
13
|
+
source content must not be copied into the review envelope.
|
|
14
|
+
|
|
15
|
+
Do not edit files, mutate workflow state, approve a successor, or invoke
|
|
16
|
+
another role. The stable Review Gate is `imm-code-review`.
|
|
17
|
+
|
|
18
|
+
## Code Quality Guard
|
|
19
|
+
|
|
20
|
+
Apply the Code Quality Guard reference to the immutable revision: reject
|
|
21
|
+
fabricated success, unknown-error suppression, missing external-boundary
|
|
22
|
+
validation, invented imports/APIs, weakened tests, unauthorized behavior
|
|
23
|
+
changes, and speculative production paths when the diff creates a concrete
|
|
24
|
+
risk. Report only evidence-based correctness, security, regression, or
|
|
25
|
+
material task-local maintenance risks. Pure naming, length, complexity
|
|
26
|
+
thresholds, formatting, and design preference are not findings and must not
|
|
27
|
+
cause style-only rework.
|
|
28
|
+
|
|
29
|
+
Return exactly one JSON object with the fields required by the Loop review
|
|
30
|
+
contract: `contract`, `role`, `task_id`, `snapshot_digest`, `decision` (`pass`
|
|
31
|
+
or `rework`), and for `pass` include `approval` (`kind`, `authority_role`,
|
|
32
|
+
`summary`), for `rework` include `findings` (`id`, `kind`, `acceptance_id`,
|
|
33
|
+
`summary`). Do not invent fields. A passing review has no findings. If the
|
|
34
|
+
checkpoint is `awaiting_user_successor_decision`, stop without dispatch; only
|
|
35
|
+
a literal user may invoke `--approve-successor`.
|
|
@@ -11,3 +11,17 @@ action. Preserve failed and blocked attempts. Do not perform QA,
|
|
|
11
11
|
review, plan mutation, successor approval, Compounder work, or authority
|
|
12
12
|
writes. If the requested change needs scope expansion, stop and return an
|
|
13
13
|
`imm-planner` route with the concrete missing scope and verification reason.
|
|
14
|
+
|
|
15
|
+
## Code Quality Guard
|
|
16
|
+
|
|
17
|
+
Before handoff, check the implementation for real implementation rather than
|
|
18
|
+
mock or hard-coded success, swallowed unexpected errors, missing validation at
|
|
19
|
+
external trust boundaries, invented dependencies or APIs, unauthorized
|
|
20
|
+
observable behavior changes, and production paths without a current caller.
|
|
21
|
+
Do not weaken tests or hide an incomplete result to make Verification pass.
|
|
22
|
+
Treat naming, function length, parameter count, nesting, and abstraction taste
|
|
23
|
+
as contextual signals, never as automatic failure thresholds.
|
|
24
|
+
|
|
25
|
+
Fix in-scope integrity defects before Verification. If fixing one requires
|
|
26
|
+
behavior, scope, or authority beyond the active Step, stop and route the
|
|
27
|
+
concrete reason to `imm-planner`.
|
|
@@ -60,6 +60,15 @@ shard on failure; on second failure, fall back to solo repair.
|
|
|
60
60
|
Re-run project checks and PR-related conflict checks. Compare local HEAD
|
|
61
61
|
against PR head expectation before push.
|
|
62
62
|
|
|
63
|
+
## Code Quality Guard
|
|
64
|
+
|
|
65
|
+
Apply the same integrity boundary while repairing a blocker. Do not clear CI or
|
|
66
|
+
review feedback by swallowing unexpected errors, fabricating success, or using
|
|
67
|
+
a repair that would weaken tests, invent an unavailable API or dependency,
|
|
68
|
+
change unrelated behavior, or widen the PR beyond the named blocker. Preserve
|
|
69
|
+
the PR's observable intent. If the correct repair needs new scope or a product
|
|
70
|
+
decision, stop and report it to the Parent.
|
|
71
|
+
|
|
63
72
|
## Boundary
|
|
64
73
|
|
|
65
74
|
Work only inside the supplied Plan, `plan_id`, changed-file boundary, review
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
# Internal role: test-fixer
|
|
2
2
|
|
|
3
3
|
You are the Immune-Brain bounded test-repair role inside Loop. Edit only the delegated test files listed in `focus_delta.specific_changes` for the active target. Run the supplied `verification_hint`, return structured child evidence, and stop when the delegated test boundary is satisfied. Do not edit production code, plan files, workflow state, or unrelated tests. Do not discover or load a Pi Skill, invoke another role, approve QA, or widen the delegated file list. If the failure requires production changes or broader scope, report that boundary finding to the Parent instead of editing beyond it.
|
|
4
|
+
|
|
5
|
+
## Code Quality Guard
|
|
6
|
+
|
|
7
|
+
Preserve test intent while repairing tests. Do not delete or loosen assertions,
|
|
8
|
+
reduce coverage, replace target behavior with a mock, or change expected
|
|
9
|
+
behavior solely to make the test pass. A production defect is a boundary
|
|
10
|
+
finding for the Parent, not permission to edit production code.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "Observe Claude Code Review and session lifecycle for Immune-Brain. Hooks never mint authority.",
|
|
3
|
+
"hooks": {
|
|
4
|
+
"SubagentStart": [
|
|
5
|
+
{
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/dist/claude/mcp-server.mjs\" --hook"
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"PostToolUse": [
|
|
15
|
+
{
|
|
16
|
+
"hooks": [
|
|
17
|
+
{
|
|
18
|
+
"type": "command",
|
|
19
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/dist/claude/mcp-server.mjs\" --hook"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"SubagentStop": [
|
|
25
|
+
{
|
|
26
|
+
"hooks": [
|
|
27
|
+
{
|
|
28
|
+
"type": "command",
|
|
29
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/dist/claude/mcp-server.mjs\" --hook"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"ElicitationResult": [
|
|
35
|
+
{
|
|
36
|
+
"hooks": [
|
|
37
|
+
{
|
|
38
|
+
"type": "command",
|
|
39
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/dist/claude/mcp-server.mjs\" --hook"
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"SessionEnd": [
|
|
45
|
+
{
|
|
46
|
+
"hooks": [
|
|
47
|
+
{
|
|
48
|
+
"type": "command",
|
|
49
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/dist/claude/mcp-server.mjs\" --hook"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
}
|