Harness Integration
Verify system wiring, materialize knowledge artifacts, and update project metadata. Integration is a gate, not a discovery phase -- it confirms that planned integration tasks completed.
When to Use
- After execution completes and verification passes (between VERIFY and REVIEW in the workflow)
- When the autopilot state machine reaches the INTEGRATE state
- When validating that a feature is properly wired into the system (barrel exports, skill discovery, route mounts)
- When materializing architectural decisions as durable ADRs
- When invoked standalone to check integration completeness of a feature branch
- NOT as a replacement for verification (verification checks code correctness; integration checks system connectivity)
- NOT for discovering integration work (integration work is planned upfront in brainstorming and planning)
- NOT for implementing fixes (integration identifies gaps; the executor fixes them)
Process
Iron Law
No integration claim may be made without checking every planned integration task against the codebase.
Integration checking is mechanical: did the planned task produce the expected artifact? "It should be there" is not evidence. Check the file, check the import, check the registration. Report what you observed.
The words "should", "probably", "seems to", and "I believe" are forbidden in integration reports. Replace with "verified: [evidence]" or "not verified: [what is missing]."
Argument Resolution
When invoked by autopilot (or with explicit arguments), resolve paths before starting:
- Session slug: If
session-slug argument provided, set {sessionDir} = .harness/sessions/<session-slug>/. Pass to gather_context({ session: "<session-slug>" }). All report writes go to {sessionDir}/.
- Plan path: Discover from
{sessionDir}/handoff.json (read upstream execution/verification output). The plan contains integration tasks tagged category: "integration" and the integrationTier field.
- Rigor level: If
fast/thorough argument provided, use it. Otherwise default to standard.
When no arguments are provided (standalone invocation), discover plan from docs/changes/<topic>/plans/ (preferred) or docs/plans/ (legacy fallback) or prompt. Global .harness/ paths used as fallback.
Tier Resolution
Before running sub-phases, resolve the effective integration tier:
Read plan-time tier. Extract integrationTier from the plan header (small, medium, or large). If absent, default to small.
Derive execution-time tier. Read the execution start commit from the session handoff (startCommit field in {sessionDir}/handoff.json). If unavailable, use the autopilot's startingCommit from {sessionDir}/autopilot-state.json. Diff startCommit..HEAD to analyze the execution phase:
newPackages > 0 -> large
newPublicExports > 5 -> large (minimum)
filesChanged > 15 AND newExports -> medium (minimum)
else -> keep plan estimate
To count these signals:
newPackages: count new package.json files in the diff
newPublicExports: count new export statements in barrel/index files
filesChanged: count total files changed in the diff
newExports: boolean, true if any new export statements exist
Apply max(planned, derived). The effective tier is the higher of the two.
Notify on escalation. If derived tier exceeds planned tier, notify the human:
Tier escalated from `small` to `medium`: 8 new exports detected.
Inform the human and get acknowledgment in plain text in your reply (do NOT route this through emit_interaction or AskUserQuestion — they record the prompt but do not display it to the human, so they won't see it).
Rigor Level Interaction
| Rigor |
INTEGRATE behavior |
fast |
WIRE only (default checks), auto-approve, no ADR drafting |
standard |
Full tier-appropriate checks (WIRE for all; MATERIALIZE + UPDATE for medium and large) |
thorough |
Full checks + human reviews every ADR draft + force knowledge graph verification |
Context Loading
Before running sub-phases, load session context:
gather_context({
path: "<project-root>",
intent: "Verify integration of executed plan",
skill: "harness-integration",
session: "<session-slug-if-provided>",
include: ["state", "learnings", "handoff", "graph", "businessKnowledge", "sessions", "validation"]
})
Load the plan, identify integration tasks (tagged category: "integration"), and group them by sub-phase:
- WIRE tasks: Entry point registration, barrel exports, skill discovery, route mounts
- MATERIALIZE tasks: ADR writing, knowledge graph enrichment, documentation updates
- UPDATE tasks: Roadmap sync, changelog, spec cross-references
Sub-Phase 1: WIRE (all tiers)
Report progress: **[WIRE]** Checking system wiring
WIRE always runs, regardless of tier. It has two parts: default checks (always) and task-specific checks (when integration tasks exist).
Default Checks (always run)
These run even with zero explicit integration tasks (D8: barrel exports and validation are cheap and catch real problems).
Barrel export check. Run pnpm run generate-barrel-exports --check. If the --check flag is not supported, fall back to:
- Run
pnpm run generate-barrel-exports
- Run
git diff --name-only
- If barrel files changed, the previous execution missed this step. Record as FAIL with the list of changed barrel files.
- If no changes, barrel exports are current. Record as PASS.
Harness validate. Run pnpm harness validate. Must pass. Record result.
Task-Specific Checks (when integration tasks exist)
For each integration task tagged category: "integration" that relates to wiring:
Entry point reachability. Trace from known entry points to new code:
- CLI: search for the new command/function in the
createProgram() registration chain
- MCP: search for the new tool in
getToolDefinitions() or tool registration files
- Skill: verify
skill.yaml + SKILL.md exist at the expected path and skill appears in harness skill list output or discovery glob results
- If the task claims a new entry point, verify it is reachable from at least one system entry point. An unreachable entry point is dead code.
Skill discovery verification. If a new skill was created:
- Verify
agents/skills/claude-code/<skill-name>/skill.yaml exists and has valid YAML
- Verify
agents/skills/claude-code/<skill-name>/SKILL.md exists and is non-empty
- Verify the skill appears in
harness skill list output (or would appear based on glob pattern)
Route mount verification. If a new API route was added:
- Verify the route handler file exists
- Verify the route is imported and mounted in the router/app configuration
- Verify a request to the route path would be handled (trace the mount chain)
Produce wiring report. Write {sessionDir}/integration-wiring.json:
{
"subPhase": "wire",
"tier": "<effective-tier>",
"timestamp": "<ISO-8601>",
"defaultChecks": {
"barrelExports": { "status": "pass|fail", "detail": "<description>" },
"harnessValidate": { "status": "pass|fail", "detail": "<output summary>" }
},
"taskChecks": [
{
"taskRef": "Task N: <name>",
"check": "<what was verified>",
"status": "pass|fail",
"evidence": "<file:line or command output>"
}
],
"verdict": "pass|fail"
}
Sub-Phase 2: MATERIALIZE (medium + large tiers)
Report progress: **[MATERIALIZE]** Checking knowledge materialization
Skip this sub-phase for small tier or fast rigor. For medium and large tiers:
Decision Harvesting
Read handoff decisions. Load {sessionDir}/handoff.json from all phases in this session. Collect all entries from the decisions array.
Classify decisions. For each decision:
- Architectural (large tier): Decisions that affect system structure, introduce new patterns, or change integration boundaries. These warrant ADRs.
- Minor (medium + large tier): Decisions about implementation approach, naming, or local design. These enrich the knowledge graph directly without an ADR.
ADR Auto-Drafting (large tier only)
Auto-draft ADRs from architectural decisions. For each architectural decision:
a. Assign ADR number. Scan docs/knowledge/decisions/ for existing ADR files matching NNNN-*.md. Take the highest number and increment by 1. If the directory does not exist, create it and start at 0001.
b. Generate slug. Convert the decision title to a URL-safe slug (lowercase, hyphens, no special characters).
c. Write ADR to docs/knowledge/decisions/NNNN-<slug>.md:
---
number: NNNN
title: <decision title>
date: <ISO date>
status: accepted
tier: large
source: <spec path or session slug>
supersedes: <prior ADR number, if any>
---
## Context
<What situation prompted this decision? What constraints existed?>
## Decision
<What was decided and why?>
## Consequences
<What follows from this decision -- positive, negative, and neutral?>
d. Present for review. In thorough rigor, present each ADR draft in plain text in your reply and wait for human approval — do NOT route it through emit_interaction or AskUserQuestion, which record the prompt but do not display it to the human (the client collapses the call to "Called harness" and the text only returns to the model). In standard rigor, auto-approve but log the draft for review.
Knowledge Graph Enrichment (medium + large tiers)
- Enrich knowledge graph. For each decision (both architectural and minor):
- Call
ingest_source with the decision metadata so decisions become queryable graph nodes
- For ADR-sourced decisions, the ADR file path is the source
- For minor decisions, the handoff.json decision text is the content
Documentation Task Verification
Verify documentation integration tasks. For each integration task tagged category: "integration" that relates to documentation:
- Verify the specified document was updated (file exists, content includes expected additions)
- Verify AGENTS.md was updated if the task required it
- Verify guides were written if the task required it
Produce materialization report. Write {sessionDir}/integration-materialization.json:
{
"subPhase": "materialize",
"tier": "<effective-tier>",
"timestamp": "<ISO-8601>",
"decisions": {
"total": 0,
"architectural": 0,
"minor": 0
},
"adrs": [
{
"number": "NNNN",
"title": "<title>",
"path": "docs/knowledge/decisions/NNNN-<slug>.md",
"status": "drafted|approved"
}
],
"graphEnrichment": {
"nodesCreated": 0,
"status": "pass|fail|skipped"
},
"documentationChecks": [
{
"taskRef": "Task N: <name>",
"status": "pass|fail",
"evidence": "<description>"
}
],
"verdict": "pass|fail|skipped"
}
Sub-Phase 3: UPDATE (medium and large tiers)
Report progress: **[UPDATE]** Checking project metadata updates
Skip this sub-phase for small tier or fast rigor. For medium and large tiers:
Roadmap sync. If docs/roadmap.md exists, call manage_roadmap with sync and apply: true to update feature status. If manage_roadmap is unavailable, fall back to noting the roadmap needs manual sync.
Changelog verification. If CHANGELOG.md exists at the project root:
- Read the file and check for a new entry matching the current feature
- If no entry exists, record as FAIL with instruction: "Add a changelog entry for this feature under the Unreleased section."
- If no
CHANGELOG.md exists, skip silently (not all projects use changelogs)
Spec cross-reference annotation. Read the spec at its path (from the plan or handoff):
- For each phase in the spec's Implementation Order, check if implementation files can be linked
- If the spec does not have file annotations, note this as an improvement suggestion (not a failure)
Produce update report. Write {sessionDir}/integration-updates.json:
{
"subPhase": "update",
"tier": "<effective-tier>",
"timestamp": "<ISO-8601>",
"roadmap": { "status": "synced|skipped|failed", "detail": "<description>" },
"changelog": { "status": "pass|fail|skipped", "detail": "<description>" },
"specCrossRef": { "status": "annotated|skipped", "detail": "<description>" },
"verdict": "pass|fail|skipped"
}
Combined Report and Verdict
After all applicable sub-phases complete, produce the combined integration report:
Write combined report. Write {sessionDir}/phase-{N}-integration.json:
{
"phase": "integration",
"tier": "<effective-tier>",
"rigor": "<fast|standard|thorough>",
"timestamp": "<ISO-8601>",
"subPhases": {
"wire": { "verdict": "pass|fail", "reportPath": "{sessionDir}/integration-wiring.json" },
"materialize": {
"verdict": "pass|fail|skipped",
"reportPath": "{sessionDir}/integration-materialization.json"
},
"update": {
"verdict": "pass|fail|skipped",
"reportPath": "{sessionDir}/integration-updates.json"
}
},
"verdict": "pass|fail",
"failures": [
{
"subPhase": "<wire|materialize|update>",
"taskRef": "Task N: <name>",
"issue": "<what is incomplete>",
"fix": "<specific fix instruction>"
}
]
}
Report verdict. Summarize pass/fail per sub-phase. On failure, list exactly which integration tasks are incomplete with specific fix instructions.
On PASS: Write handoff and emit transition to REVIEW:
emit_interaction({
path: "<project-root>",
type: "transition",
transition: {
completedPhase: "integration",
suggestedNext: "review",
reason: "Integration passed at all applicable sub-phases",
artifacts: ["<report paths>"],
requiresConfirmation: false,
summary: "Integration passed: tier <tier>. WIRE passed. MATERIALIZE <passed|skipped>. UPDATE <passed|skipped>.",
qualityGate: {
checks: [
{ "name": "wire-checks", "passed": true },
{ "name": "materialize-checks", "passed": true },
{ "name": "update-checks", "passed": true },
{ "name": "harness-validate", "passed": true }
],
allPassed: true
}
}
})
Immediately invoke harness-code-review without waiting for user input.
On FAIL: Do NOT emit a transition. Report incomplete items with fix instructions, then ask the human how to proceed in plain text.
Ask directly in your reply. Do NOT route the question through emit_interaction, AskUserQuestion, or any tool. emit_interaction records the prompt but does not display it to the human — the client collapses the call to "Called harness" and the rendered text only returns to the model, so the human sees nothing and you end up narrating a question they cannot answer. AskUserQuestion is Claude-Code-only and caps headers at 12 chars / 4 options. Plain text in your own message is the only channel that reliably reaches the human across every tool (Claude Code, Cursor, Codex, Gemini CLI).
Present the options as a markdown table, state your recommendation, then STOP and wait for the human's reply:
### Decision needed: Integration failed. <N> items incomplete. How to proceed?
| | fix | skip | stop |
| ---------- | ---------------------------------------------------------------------------------- | ------------------------------------------------------ | ------------------------- |
| **What** | Re-enter EXECUTE with integration-specific fix tasks, then re-VERIFY, re-INTEGRATE | Record decision and proceed to REVIEW (human override) | Save state and exit |
| **Pros** | Closes gaps before review | Unblocks progress immediately | Preserves state for later |
| **Cons** | Another execute/verify cycle | Ships with known gaps | No forward progress |
| **Risk** | Low | Medium | Low |
| **Effort** | Medium | Low | Low |
**Recommendation:** fix (confidence: high) — fixing integration gaps now prevents review rework.
- fix: Record fix tasks in handoff. The autopilot re-enters EXECUTE with those tasks.
- skip: Record the skip decision in
decisions[] in handoff. Proceed to REVIEW.
- stop: Write handoff with current state and stop.
Handoff
Write handoff to the session-scoped path when session slug is known, otherwise fall back to global:
- Session-scoped (preferred):
.harness/sessions/<session-slug>/handoff.json
- Global (fallback, deprecated):
.harness/handoff.json
[DEPRECATED] Writing to .harness/handoff.json is deprecated. In autopilot sessions, always write to .harness/sessions/<slug>/handoff.json to prevent cross-session contamination.
{
"fromSkill": "harness-integration",
"phase": "COMPLETE",
"summary": "<verdict summary>",
"tier": "<effective-tier>",
"artifacts": ["<report paths>", "<ADR paths if any>"],
"verdict": "pass | fail",
"gaps": ["<gap descriptions if any>"],
"decisions": [{ "what": "<decision>", "why": "<rationale>" }]
}
Session summary (if session known): Update via writeSessionSummary with skill, status (Integration <PASS|FAIL>. Tier: <tier>. <N> checks, <N> gaps.), keyContext, and nextStep.
Session State
| Section |
Read |
Write |
Purpose |
| terminology |
yes |
no |
Consistent language in integration reports |
| decisions |
yes |
yes |
Reads all phase decisions for ADR drafting; writes integration decisions |
| constraints |
yes |
no |
Respect existing constraints during checks |
| risks |
yes |
yes |
Reads risks; writes integration risks discovered during checks |
| openQuestions |
yes |
yes |
Reads questions; resolves those answered by integration evidence |
| evidence |
yes |
yes |
Prior evidence; writes wiring, materialization, and update evidence |
When to write: After each sub-phase, append evidence entries. After ADR drafting, write decisions.
When to read: During Context Loading via gather_context with include: ["state", "learnings", "handoff", "graph", "businessKnowledge", "sessions", "validation"].
Evidence Requirements
Every pass/fail assertion in the integration report MUST include concrete evidence:
- File reference:
file:line with observed content (e.g., src/index.ts:12 -- "exports NotificationService")
- Command output: Actual command and output (e.g.,
pnpm run generate-barrel-exports --check -- "No changes detected")
- Harness output:
harness validate output
- Git diff evidence:
git diff --name-only output for barrel export checks
- Discovery evidence:
harness skill list output for skill discovery verification
- Session evidence: Record evidence in the sub-phase report JSON files written to the session directory
When to cite: At every check. Each pass/fail in the wiring, materialization, and update reports must be backed by evidence.
Uncited claims: Any integration assertion without direct evidence is an integration failure. This skill does not use [UNVERIFIED] -- if evidence cannot be produced, verdict is FAIL.
Harness Integration
gather_context -- Load session-scoped state, learnings, handoff, and validation before sub-phases. session parameter scopes to session directory.
harness validate -- Run during WIRE default checks. Must pass.
harness check-deps -- Run during WIRE if new modules were added.
ingest_source -- Run during MATERIALIZE to enrich knowledge graph with decision nodes.
manage_roadmap -- Run during UPDATE to sync roadmap status. Use sync with apply: true.
emit_interaction -- Used only for the transition to REVIEW on pass. Tier escalation, ADR review (thorough mode), and fail/skip/stop decisions are asked in plain text in your reply.
- Session directory --
.harness/sessions/<slug>/ contains all report files. Do not write to global .harness/ when session slug is known.
Success Criteria
- WIRE default checks run for every tier (including small) -- barrel exports current, harness validate passes
- All planned integration tasks verified with evidence
- ADRs drafted for large-tier architectural decisions with correct format and sequential numbering
- Knowledge graph enriched with decision nodes (medium + large tiers)
- Documentation tasks verified as complete (medium + large tiers)
- Roadmap synced, changelog verified (medium + large tiers)
- Combined report written with pass/fail per sub-phase
- Tier derivation correctly escalates when execution exceeds plan estimates
- Fast rigor completes in seconds (WIRE only, no ADRs, no graph enrichment)
- Failure report includes specific fix instructions for each incomplete item
Red Flags
| Flag |
Corrective Action |
| "Barrel exports probably have not changed, so I will skip the check" |
STOP. WIRE default checks always run. "Probably" is forbidden. Run the check and report the result. |
| "The ADR looks correct from the decision text, no need to present for review" |
STOP. In thorough mode, every ADR draft requires human review. In standard mode, auto-approve but log. Do not skip the review protocol. |
| "Integration tasks are just bureaucracy, I will mark them as passed" |
STOP. Integration tasks exist because brainstorming and planning identified real connection points. Each must be verified with evidence. |
| "The knowledge graph enrichment failed but it is not critical" |
STOP. In thorough mode, graph enrichment failure is a FAIL. In standard mode, log the failure and include in the report. |
| "I will fix the missing barrel export myself to make WIRE pass" |
STOP. Integration identifies gaps -- integration never fills them. Record as FAIL with fix instructions. The executor fixes it. |
Rationalizations to Reject
| Rationalization |
Reality |
| "WIRE passed so the feature is properly integrated" |
WIRE checks wiring only. For medium/large tiers, MATERIALIZE and UPDATE must also pass. Partial integration is not integration. |
| "This is a small change, so I can skip tier derivation and just use the plan estimate" |
Tier derivation is mandatory. Even if the plan says small, execution may have produced more changes than expected. Always derive and compare. |
| "The ADR format is close enough, no need to match the exact frontmatter schema" |
ADRs must match the spec format exactly (number, title, date, status, tier, source, supersedes). The knowledge pipeline depends on consistent frontmatter for parsing. |
| "Integration tasks were not in the plan, so there is nothing to check" |
WIRE default checks always run regardless of planned integration tasks (D8). If the plan has no integration tasks, WIRE still checks barrel exports and runs validate. |
| "I found an integration gap but it is minor, so I will mark it as pass with a note" |
A gap is a FAIL, not a conditional pass. Record the gap, report it, and let the human decide whether to fix or skip. |
Examples
Example: Small Tier Integration (Bug Fix)
## Integration Report
**Tier:** small (plan: small, derived: small)
**Rigor:** standard
### WIRE
- [PASS] Barrel exports: `pnpm run generate-barrel-exports --check` -- no changes
- [PASS] Harness validate: passes
- No integration tasks to verify
### MATERIALIZE
- [SKIPPED] Small tier -- no materialization required
### UPDATE
- [SKIPPED] Small tier -- no updates required
### Verdict: PASS
Example: Large Tier Integration (New Skill)
## Integration Report
**Tier:** large (plan: medium, derived: large -- escalated due to new package)
**Rigor:** standard
### WIRE
- [PASS] Barrel exports: regenerated, git diff shows no changes
- [PASS] Harness validate: passes
- [PASS] Skill discovery: harness-integration/skill.yaml exists, SKILL.md exists (420 lines)
- [PASS] Entry point: skill appears in harness skill list output
- [FAIL] Route mount: /api/integration not mounted in router
### MATERIALIZE
- [PASS] ADR 0001-tiered-integration-rigor.md drafted and auto-approved
- [PASS] Knowledge graph: 3 decision nodes created via ingest_source
- [PASS] AGENTS.md updated with integration phase description
### UPDATE
- [PASS] Roadmap synced: integration-phase moved to in-progress
- [FAIL] Changelog: no entry in CHANGELOG.md for integration phase
- [PASS] Spec cross-reference: annotated with implementation file links
### Verdict: FAIL -- 2 items incomplete
1. Route mount /api/integration not found in router configuration
Fix: Add route import and mount in src/api/routes/index.ts
2. Changelog entry missing
Fix: Add entry under Unreleased: "Added integration phase with tiered wiring verification"
Gates
- No skipping WIRE defaults. Barrel export check and harness validate run for every tier, every rigor level. No exceptions.
- No skipping tier derivation. Always derive tier from execution results and compare with plan estimate. Higher tier wins.
- No fixing during integration. Integration identifies gaps. Integration never fills them. Record as FAIL and report.
- No auto-passing MATERIALIZE in thorough mode. Every ADR draft must be presented for human review in thorough mode.
- No integration without a plan. If no plan exists, there are no integration tasks to verify. Run WIRE defaults only and note the absence.
- No forbidden hedging language. "Should", "probably", "seems to" are forbidden. Use evidence or state "not verified."
Escalation
- Barrel export generation command not found: Record as FAIL. Instruct: "The project does not have a
generate-barrel-exports script. Add it to package.json or skip barrel export verification."
- Knowledge graph tools unavailable: If
ingest_source is not available, record materialization as skipped with reason. Do not block on tooling absence for medium tier. For large tier in thorough mode, escalate.
- ADR directory does not exist: Create
docs/knowledge/decisions/ on first ADR write. This is expected for projects that have not used ADRs before.
- Plan has no integration tier: Default to small. Run WIRE defaults only.
- Tier derivation signals ambiguous: When git diff counts are borderline (e.g., exactly 5 new exports), use the plan estimate as tiebreaker.
- Integration fails repeatedly after fix attempts: After 2 fix cycles, escalate: "Integration has failed times. The integration tasks may need redesign. Review the plan's integration section."
1---2name: harness-integration3description: Harness Integration4---5# Harness Integration67> Verify system wiring, materialize knowledge artifacts, and update project metadata. Integration is a gate, not a discovery phase -- it confirms that planned integration tasks completed.89## When to Use1011- After execution completes and verification passes (between VERIFY and REVIEW in the workflow)12- When the autopilot state machine reaches the INTEGRATE state13- When validating that a feature is properly wired into the system (barrel exports, skill discovery, route mounts)14- When materializing architectural decisions as durable ADRs15- When invoked standalone to check integration completeness of a feature branch16- NOT as a replacement for verification (verification checks code correctness; integration checks system connectivity)17- NOT for discovering integration work (integration work is planned upfront in brainstorming and planning)18- NOT for implementing fixes (integration identifies gaps; the executor fixes them)1920## Process2122### Iron Law2324**No integration claim may be made without checking every planned integration task against the codebase.**2526Integration checking is mechanical: did the planned task produce the expected artifact? "It should be there" is not evidence. Check the file, check the import, check the registration. Report what you observed.2728The words "should", "probably", "seems to", and "I believe" are forbidden in integration reports. Replace with "verified: [evidence]" or "not verified: [what is missing]."2930---3132### Argument Resolution3334When invoked by autopilot (or with explicit arguments), resolve paths before starting:35361. **Session slug:** If `session-slug` argument provided, set `{sessionDir} = .harness/sessions/<session-slug>/`. Pass to `gather_context({ session: "<session-slug>" })`. All report writes go to `{sessionDir}/`.372. **Plan path:** Discover from `{sessionDir}/handoff.json` (read upstream execution/verification output). The plan contains integration tasks tagged `category: "integration"` and the `integrationTier` field.383. **Rigor level:** If `fast`/`thorough` argument provided, use it. Otherwise default to `standard`.3940When no arguments are provided (standalone invocation), discover plan from `docs/changes/<topic>/plans/` (preferred) or `docs/plans/` (legacy fallback) or prompt. Global `.harness/` paths used as fallback.4142---4344### Tier Resolution4546Before running sub-phases, resolve the effective integration tier:47481. **Read plan-time tier.** Extract `integrationTier` from the plan header (small, medium, or large). If absent, default to `small`.49502. **Derive execution-time tier.** Read the execution start commit from the session handoff (`startCommit` field in `{sessionDir}/handoff.json`). If unavailable, use the autopilot's `startingCommit` from `{sessionDir}/autopilot-state.json`. Diff `startCommit..HEAD` to analyze the execution phase:5152 ```53 newPackages > 0 -> large54 newPublicExports > 5 -> large (minimum)55 filesChanged > 15 AND newExports -> medium (minimum)56 else -> keep plan estimate57 ```5859 To count these signals:60 - `newPackages`: count new `package.json` files in the diff61 - `newPublicExports`: count new `export` statements in barrel/index files62 - `filesChanged`: count total files changed in the diff63 - `newExports`: boolean, true if any new `export` statements exist64653. **Apply max(planned, derived).** The effective tier is the higher of the two.66674. **Notify on escalation.** If derived tier exceeds planned tier, notify the human:6869 ```70 Tier escalated from `small` to `medium`: 8 new exports detected.71 ```7273 Inform the human and get acknowledgment in plain text in your reply (do NOT route this through `emit_interaction` or `AskUserQuestion` — they record the prompt but do not display it to the human, so they won't see it).7475---7677### Rigor Level Interaction7879| Rigor | INTEGRATE behavior |80| ---------- | -------------------------------------------------------------------------------------- |81| `fast` | WIRE only (default checks), auto-approve, no ADR drafting |82| `standard` | Full tier-appropriate checks (WIRE for all; MATERIALIZE + UPDATE for medium and large) |83| `thorough` | Full checks + human reviews every ADR draft + force knowledge graph verification |8485---8687### Context Loading8889Before running sub-phases, load session context:9091```json92gather_context({93 path: "<project-root>",94 intent: "Verify integration of executed plan",95 skill: "harness-integration",96 session: "<session-slug-if-provided>",97 include: ["state", "learnings", "handoff", "graph", "businessKnowledge", "sessions", "validation"]98})99```100101Load the plan, identify integration tasks (tagged `category: "integration"`), and group them by sub-phase:102103- **WIRE tasks:** Entry point registration, barrel exports, skill discovery, route mounts104- **MATERIALIZE tasks:** ADR writing, knowledge graph enrichment, documentation updates105- **UPDATE tasks:** Roadmap sync, changelog, spec cross-references106107---108109### Sub-Phase 1: WIRE (all tiers)110111Report progress: `**[WIRE]** Checking system wiring`112113WIRE always runs, regardless of tier. It has two parts: default checks (always) and task-specific checks (when integration tasks exist).114115#### Default Checks (always run)116117These run even with zero explicit integration tasks (D8: barrel exports and validation are cheap and catch real problems).1181191. **Barrel export check.** Run `pnpm run generate-barrel-exports --check`. If the `--check` flag is not supported, fall back to:120 - Run `pnpm run generate-barrel-exports`121 - Run `git diff --name-only`122 - If barrel files changed, the previous execution missed this step. Record as FAIL with the list of changed barrel files.123 - If no changes, barrel exports are current. Record as PASS.1241252. **Harness validate.** Run `pnpm harness validate`. Must pass. Record result.126127#### Task-Specific Checks (when integration tasks exist)128129For each integration task tagged `category: "integration"` that relates to wiring:1301313. **Entry point reachability.** Trace from known entry points to new code:132 - CLI: search for the new command/function in the `createProgram()` registration chain133 - MCP: search for the new tool in `getToolDefinitions()` or tool registration files134 - Skill: verify `skill.yaml` + `SKILL.md` exist at the expected path and skill appears in `harness skill list` output or discovery glob results135 - If the task claims a new entry point, verify it is reachable from at least one system entry point. An unreachable entry point is dead code.1361374. **Skill discovery verification.** If a new skill was created:138 - Verify `agents/skills/claude-code/<skill-name>/skill.yaml` exists and has valid YAML139 - Verify `agents/skills/claude-code/<skill-name>/SKILL.md` exists and is non-empty140 - Verify the skill appears in `harness skill list` output (or would appear based on glob pattern)1411425. **Route mount verification.** If a new API route was added:143 - Verify the route handler file exists144 - Verify the route is imported and mounted in the router/app configuration145 - Verify a request to the route path would be handled (trace the mount chain)1461476. **Produce wiring report.** Write `{sessionDir}/integration-wiring.json`:148149 ```json150 {151 "subPhase": "wire",152 "tier": "<effective-tier>",153 "timestamp": "<ISO-8601>",154 "defaultChecks": {155 "barrelExports": { "status": "pass|fail", "detail": "<description>" },156 "harnessValidate": { "status": "pass|fail", "detail": "<output summary>" }157 },158 "taskChecks": [159 {160 "taskRef": "Task N: <name>",161 "check": "<what was verified>",162 "status": "pass|fail",163 "evidence": "<file:line or command output>"164 }165 ],166 "verdict": "pass|fail"167 }168 ```169170---171172### Sub-Phase 2: MATERIALIZE (medium + large tiers)173174Report progress: `**[MATERIALIZE]** Checking knowledge materialization`175176Skip this sub-phase for `small` tier or `fast` rigor. For medium and large tiers:177178#### Decision Harvesting1791801. **Read handoff decisions.** Load `{sessionDir}/handoff.json` from all phases in this session. Collect all entries from the `decisions` array.1811822. **Classify decisions.** For each decision:183 - **Architectural** (large tier): Decisions that affect system structure, introduce new patterns, or change integration boundaries. These warrant ADRs.184 - **Minor** (medium + large tier): Decisions about implementation approach, naming, or local design. These enrich the knowledge graph directly without an ADR.185186#### ADR Auto-Drafting (large tier only)1871883. **Auto-draft ADRs** from architectural decisions. For each architectural decision:189190 a. **Assign ADR number.** Scan `docs/knowledge/decisions/` for existing ADR files matching `NNNN-*.md`. Take the highest number and increment by 1. If the directory does not exist, create it and start at `0001`.191192 b. **Generate slug.** Convert the decision title to a URL-safe slug (lowercase, hyphens, no special characters).193194 c. **Write ADR** to `docs/knowledge/decisions/NNNN-<slug>.md`:195196 ```markdown197 ---198 number: NNNN199 title: <decision title>200 date: <ISO date>201 status: accepted202 tier: large203 source: <spec path or session slug>204 supersedes: <prior ADR number, if any>205 ---206207 ## Context208209 <What situation prompted this decision? What constraints existed?>210211 ## Decision212213 <What was decided and why?>214215 ## Consequences216217 <What follows from this decision -- positive, negative, and neutral?>218 ```219220 d. **Present for review.** In `thorough` rigor, present each ADR draft in plain text in your reply and wait for human approval — do NOT route it through `emit_interaction` or `AskUserQuestion`, which record the prompt but do not display it to the human (the client collapses the call to "Called harness" and the text only returns to the model). In `standard` rigor, auto-approve but log the draft for review.221222#### Knowledge Graph Enrichment (medium + large tiers)2232244. **Enrich knowledge graph.** For each decision (both architectural and minor):225 - Call `ingest_source` with the decision metadata so decisions become queryable graph nodes226 - For ADR-sourced decisions, the ADR file path is the source227 - For minor decisions, the handoff.json decision text is the content228229#### Documentation Task Verification2302315. **Verify documentation integration tasks.** For each integration task tagged `category: "integration"` that relates to documentation:232 - Verify the specified document was updated (file exists, content includes expected additions)233 - Verify AGENTS.md was updated if the task required it234 - Verify guides were written if the task required it2352366. **Produce materialization report.** Write `{sessionDir}/integration-materialization.json`:237238 ```json239 {240 "subPhase": "materialize",241 "tier": "<effective-tier>",242 "timestamp": "<ISO-8601>",243 "decisions": {244 "total": 0,245 "architectural": 0,246 "minor": 0247 },248 "adrs": [249 {250 "number": "NNNN",251 "title": "<title>",252 "path": "docs/knowledge/decisions/NNNN-<slug>.md",253 "status": "drafted|approved"254 }255 ],256 "graphEnrichment": {257 "nodesCreated": 0,258 "status": "pass|fail|skipped"259 },260 "documentationChecks": [261 {262 "taskRef": "Task N: <name>",263 "status": "pass|fail",264 "evidence": "<description>"265 }266 ],267 "verdict": "pass|fail|skipped"268 }269 ```270271---272273### Sub-Phase 3: UPDATE (medium and large tiers)274275Report progress: `**[UPDATE]** Checking project metadata updates`276277Skip this sub-phase for `small` tier or `fast` rigor. For medium and large tiers:2782791. **Roadmap sync.** If `docs/roadmap.md` exists, call `manage_roadmap` with `sync` and `apply: true` to update feature status. If `manage_roadmap` is unavailable, fall back to noting the roadmap needs manual sync.2802812. **Changelog verification.** If `CHANGELOG.md` exists at the project root:282 - Read the file and check for a new entry matching the current feature283 - If no entry exists, record as FAIL with instruction: "Add a changelog entry for this feature under the Unreleased section."284 - If no `CHANGELOG.md` exists, skip silently (not all projects use changelogs)2852863. **Spec cross-reference annotation.** Read the spec at its path (from the plan or handoff):287 - For each phase in the spec's Implementation Order, check if implementation files can be linked288 - If the spec does not have file annotations, note this as an improvement suggestion (not a failure)2892904. **Produce update report.** Write `{sessionDir}/integration-updates.json`:291292 ```json293 {294 "subPhase": "update",295 "tier": "<effective-tier>",296 "timestamp": "<ISO-8601>",297 "roadmap": { "status": "synced|skipped|failed", "detail": "<description>" },298 "changelog": { "status": "pass|fail|skipped", "detail": "<description>" },299 "specCrossRef": { "status": "annotated|skipped", "detail": "<description>" },300 "verdict": "pass|fail|skipped"301 }302 ```303304---305306### Combined Report and Verdict307308After all applicable sub-phases complete, produce the combined integration report:3093101. **Write combined report.** Write `{sessionDir}/phase-{N}-integration.json`:311312 ```json313 {314 "phase": "integration",315 "tier": "<effective-tier>",316 "rigor": "<fast|standard|thorough>",317 "timestamp": "<ISO-8601>",318 "subPhases": {319 "wire": { "verdict": "pass|fail", "reportPath": "{sessionDir}/integration-wiring.json" },320 "materialize": {321 "verdict": "pass|fail|skipped",322 "reportPath": "{sessionDir}/integration-materialization.json"323 },324 "update": {325 "verdict": "pass|fail|skipped",326 "reportPath": "{sessionDir}/integration-updates.json"327 }328 },329 "verdict": "pass|fail",330 "failures": [331 {332 "subPhase": "<wire|materialize|update>",333 "taskRef": "Task N: <name>",334 "issue": "<what is incomplete>",335 "fix": "<specific fix instruction>"336 }337 ]338 }339 ```3403412. **Report verdict.** Summarize pass/fail per sub-phase. On failure, list exactly which integration tasks are incomplete with specific fix instructions.3423433. **On PASS:** Write handoff and emit transition to REVIEW:344345 ```json346 emit_interaction({347 path: "<project-root>",348 type: "transition",349 transition: {350 completedPhase: "integration",351 suggestedNext: "review",352 reason: "Integration passed at all applicable sub-phases",353 artifacts: ["<report paths>"],354 requiresConfirmation: false,355 summary: "Integration passed: tier <tier>. WIRE passed. MATERIALIZE <passed|skipped>. UPDATE <passed|skipped>.",356 qualityGate: {357 checks: [358 { "name": "wire-checks", "passed": true },359 { "name": "materialize-checks", "passed": true },360 { "name": "update-checks", "passed": true },361 { "name": "harness-validate", "passed": true }362 ],363 allPassed: true364 }365 }366 })367 ```368369 Immediately invoke harness-code-review without waiting for user input.3703714. **On FAIL:** Do NOT emit a transition. Report incomplete items with fix instructions, then ask the human how to proceed in plain text.372373 **Ask directly in your reply. Do NOT route the question through `emit_interaction`, `AskUserQuestion`, or any tool.** `emit_interaction` records the prompt but does not display it to the human — the client collapses the call to "Called harness" and the rendered text only returns to the model, so the human sees nothing and you end up narrating a question they cannot answer. `AskUserQuestion` is Claude-Code-only and caps headers at 12 chars / 4 options. Plain text in your own message is the only channel that reliably reaches the human across every tool (Claude Code, Cursor, Codex, Gemini CLI).374375 Present the options as a markdown table, state your recommendation, then STOP and wait for the human's reply:376377 ```markdown378 ### Decision needed: Integration failed. <N> items incomplete. How to proceed?379380 | | fix | skip | stop |381 | ---------- | ---------------------------------------------------------------------------------- | ------------------------------------------------------ | ------------------------- |382 | **What** | Re-enter EXECUTE with integration-specific fix tasks, then re-VERIFY, re-INTEGRATE | Record decision and proceed to REVIEW (human override) | Save state and exit |383 | **Pros** | Closes gaps before review | Unblocks progress immediately | Preserves state for later |384 | **Cons** | Another execute/verify cycle | Ships with known gaps | No forward progress |385 | **Risk** | Low | Medium | Low |386 | **Effort** | Medium | Low | Low |387388 **Recommendation:** fix (confidence: high) — fixing integration gaps now prevents review rework.389 ```390391 - **fix:** Record fix tasks in handoff. The autopilot re-enters EXECUTE with those tasks.392 - **skip:** Record the skip decision in `decisions[]` in handoff. Proceed to REVIEW.393 - **stop:** Write handoff with current state and stop.394395---396397### Handoff398399Write handoff to the session-scoped path when session slug is known, otherwise fall back to global:400401- Session-scoped (preferred): `.harness/sessions/<session-slug>/handoff.json`402- Global (fallback, **deprecated**): `.harness/handoff.json`403404> **[DEPRECATED]** Writing to `.harness/handoff.json` is deprecated. In autopilot sessions, always write to `.harness/sessions/<slug>/handoff.json` to prevent cross-session contamination.405406```json407{408 "fromSkill": "harness-integration",409 "phase": "COMPLETE",410 "summary": "<verdict summary>",411 "tier": "<effective-tier>",412 "artifacts": ["<report paths>", "<ADR paths if any>"],413 "verdict": "pass | fail",414 "gaps": ["<gap descriptions if any>"],415 "decisions": [{ "what": "<decision>", "why": "<rationale>" }]416}417```418419**Session summary (if session known):** Update via `writeSessionSummary` with skill, status (`Integration <PASS|FAIL>. Tier: <tier>. <N> checks, <N> gaps.`), keyContext, and nextStep.420421## Session State422423| Section | Read | Write | Purpose |424| ------------- | ---- | ----- | ------------------------------------------------------------------------ |425| terminology | yes | no | Consistent language in integration reports |426| decisions | yes | yes | Reads all phase decisions for ADR drafting; writes integration decisions |427| constraints | yes | no | Respect existing constraints during checks |428| risks | yes | yes | Reads risks; writes integration risks discovered during checks |429| openQuestions | yes | yes | Reads questions; resolves those answered by integration evidence |430| evidence | yes | yes | Prior evidence; writes wiring, materialization, and update evidence |431432**When to write:** After each sub-phase, append evidence entries. After ADR drafting, write decisions.433434**When to read:** During Context Loading via `gather_context` with `include: ["state", "learnings", "handoff", "graph", "businessKnowledge", "sessions", "validation"]`.435436## Evidence Requirements437438Every pass/fail assertion in the integration report MUST include concrete evidence:4394401. **File reference:** `file:line` with observed content (e.g., `src/index.ts:12` -- "exports NotificationService")4412. **Command output:** Actual command and output (e.g., `pnpm run generate-barrel-exports --check` -- "No changes detected")4423. **Harness output:** `harness validate` output4434. **Git diff evidence:** `git diff --name-only` output for barrel export checks4445. **Discovery evidence:** `harness skill list` output for skill discovery verification4456. **Session evidence:** Record evidence in the sub-phase report JSON files written to the session directory446447**When to cite:** At every check. Each pass/fail in the wiring, materialization, and update reports must be backed by evidence.448449**Uncited claims:** Any integration assertion without direct evidence is an integration failure. This skill does not use `[UNVERIFIED]` -- if evidence cannot be produced, verdict is FAIL.450451## Harness Integration452453- **`gather_context`** -- Load session-scoped state, learnings, handoff, and validation before sub-phases. `session` parameter scopes to session directory.454- **`harness validate`** -- Run during WIRE default checks. Must pass.455- **`harness check-deps`** -- Run during WIRE if new modules were added.456- **`ingest_source`** -- Run during MATERIALIZE to enrich knowledge graph with decision nodes.457- **`manage_roadmap`** -- Run during UPDATE to sync roadmap status. Use `sync` with `apply: true`.458- **`emit_interaction`** -- Used only for the transition to REVIEW on pass. Tier escalation, ADR review (thorough mode), and fail/skip/stop decisions are asked in plain text in your reply.459- **Session directory** -- `.harness/sessions/<slug>/` contains all report files. Do not write to global `.harness/` when session slug is known.460461## Success Criteria462463- WIRE default checks run for every tier (including small) -- barrel exports current, harness validate passes464- All planned integration tasks verified with evidence465- ADRs drafted for large-tier architectural decisions with correct format and sequential numbering466- Knowledge graph enriched with decision nodes (medium + large tiers)467- Documentation tasks verified as complete (medium + large tiers)468- Roadmap synced, changelog verified (medium + large tiers)469- Combined report written with pass/fail per sub-phase470- Tier derivation correctly escalates when execution exceeds plan estimates471- Fast rigor completes in seconds (WIRE only, no ADRs, no graph enrichment)472- Failure report includes specific fix instructions for each incomplete item473474## Red Flags475476| Flag | Corrective Action |477| ----------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |478| "Barrel exports probably have not changed, so I will skip the check" | STOP. WIRE default checks always run. "Probably" is forbidden. Run the check and report the result. |479| "The ADR looks correct from the decision text, no need to present for review" | STOP. In thorough mode, every ADR draft requires human review. In standard mode, auto-approve but log. Do not skip the review protocol. |480| "Integration tasks are just bureaucracy, I will mark them as passed" | STOP. Integration tasks exist because brainstorming and planning identified real connection points. Each must be verified with evidence. |481| "The knowledge graph enrichment failed but it is not critical" | STOP. In thorough mode, graph enrichment failure is a FAIL. In standard mode, log the failure and include in the report. |482| "I will fix the missing barrel export myself to make WIRE pass" | STOP. Integration identifies gaps -- integration never fills them. Record as FAIL with fix instructions. The executor fixes it. |483484## Rationalizations to Reject485486| Rationalization | Reality |487| -------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |488| "WIRE passed so the feature is properly integrated" | WIRE checks wiring only. For medium/large tiers, MATERIALIZE and UPDATE must also pass. Partial integration is not integration. |489| "This is a small change, so I can skip tier derivation and just use the plan estimate" | Tier derivation is mandatory. Even if the plan says small, execution may have produced more changes than expected. Always derive and compare. |490| "The ADR format is close enough, no need to match the exact frontmatter schema" | ADRs must match the spec format exactly (number, title, date, status, tier, source, supersedes). The knowledge pipeline depends on consistent frontmatter for parsing. |491| "Integration tasks were not in the plan, so there is nothing to check" | WIRE default checks always run regardless of planned integration tasks (D8). If the plan has no integration tasks, WIRE still checks barrel exports and runs validate. |492| "I found an integration gap but it is minor, so I will mark it as pass with a note" | A gap is a FAIL, not a conditional pass. Record the gap, report it, and let the human decide whether to fix or skip. |493494## Examples495496### Example: Small Tier Integration (Bug Fix)497498```499## Integration Report500501**Tier:** small (plan: small, derived: small)502**Rigor:** standard503504### WIRE505- [PASS] Barrel exports: `pnpm run generate-barrel-exports --check` -- no changes506- [PASS] Harness validate: passes507- No integration tasks to verify508509### MATERIALIZE510- [SKIPPED] Small tier -- no materialization required511512### UPDATE513- [SKIPPED] Small tier -- no updates required514515### Verdict: PASS516```517518### Example: Large Tier Integration (New Skill)519520```521## Integration Report522523**Tier:** large (plan: medium, derived: large -- escalated due to new package)524**Rigor:** standard525526### WIRE527- [PASS] Barrel exports: regenerated, git diff shows no changes528- [PASS] Harness validate: passes529- [PASS] Skill discovery: harness-integration/skill.yaml exists, SKILL.md exists (420 lines)530- [PASS] Entry point: skill appears in harness skill list output531- [FAIL] Route mount: /api/integration not mounted in router532533### MATERIALIZE534- [PASS] ADR 0001-tiered-integration-rigor.md drafted and auto-approved535- [PASS] Knowledge graph: 3 decision nodes created via ingest_source536- [PASS] AGENTS.md updated with integration phase description537538### UPDATE539- [PASS] Roadmap synced: integration-phase moved to in-progress540- [FAIL] Changelog: no entry in CHANGELOG.md for integration phase541- [PASS] Spec cross-reference: annotated with implementation file links542543### Verdict: FAIL -- 2 items incomplete5441. Route mount /api/integration not found in router configuration545 Fix: Add route import and mount in src/api/routes/index.ts5462. Changelog entry missing547 Fix: Add entry under Unreleased: "Added integration phase with tiered wiring verification"548```549550## Gates551552- **No skipping WIRE defaults.** Barrel export check and harness validate run for every tier, every rigor level. No exceptions.553- **No skipping tier derivation.** Always derive tier from execution results and compare with plan estimate. Higher tier wins.554- **No fixing during integration.** Integration identifies gaps. Integration never fills them. Record as FAIL and report.555- **No auto-passing MATERIALIZE in thorough mode.** Every ADR draft must be presented for human review in thorough mode.556- **No integration without a plan.** If no plan exists, there are no integration tasks to verify. Run WIRE defaults only and note the absence.557- **No forbidden hedging language.** "Should", "probably", "seems to" are forbidden. Use evidence or state "not verified."558559## Escalation560561- **Barrel export generation command not found:** Record as FAIL. Instruct: "The project does not have a `generate-barrel-exports` script. Add it to package.json or skip barrel export verification."562- **Knowledge graph tools unavailable:** If `ingest_source` is not available, record materialization as skipped with reason. Do not block on tooling absence for medium tier. For large tier in thorough mode, escalate.563- **ADR directory does not exist:** Create `docs/knowledge/decisions/` on first ADR write. This is expected for projects that have not used ADRs before.564- **Plan has no integration tier:** Default to small. Run WIRE defaults only.565- **Tier derivation signals ambiguous:** When git diff counts are borderline (e.g., exactly 5 new exports), use the plan estimate as tiebreaker.566- **Integration fails repeatedly after fix attempts:** After 2 fix cycles, escalate: "Integration has failed <N> times. The integration tasks may need redesign. Review the plan's integration section."