Skip to content

Commit 4bc644c

Browse files
rjmurillo-botclaude
andcommitted
merge: resolve conflicts with main in traceability intake
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2 parents 46f99e6 + ce19665 commit 4bc644c

File tree

299 files changed

+28211
-814
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

299 files changed

+28211
-814
lines changed

.agents/AGENT-SYSTEM.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Task(subagent_type="analyst", prompt="Investigate API latency issues")
3636

3737
### Agent Count
3838

39-
This system includes **19 specialized agents** organized into 5 categories.
39+
This system includes **20 specialized agents** organized into 5 categories.
4040

4141
---
4242

@@ -304,6 +304,40 @@ Create a threat model and identify required controls.
304304

305305
---
306306

307+
#### merge-resolver
308+
309+
**File**: `src/claude/merge-resolver.md`
310+
311+
**Role**: Resolves git merge conflicts by analyzing commit history and code intent
312+
313+
**Specialization**: Git conflict analysis, intent classification, heuristic-based resolution
314+
315+
**Input**:
316+
- PR number or branch name with conflicts
317+
- Base and head branch references
318+
319+
**Output**:
320+
- Resolved conflict files (staged)
321+
- Resolution report with confidence scores
322+
- Merge commit with rationale
323+
324+
**Delegates To**: None (returns to orchestrator)
325+
326+
**Called By**: orchestrator, implementer, qa
327+
328+
**When to Use**:
329+
- PR has merge conflicts with base branch
330+
- Rebase failures need systematic resolution
331+
- Automated conflict resolution for known patterns
332+
333+
**Example Invocation**:
334+
```text
335+
@merge-resolver Resolve conflicts on PR #123. The PR branch has diverged
336+
from main with conflicts in 3 source files.
337+
```
338+
339+
---
340+
307341
### 2.3 Quality Agents
308342

309343
#### critic
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Investigation: Skillbook Deduplication in Retrospective Workflow
2+
3+
**Issue**: #126
4+
**Date**: 2026-02-24
5+
**Status**: Complete
6+
7+
## Context
8+
9+
The 2025-12-16 Phase 4 retrospective (`2025-12-16-phase4-handoff-validation.md`)
10+
noted: "Skillbook deduplication check referenced but unclear if functioning."
11+
This investigation traces the retrospective-to-skillbook pipeline and documents
12+
gaps in the deduplication mechanism.
13+
14+
## Findings
15+
16+
### 1. Skillbook Deduplication Logic
17+
18+
**Location**: `src/claude/skillbook.md`, lines 97-124
19+
20+
The skillbook agent defines a Pre-ADD Checklist with three steps:
21+
22+
1. Read `memory-index.md` for domain routing
23+
2. Read the relevant domain index (`skills-*-index.md`)
24+
3. Search activation vocabulary for similar keywords
25+
26+
**Similarity threshold**: 70%. Below 70% triggers ADD. Above 70% triggers UPDATE.
27+
Exact match triggers REJECT.
28+
29+
**Implementation**: Prompt-based only. The agent prompt instructs the LLM to
30+
perform deduplication, but no automated tool enforces it. The prompt references
31+
`Search-Memory.ps1` for lexical search, but that script does not exist in the
32+
repository.
33+
34+
**Memory router** (`memory_core/memory_router.py`): Provides SHA-256 hash-based
35+
deduplication for merging search results across Serena and Forgetful backends.
36+
This deduplicates identical content across sources. It does not compute semantic
37+
similarity between skills.
38+
39+
### 2. Retrospective to Skillbook Handoff
40+
41+
**Location**: `src/claude/retrospective.md`, Phases 4-5
42+
43+
The retrospective agent defines a structured pipeline:
44+
45+
- **Phase 4** (line 645): Extract learnings with atomicity scoring
46+
- **Phase 5** (line 889): Recursive learning extraction with skillbook delegation
47+
- **Structured Handoff** (line 1270): Mandatory output format with skill
48+
candidates, memory updates, and git operations
49+
50+
The handoff format is well-specified. It includes skill ID, statement, atomicity
51+
score, operation type, and target file. The retrospective agent recommends
52+
routing to the skillbook agent, which the orchestrator handles.
53+
54+
**Enforcement**: None. The handoff relies on agent compliance with prompt
55+
instructions. No validation script, CI check, or gate verifies that the
56+
skillbook agent ran deduplication before persisting a skill.
57+
58+
### 3. Evidence from 2025-12-16 Retrospective
59+
60+
The retrospective that triggered this issue confirms the gap:
61+
62+
> "Deduplication Check: Placeholder for now (no existing skills to compare)"
63+
> "Need actual skillbook integration to make this meaningful"
64+
> "Compare Against Skillbook: Once skills are stored, test deduplication check
65+
> with real data"
66+
67+
At the time, the skillbook contained no skills to deduplicate against. The
68+
deduplication table in the retrospective template was empty.
69+
70+
### 4. Current State of Skill Storage
71+
72+
Skills are stored as atomic markdown files in `.serena/memories/` with domain
73+
indexes (`skills-*-index.md`). The memory-index hierarchy (L1 -> L2 -> L3)
74+
provides keyword-based routing. This supports manual deduplication via keyword
75+
overlap checking, but does not automate similarity scoring.
76+
77+
## Gap Summary
78+
79+
| Component | Specified | Implemented | Gap |
80+
|-----------|-----------|-------------|-----|
81+
| Deduplication logic | Yes (prompt) | Prompt-only | No automated enforcement |
82+
| Similarity threshold (70%) | Yes (prompt) | No tooling | LLM judgment only |
83+
| `Search-Memory.ps1` | Referenced | Does not exist | Missing script |
84+
| Memory router dedup | SHA-256 hash | Yes | Exact-match only, no semantic similarity |
85+
| Handoff format | Yes (structured) | Prompt-only | No validation gate |
86+
| Retrospective -> skillbook routing | Yes (orchestrator) | Manual | No automated trigger |
87+
88+
## Remediation Plan
89+
90+
### Short-term (P2, low effort)
91+
92+
1. **Remove `Search-Memory.ps1` references** from `skillbook.md`. Replace with
93+
the actual available tool: `memory_router.py` CLI or Serena `read_memory`
94+
tool for keyword search.
95+
96+
2. **Add deduplication verification to retrospective template**. The
97+
"Deduplication Check" table (retrospective.md line 782) should include a
98+
column for "Tool Used" to make it auditable.
99+
100+
### Medium-term (P1, moderate effort)
101+
102+
3. **Add keyword overlap scoring to memory router**. Extend `memory_router.py`
103+
with a function that computes Jaccard similarity between activation keywords
104+
of existing skills and a proposed skill. This replaces LLM-based similarity
105+
judgment with a deterministic metric.
106+
107+
4. **Create a `check_skill_duplicate.py` script**. Accept a proposed skill
108+
statement and keywords. Search existing skills. Return similarity score and
109+
most similar match. Exit code 0 if novel, 1 if duplicate.
110+
111+
### Long-term (P2, higher effort)
112+
113+
5. **Add CI validation for skill uniqueness**. Run the duplicate check script
114+
on any PR that adds files to `.serena/memories/`. Block merge if similarity
115+
exceeds threshold without explicit override.
116+
117+
6. **Automate retrospective -> skillbook routing**. When a retrospective
118+
artifact contains a Handoff Summary with skill candidates, trigger the
119+
skillbook agent automatically.
120+
121+
## Related Files
122+
123+
| File | Role |
124+
|------|------|
125+
| `src/claude/skillbook.md` | Skillbook agent prompt with dedup checklist |
126+
| `src/claude/retrospective.md` | Retrospective agent prompt with handoff format |
127+
| `.claude/skills/memory/memory_core/memory_router.py` | Memory router with hash-based dedup |
128+
| `.agents/retrospective/2025-12-16-phase4-handoff-validation.md` | Original retrospective citing the gap |
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Spec-Generator Evaluation: Skill vs No Action
2+
3+
## Decision
4+
5+
**No Action Needed** (Outcome A)
6+
7+
The spec-generator agent already produces consistent EARS output when invoked. Format
8+
inconsistency originates from manual spec creation that bypasses the agent entirely.
9+
10+
## Evidence
11+
12+
### Compliance Analysis (10 spec files)
13+
14+
| Metric | Count | Percentage |
15+
|--------|-------|------------|
16+
| EARS-compliant specs | 4 | 40% |
17+
| Non-compliant specs | 6 | 60% |
18+
| Duplicate IDs | 3 pairs | REQ-001, DESIGN-001, TASK-001 |
19+
20+
### Agent-Generated vs Manual Specs
21+
22+
| Origin | Files | EARS Compliant | Traceability |
23+
|--------|-------|----------------|--------------|
24+
| Agent-generated | REQ-001-pr-comment-handling, REQ-002-pr-comment-triage, DESIGN-001-pr-comment-processing, TASK-001/002/003-pr-* | Yes | Complete chain |
25+
| Manual | REQ-001, REQ-a01, DESIGN-001, TASK-001 | No | Broken or missing |
26+
27+
### Evaluation Questions (from issue 617)
28+
29+
| Question | Finding | Implication |
30+
|----------|---------|-------------|
31+
| Are specs currently inconsistent? | Yes, 60% non-compliant | Problem exists |
32+
| Is EARS format not being followed? | Only when agent is bypassed | Agent works correctly |
33+
| Is traceability chain broken? | Yes, for manual specs only | Usage problem, not capability |
34+
| Does spec-generator agent already produce consistent output? | Yes | No action needed on agent |
35+
36+
## Root Cause
37+
38+
The spec-generator agent prompt (`.claude/agents/spec-generator.md`) contains:
39+
40+
- Complete EARS templates (WHEN/THE SYSTEM SHALL/SO THAT)
41+
- All five EARS patterns (Ubiquitous, Event-Driven, State-Driven, Optional, Unwanted)
42+
- YAML frontmatter schemas with validation rules
43+
- Traceability chain enforcement (REQ to DESIGN to TASK)
44+
- Anti-pattern checklist
45+
46+
When invoked, the agent produces compliant output. The inconsistency comes from specs
47+
created without the agent.
48+
49+
## Why a Skill Would Not Help
50+
51+
| Factor | Assessment |
52+
|--------|------------|
53+
| Agent output quality | Already deterministic and consistent |
54+
| Skill duplication | Would replicate agent prompt content |
55+
| Real gap | Usage enforcement, not format capability |
56+
| Better fix | "Do Router" gate (ADR-033 Phase 4) to force spec-generator routing |
57+
58+
## Recommendation
59+
60+
1. **No skill creation**. The agent handles format consistency.
61+
2. **Phase 4 consideration**: A future "Do Router" gate could enforce spec-generator
62+
routing when spec files are created. This belongs in ADR-033 Phase 4, not Phase 2.
63+
3. **Cleanup**: Resolve duplicate IDs and convert manual specs to EARS format as
64+
separate maintenance work.
65+
66+
## References
67+
68+
- Issue: [#617](https://github.com/rjmurillo/ai-agents/issues/617)
69+
- Parent: [#615](https://github.com/rjmurillo/ai-agents/issues/615)
70+
- Agent prompt: `.claude/agents/spec-generator.md`
71+
- Spec schemas: `.agents/governance/spec-schemas.md`
72+
- ADR-033: `.agents/architecture/ADR-033-routing-level-enforcement-gates.md`

.agents/architecture/ADR-033-routing-level-enforcement-gates.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Status
44

5-
Proposed
5+
Accepted
66

77
## Date
88

@@ -136,6 +136,7 @@ Instead of exit code 2, hooks can output JSON with `decision: "deny"` and exit 0
136136
| **QA Validation** | `gh pr create` | `.agents/qa/` report exists | JSON deny |
137137
| **Critic Review** | `gh pr merge` | Critic agent invoked in transcript | JSON deny |
138138
| **ADR Existence** | `gh pr create --head feat/*` | ADR file exists for features | JSON deny |
139+
| **Retrospective** | `git push` | Retrospective evidence in session or file | Exit code 2 |
139140

140141
### Hook Configuration
141142

@@ -380,6 +381,21 @@ SkillCreator enforces:
380381
2. Block PR merge without critic review evidence
381382
3. Consider prompt-based hook for intelligent detection
382383

384+
### Phase 3.5: Retrospective Gate (Issue #618)
385+
386+
Implemented `invoke_retrospective_gate.py` to enforce retrospective before push:
387+
388+
1. **Trigger**: `git push` commands
389+
2. **Evidence Requirements** (any satisfies):
390+
- Retrospective section in session log (`## Retrospective`)
391+
- Retrospective file in `.agents/retrospective/` for today
392+
- Reference to retrospective file in session log
393+
3. **Bypass Conditions**:
394+
- Documentation-only changes (auto-detected)
395+
- Trivial sessions (<10 minutes, single file change)
396+
- `SKIP_RETROSPECTIVE_GATE=true` environment variable
397+
4. **Hook Configuration**: Added to `.claude/settings.json` under `Bash(git push*)` matcher
398+
383399
### Phase 4: "Do Router" Integration
384400

385401
1. Add keyword-based mandatory routing
@@ -448,7 +464,7 @@ flowchart TB
448464

449465
---
450466

451-
*ADR Version: 1.2*
467+
*ADR Version: 1.3*
452468
*Created: 2025-12-30*
453-
*Updated: 2025-12-30 - Added SkillCreator guidance for gate-related skill creation*
469+
*Updated: 2026-02-20 - Added Retrospective Gate implementation (Issue #618)*
454470
*Note: ADR-032 reserved for Exit Code Standardization (PR #557)*

0 commit comments

Comments
 (0)