Compare commits
8 Commits
6bc5e48357
...
d9ec148bb3
| Author | SHA1 | Date | |
|---|---|---|---|
| d9ec148bb3 | |||
| f2b886880a | |||
| dd82944529 | |||
| 8af9db2c12 | |||
| 7f99d52a09 | |||
| 34f101c166 | |||
| 960aba5faa | |||
| 2247e52ae4 |
@@ -12,5 +12,14 @@
|
||||
"orchestration", "multi-agent", "archetypes", "pdca",
|
||||
"code-review", "quality", "worktrees", "jungian",
|
||||
"shadow-detection", "workflows"
|
||||
]
|
||||
],
|
||||
"skills": [
|
||||
"run", "orchestration", "plan-phase", "do-phase", "check-phase", "act-phase",
|
||||
"shadow-detection", "attention-filters", "convergence", "artifact-routing",
|
||||
"process-log", "memory", "effectiveness", "progress",
|
||||
"colette-bridge", "git-integration", "multi-project",
|
||||
"custom-archetypes", "workflow-design", "domains", "cost-tracking",
|
||||
"templates", "autonomous-mode", "using-archeflow", "presence"
|
||||
],
|
||||
"hooks": "hooks/hooks.json"
|
||||
}
|
||||
|
||||
38
README.md
38
README.md
@@ -16,14 +16,44 @@ The key insight: archetypes are not just system prompts. Each one has a **virtue
|
||||
|
||||
### 1. Install
|
||||
|
||||
```bash
|
||||
# From Git
|
||||
claude plugin install --url https://git.xorwell.de/c/claude-archeflow-plugin
|
||||
**From the marketplace** (recommended):
|
||||
|
||||
# Local development
|
||||
```bash
|
||||
# Add the marketplace (one time)
|
||||
/plugin marketplace add https://git.xorwell.de/c/claude-archeflow-plugin
|
||||
|
||||
# Install the plugin
|
||||
/plugin install archeflow@claude-archeflow-plugin
|
||||
```
|
||||
|
||||
**From Git URL directly:**
|
||||
|
||||
```bash
|
||||
/plugin marketplace add https://git.xorwell.de/c/claude-archeflow-plugin.git
|
||||
/plugin install archeflow --scope user
|
||||
```
|
||||
|
||||
**Local development:**
|
||||
|
||||
```bash
|
||||
claude --plugin-dir ./archeflow
|
||||
```
|
||||
|
||||
After installing, run `/reload-plugins` or restart Claude Code. ArcheFlow activates automatically on session start.
|
||||
|
||||
#### Verify installation
|
||||
|
||||
```
|
||||
/plugin # Opens plugin manager — check "Installed" tab
|
||||
/af-status # Should show "no active run"
|
||||
```
|
||||
|
||||
#### Scopes
|
||||
|
||||
- `--scope user` — available in all your projects (recommended)
|
||||
- `--scope project` — only in the current project
|
||||
- `--scope local` — only in the current directory
|
||||
|
||||
### 2. Run your first orchestration
|
||||
|
||||
Just describe a task. ArcheFlow activates automatically for multi-file changes:
|
||||
|
||||
@@ -25,7 +25,10 @@ try {
|
||||
}
|
||||
|
||||
console.log(JSON.stringify({
|
||||
hookSpecificOutput: { additionalContext: stripped }
|
||||
hookSpecificOutput: {
|
||||
hookEventName: "SessionStart",
|
||||
additionalContext: stripped
|
||||
}
|
||||
}));
|
||||
} catch (e) {
|
||||
console.log("{}");
|
||||
|
||||
@@ -201,6 +201,16 @@ cmd_inject() {
|
||||
local domain="${1:-}"
|
||||
local archetype="${2:-}"
|
||||
|
||||
# Parse optional --audit <run_id>
|
||||
local audit_run_id=""
|
||||
shift 2 2>/dev/null || true
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--audit) audit_run_id="$2"; shift 2 ;;
|
||||
*) shift ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ ! -f "$LESSONS_FILE" ]]; then
|
||||
return 0
|
||||
fi
|
||||
@@ -237,14 +247,118 @@ cmd_inject() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Collect injected lesson IDs for audit
|
||||
local injected_ids=()
|
||||
|
||||
echo "## Known Issues (from past runs)"
|
||||
while IFS= read -r lesson; do
|
||||
local desc freq src
|
||||
local desc freq src lid
|
||||
desc=$(echo "$lesson" | jq -r '.description')
|
||||
freq=$(echo "$lesson" | jq -r '.frequency')
|
||||
src=$(echo "$lesson" | jq -r '.source')
|
||||
lid=$(echo "$lesson" | jq -r '.id')
|
||||
injected_ids+=("$lid")
|
||||
echo "- ${desc} [seen ${freq}x, ${src}]"
|
||||
done <<< "$lessons"
|
||||
|
||||
# Write audit record if --audit was passed
|
||||
if [[ -n "$audit_run_id" && ${#injected_ids[@]} -gt 0 ]]; then
|
||||
ensure_dir
|
||||
local AUDIT_FILE="${MEMORY_DIR}/audit.jsonl"
|
||||
local ids_json
|
||||
ids_json=$(printf '%s\n' "${injected_ids[@]}" | jq -R . | jq -sc .)
|
||||
jq -cn \
|
||||
--arg ts "$(now_ts)" \
|
||||
--arg run_id "$audit_run_id" \
|
||||
--arg domain "$domain" \
|
||||
--arg archetype "$archetype" \
|
||||
--argjson lessons_injected "$ids_json" \
|
||||
--argjson lesson_count "${#injected_ids[@]}" \
|
||||
'{ts:$ts,run_id:$run_id,domain:$domain,archetype:$archetype,lessons_injected:$lessons_injected,lesson_count:$lesson_count}' \
|
||||
>> "$AUDIT_FILE"
|
||||
fi
|
||||
}
|
||||
|
||||
cmd_audit_check() {
|
||||
local run_id="${1:?Usage: $0 audit-check <run_id>}"
|
||||
local AUDIT_FILE="${MEMORY_DIR}/audit.jsonl"
|
||||
local EVENTS_FILE=".archeflow/events/${run_id}.jsonl"
|
||||
|
||||
if [[ ! -f "$AUDIT_FILE" ]]; then
|
||||
echo "No audit records found." >&2
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ ! -f "$EVENTS_FILE" ]]; then
|
||||
echo "No events file found for run $run_id." >&2
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Get lessons injected for this run
|
||||
local injected
|
||||
injected=$(jq -c --arg rid "$run_id" 'select(.run_id == $rid)' "$AUDIT_FILE" 2>/dev/null || true)
|
||||
|
||||
if [[ -z "$injected" ]]; then
|
||||
echo "No audit records for run $run_id." >&2
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Get all finding descriptions from review.verdict events
|
||||
local finding_descs
|
||||
finding_descs=$(jq -r '
|
||||
select(.type == "review.verdict") |
|
||||
.data.findings[]? | .description // empty
|
||||
' "$EVENTS_FILE" 2>/dev/null | tr '[:upper:]' '[:lower:]' || true)
|
||||
|
||||
# For each injected lesson, check if findings match the lesson's topic
|
||||
local lesson_ids
|
||||
lesson_ids=$(echo "$injected" | jq -r '.lessons_injected[]' 2>/dev/null | sort -u)
|
||||
|
||||
while IFS= read -r lid; do
|
||||
[[ -z "$lid" ]] && continue
|
||||
|
||||
# Get lesson description
|
||||
local lesson_desc
|
||||
lesson_desc=$(jq -r --arg lid "$lid" 'select(.id == $lid) | .description' "$LESSONS_FILE" 2>/dev/null | head -1)
|
||||
[[ -z "$lesson_desc" ]] && continue
|
||||
|
||||
# Check keyword overlap between lesson and findings
|
||||
local lesson_tokens finding_overlap
|
||||
lesson_tokens=$(tokenize "$lesson_desc")
|
||||
finding_overlap=0
|
||||
|
||||
if [[ -n "$finding_descs" ]]; then
|
||||
local finding_tokens
|
||||
finding_tokens=$(echo "$finding_descs" | tr -cs '[:alnum:]' '\n' | awk 'length >= 3' | sort -u)
|
||||
local common
|
||||
common=$(comm -12 <(echo "$lesson_tokens") <(echo "$finding_tokens") | wc -l)
|
||||
local total
|
||||
total=$(echo "$lesson_tokens" | wc -l)
|
||||
if [[ "$total" -gt 0 ]]; then
|
||||
finding_overlap=$(( common * 100 / total ))
|
||||
fi
|
||||
fi
|
||||
|
||||
local effectiveness
|
||||
if [[ "$finding_overlap" -ge 30 ]]; then
|
||||
effectiveness="ineffective" # Issue repeated despite lesson injection
|
||||
else
|
||||
effectiveness="helpful" # Issue was prevented (no matching finding)
|
||||
fi
|
||||
|
||||
# Append result to audit.jsonl
|
||||
jq -cn \
|
||||
--arg ts "$(now_ts)" \
|
||||
--arg run_id "$run_id" \
|
||||
--arg lesson_id "$lid" \
|
||||
--arg lesson_desc "$lesson_desc" \
|
||||
--arg effectiveness "$effectiveness" \
|
||||
--argjson overlap "$finding_overlap" \
|
||||
'{ts:$ts,run_id:$run_id,type:"effectiveness_check",lesson_id:$lesson_id,lesson_desc:$lesson_desc,effectiveness:$effectiveness,keyword_overlap_pct:$overlap}' \
|
||||
>> "$AUDIT_FILE"
|
||||
|
||||
echo "[archeflow-memory] Lesson $lid ($effectiveness): $lesson_desc" >&2
|
||||
done <<< "$lesson_ids"
|
||||
}
|
||||
|
||||
cmd_add() {
|
||||
@@ -383,11 +497,12 @@ if [[ $# -lt 1 ]]; then
|
||||
echo "" >&2
|
||||
echo "Commands:" >&2
|
||||
echo " extract <events.jsonl> Extract lessons from a completed run" >&2
|
||||
echo " inject <domain> <archetype> Output relevant lessons for injection" >&2
|
||||
echo " inject <domain> <archetype> [--audit <run_id>] Output relevant lessons for injection" >&2
|
||||
echo " add <type> <description> Manually add a lesson" >&2
|
||||
echo " list List all active lessons" >&2
|
||||
echo " decay Apply decay to all lessons" >&2
|
||||
echo " forget <id> Archive a lesson by ID" >&2
|
||||
echo " audit-check <run_id> Check lesson effectiveness for a run" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -400,7 +515,7 @@ case "$COMMAND" in
|
||||
cmd_extract "$1"
|
||||
;;
|
||||
inject)
|
||||
cmd_inject "${1:-}" "${2:-}"
|
||||
cmd_inject "$@"
|
||||
;;
|
||||
add)
|
||||
[[ $# -lt 2 ]] && { echo "Usage: $0 add <type> <description>" >&2; exit 1; }
|
||||
@@ -416,6 +531,10 @@ case "$COMMAND" in
|
||||
[[ $# -lt 1 ]] && { echo "Usage: $0 forget <id>" >&2; exit 1; }
|
||||
cmd_forget "$1"
|
||||
;;
|
||||
audit-check)
|
||||
[[ $# -lt 1 ]] && { echo "Usage: $0 audit-check <run_id>" >&2; exit 1; }
|
||||
cmd_audit_check "$1"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown command: $COMMAND" >&2
|
||||
exit 1
|
||||
|
||||
61
lib/archeflow-rollback.sh
Executable file
61
lib/archeflow-rollback.sh
Executable file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env bash
|
||||
# archeflow-rollback.sh — Auto-revert a merge that fails post-merge tests.
|
||||
#
|
||||
# Usage: archeflow-rollback.sh <run_id> [--test-cmd <cmd>]
|
||||
#
|
||||
# If --test-cmd not provided, reads test_command from .archeflow/config.yaml.
|
||||
# Returns 0 if tests pass, 1 if tests fail (merge reverted).
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
RUN_ID="${1:?Usage: archeflow-rollback.sh <run_id> [--test-cmd <cmd>]}"
|
||||
shift
|
||||
|
||||
# Parse optional --test-cmd
|
||||
TEST_CMD=""
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--test-cmd) TEST_CMD="$2"; shift 2 ;;
|
||||
*) echo "Unknown option: $1" >&2; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Read test_command from config if not provided
|
||||
if [[ -z "$TEST_CMD" ]]; then
|
||||
if [[ -f ".archeflow/config.yaml" ]]; then
|
||||
TEST_CMD=$(grep -E "^test_command:" .archeflow/config.yaml | sed 's/^test_command:\s*//' | tr -d '"' || true)
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -z "$TEST_CMD" ]]; then
|
||||
echo "ERROR: No test command specified (use --test-cmd or set test_command in .archeflow/config.yaml)" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Verify HEAD is an ArcheFlow merge
|
||||
HEAD_MSG=$(git log -1 --format=%s HEAD)
|
||||
if [[ "$HEAD_MSG" != *"$RUN_ID"* ]] && [[ "$HEAD_MSG" != *"archeflow"* ]]; then
|
||||
echo "WARNING: HEAD commit does not appear to be an ArcheFlow merge: $HEAD_MSG" >&2
|
||||
echo "Proceeding anyway..." >&2
|
||||
fi
|
||||
|
||||
echo "Running post-merge tests: $TEST_CMD"
|
||||
|
||||
if timeout 300 bash -c "$TEST_CMD"; then
|
||||
echo "Tests passed — merge is good."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Tests FAILED — reverting merge..."
|
||||
git revert --no-edit --mainline 1 HEAD
|
||||
|
||||
# Emit event if event script exists
|
||||
if [[ -x "$SCRIPT_DIR/archeflow-event.sh" ]]; then
|
||||
"$SCRIPT_DIR/archeflow-event.sh" "$RUN_ID" decision act "" \
|
||||
"{\"what\":\"post_merge_test\",\"chosen\":\"revert\",\"rationale\":\"test suite failed after merge\"}" ""
|
||||
fi
|
||||
|
||||
REVERT_HASH=$(git rev-parse --short HEAD)
|
||||
echo "Merge reverted (commit: $REVERT_HASH). Tests must pass before re-merging."
|
||||
exit 1
|
||||
@@ -286,18 +286,20 @@ When cycling back, produce `act-feedback.md` as a structured handoff. This repla
|
||||
| — | — | — | — | — |
|
||||
```
|
||||
|
||||
**Routing rules** (same as orchestration skill, repeated here for self-containment):
|
||||
**Routing rules** (canonical table — matches orchestration and artifact-routing skills):
|
||||
|
||||
| Finding Source | Routes to | When |
|
||||
|----------------|-----------|------|
|
||||
| Guardian (security, breaking-change) | Creator | Design must change |
|
||||
| Skeptic (design, scalability) | Creator | Assumptions need revision |
|
||||
| Sage (quality, consistency) | Maker | Implementation refinement |
|
||||
| Sage (design) | Creator | If it's an architectural concern |
|
||||
| Trickster (reliability) | Creator | If root cause is a design flaw |
|
||||
| Trickster (testing) | Maker | If root cause is a test gap |
|
||||
| Source | Category | Routes to | Reason |
|
||||
|--------|----------|-----------|--------|
|
||||
| Guardian | security, breaking-change | Creator | Design must change |
|
||||
| Guardian | reliability, dependency | Creator | Architectural decision needed |
|
||||
| Skeptic | design, scalability | Creator | Assumptions need revision |
|
||||
| Sage | quality, consistency | Maker | Implementation refinement |
|
||||
| Sage | testing | Maker | Test gap, not design flaw |
|
||||
| Trickster | reliability (design flaw) | Creator | Needs redesign |
|
||||
| Trickster | reliability (test gap) | Maker | Needs more tests |
|
||||
| Trickster | testing | Maker | Edge case not covered |
|
||||
|
||||
When in doubt about routing: if the fix requires changing the approach, route to Creator. If the fix requires changing the code within the existing approach, route to Maker.
|
||||
**Disambiguation rule:** When in doubt: if the fix requires changing the approach, route to Creator. If it requires changing the code within the existing approach, route to Maker.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ Artifacts follow the pattern: `<phase>-<agent>.<ext>`
|
||||
|-------|-------|----------|--------|
|
||||
| plan | explorer | `plan-explorer.md` | Markdown research report |
|
||||
| plan | creator | `plan-creator.md` | Markdown proposal with confidence scores |
|
||||
| plan | mini-explorer | `plan-mini-explorer.md` | Focused risk research (only if confidence gate triggers) |
|
||||
| do | maker | `do-maker.md` | Markdown implementation summary |
|
||||
| do | maker | `do-maker-files.txt` | Plain text, one file path per line |
|
||||
| check | guardian | `check-guardian.md` | Markdown verdict + findings table |
|
||||
@@ -89,8 +90,8 @@ Note: Address each unresolved issue listed above. Explain how your revised propo
|
||||
|
||||
| Agent | Receives | Does NOT receive |
|
||||
|-------|----------|-----------------|
|
||||
| **Maker** (cycle 1) | `plan-creator.md` (the proposal) | `plan-explorer.md`, reviewer outputs, raw task description |
|
||||
| **Maker** (cycle 2+) | `plan-creator.md`, Maker-routed findings from `act-feedback.md` | Explorer research, Guardian/Skeptic findings (those went to Creator) |
|
||||
| **Maker** (cycle 1) | `plan-creator.md` (the proposal), `plan-mini-explorer.md` (if exists) | `plan-explorer.md`, reviewer outputs, raw task description |
|
||||
| **Maker** (cycle 2+) | `plan-creator.md`, `plan-mini-explorer.md` (if exists), Maker-routed findings from `act-feedback.md` | Explorer research, Guardian/Skeptic findings (those went to Creator) |
|
||||
|
||||
**Maker context injection template (cycle 2+):**
|
||||
```markdown
|
||||
@@ -164,6 +165,8 @@ No agents are spawned in Act. The orchestrator reads all `check-*.md` artifacts
|
||||
|
||||
## Feedback Routing
|
||||
|
||||
> **This is the canonical routing table.** Other skills (orchestration, act-phase) must match this table exactly. When updating routing rules, update this table first, then sync the others.
|
||||
|
||||
When building `act-feedback.md` after the Check phase, route each finding to the right agent for the next cycle:
|
||||
|
||||
| Finding Source | Finding Category | Routes To | Rationale |
|
||||
@@ -177,7 +180,7 @@ When building `act-feedback.md` after the Check phase, route each finding to the
|
||||
| Trickster | reliability (test gap) | **Maker** | Needs more tests |
|
||||
| Trickster | testing | **Maker** | Edge case not covered |
|
||||
|
||||
**Ambiguous cases:** If a Trickster finding could be either a design flaw or a test gap, check: does the fix require changing the proposal's architecture/approach, or just adding a test/validation? Architecture change → Creator. Additional test → Maker.
|
||||
**Disambiguation rule:** When in doubt: if the fix requires changing the approach, route to Creator. If it requires changing the code within the existing approach, route to Maker.
|
||||
|
||||
### Feedback File Format
|
||||
|
||||
@@ -252,6 +255,7 @@ Before injecting an artifact into an agent's context, always check if the file e
|
||||
| Artifact | Missing when |
|
||||
|----------|-------------|
|
||||
| `plan-explorer.md` | Fast workflow (no Explorer) |
|
||||
| `plan-mini-explorer.md` | Confidence gate did not trigger for risk coverage |
|
||||
| `check-skeptic.md` | Fast workflow, or A2 fast-path taken |
|
||||
| `check-sage.md` | Fast workflow, or A2 fast-path taken |
|
||||
| `check-trickster.md` | Non-thorough workflow, or A2 fast-path taken |
|
||||
|
||||
@@ -165,3 +165,29 @@ Before your final commit, verify:
|
||||
- [ ] Every logical step has its own commit
|
||||
- [ ] Output summary is complete and accurate
|
||||
- [ ] Branch name follows convention
|
||||
|
||||
## Test-First Gate
|
||||
|
||||
Before the Maker's output is accepted, the orchestrator validates that tests were included.
|
||||
|
||||
### Validation Logic
|
||||
|
||||
Read `do-maker-files.txt`. Check if any file path matches common test patterns:
|
||||
- `*test*`, `*spec*`, `*.test.*`, `*.spec.*`, `*_test.*`, `*_spec.*`
|
||||
- Files in directories named `test/`, `tests/`, `__tests__/`, `spec/`
|
||||
|
||||
For writing domain projects, this gate is skipped.
|
||||
|
||||
### Outcomes
|
||||
|
||||
| Result | Action |
|
||||
|--------|--------|
|
||||
| Test files found | Pass — proceed to Check phase |
|
||||
| No test files, code domain | **Warn** — emit WARNING event, note in do-maker.md |
|
||||
| No test files + Creator specified tests | **Block** — re-run Maker with test instruction (1 retry) |
|
||||
| Writing domain | Skip gate entirely |
|
||||
|
||||
The block case triggers a targeted re-run with prompt:
|
||||
"The proposal specified these test cases: <test strategy section>. No test files
|
||||
were found in your changes. Add the specified tests before finishing."
|
||||
This is one retry within the Do phase, not a full PDCA cycle.
|
||||
|
||||
@@ -219,6 +219,32 @@ The helper script reads this config if it exists. All values have sensible defau
|
||||
|
||||
---
|
||||
|
||||
## Post-Merge Rollback
|
||||
|
||||
After merging, the run skill validates the merge by running the project's test suite. If tests fail, the merge is automatically reverted.
|
||||
|
||||
### Script
|
||||
|
||||
```bash
|
||||
./lib/archeflow-rollback.sh <run_id> [--test-cmd <cmd>]
|
||||
```
|
||||
|
||||
**Behavior:**
|
||||
1. Reads `test_command` from `.archeflow/config.yaml` (or uses `--test-cmd` override)
|
||||
2. Runs the test suite with a 5-minute timeout
|
||||
3. If tests pass: exits 0 (merge is good)
|
||||
4. If tests fail: runs `git revert --no-edit HEAD`, emits a `decision` event, exits 1
|
||||
5. Verifies HEAD is an ArcheFlow merge commit before reverting (warning if not, proceeds anyway)
|
||||
|
||||
**Integration with run skill:** Called in section 4c (All Approved) after `archeflow-git.sh merge`. If it returns non-zero, the orchestrator cycles back with "integration test failure" feedback or reports to the user if max cycles are reached.
|
||||
|
||||
**Configuration:** Set `test_command` in `.archeflow/config.yaml`:
|
||||
```yaml
|
||||
test_command: "npm test" # or "pytest", "cargo test", etc.
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Safety Rules
|
||||
|
||||
These rules are inherited from `archeflow:orchestration` and reinforced here:
|
||||
|
||||
@@ -215,6 +215,59 @@ Moves the lesson to `archive.jsonl` regardless of frequency.
|
||||
| Before agent spawn (run start) | Inject relevant lessons | `archeflow-memory.sh inject <domain> <archetype>` |
|
||||
| User command | Add/list/forget lessons | `archeflow-memory.sh add/list/forget` |
|
||||
|
||||
## Audit Trail
|
||||
|
||||
Track which lessons are injected into each run and whether they were effective.
|
||||
|
||||
### Storage
|
||||
|
||||
```
|
||||
.archeflow/memory/audit.jsonl # Append-only audit log
|
||||
```
|
||||
|
||||
### Injection Audit Record
|
||||
|
||||
When `--audit <run_id>` is passed to the `inject` command, an audit record is written:
|
||||
|
||||
```jsonl
|
||||
{"ts":"2026-04-04T10:00:00Z","run_id":"2026-04-04-auth-fix","domain":"code","archetype":"","lessons_injected":["m-001","m-003"],"lesson_count":2}
|
||||
```
|
||||
|
||||
Usage:
|
||||
```bash
|
||||
./lib/archeflow-memory.sh inject "$DOMAIN" "" --audit "$RUN_ID"
|
||||
```
|
||||
|
||||
### Effectiveness Check
|
||||
|
||||
After a run completes, check whether injected lessons prevented issues:
|
||||
|
||||
```bash
|
||||
./lib/archeflow-memory.sh audit-check <run_id>
|
||||
```
|
||||
|
||||
This command:
|
||||
1. Reads `audit.jsonl` for lessons injected in the given run
|
||||
2. Reads the run's event file for `review.verdict` events
|
||||
3. For each injected lesson, checks keyword overlap between the lesson's description and review findings
|
||||
4. **No matching finding** = `helpful` (the lesson likely prevented the issue)
|
||||
5. **Matching finding** = `ineffective` (the issue repeated despite the lesson being injected)
|
||||
6. Appends effectiveness results to `audit.jsonl`
|
||||
|
||||
### Effectiveness Over Time
|
||||
|
||||
By querying `audit.jsonl` for effectiveness records, you can measure:
|
||||
- Which lessons consistently prevent issues (high `helpful` count)
|
||||
- Which lessons are not working (high `ineffective` count — consider rewording or removing)
|
||||
- Overall memory system ROI (ratio of helpful to ineffective across all runs)
|
||||
|
||||
```bash
|
||||
# Count effectiveness per lesson
|
||||
jq -r 'select(.type == "effectiveness_check") | [.lesson_id, .effectiveness] | @tsv' .archeflow/memory/audit.jsonl | sort | uniq -c
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Design Principles
|
||||
|
||||
1. **Append-only storage.** `lessons.jsonl` is append-only during writes; decay rewrites the file in place but preserves all data (archived lessons move to `archive.jsonl`).
|
||||
|
||||
@@ -344,12 +344,18 @@ Parse each reviewer's output into the standardized format:
|
||||
|
||||
Not all findings go to the same agent:
|
||||
|
||||
| Finding source | Routes to | Rationale |
|
||||
|----------------|-----------|-----------|
|
||||
| Guardian (security, breaking-change) | **Creator** | Design must change |
|
||||
| Skeptic (design, scalability) | **Creator** | Assumptions need revision |
|
||||
| Sage (quality, consistency) | **Maker** | Implementation refinement |
|
||||
| Trickster (reliability, testing) | **Creator** if design flaw, **Maker** if test gap | Depends on root cause |
|
||||
| Source | Category | Routes to | Reason |
|
||||
|--------|----------|-----------|--------|
|
||||
| Guardian | security, breaking-change | **Creator** | Design must change |
|
||||
| Guardian | reliability, dependency | **Creator** | Architectural decision needed |
|
||||
| Skeptic | design, scalability | **Creator** | Assumptions need revision |
|
||||
| Sage | quality, consistency | **Maker** | Implementation refinement |
|
||||
| Sage | testing | **Maker** | Test gap, not design flaw |
|
||||
| Trickster | reliability (design flaw) | **Creator** | Needs redesign |
|
||||
| Trickster | reliability (test gap) | **Maker** | Needs more tests |
|
||||
| Trickster | testing | **Maker** | Edge case not covered |
|
||||
|
||||
**Disambiguation rule:** When in doubt: if the fix requires changing the approach, route to Creator. If it requires changing the code within the existing approach, route to Maker.
|
||||
|
||||
### 3. Track Resolution
|
||||
|
||||
|
||||
@@ -63,6 +63,25 @@ After emitting `run.start`, record `SEQ_RUN_START=1`.
|
||||
|
||||
If `--start-from` is specified, verify that the required prior artifacts exist in `.archeflow/artifacts/${RUN_ID}/` before skipping phases. If missing, abort with an error.
|
||||
|
||||
#### 0b. Memory Injection
|
||||
|
||||
Load cross-run memory lessons and inject into agent prompts. Use `--audit` to track which lessons were injected for this run:
|
||||
|
||||
```bash
|
||||
# Load cross-run memory for this domain (with audit trail)
|
||||
MEMORY_LESSONS=$(./lib/archeflow-memory.sh inject "$DOMAIN" "" --audit "$RUN_ID")
|
||||
|
||||
# Inject into Explorer/Creator prompts if non-empty
|
||||
if [[ -n "$MEMORY_LESSONS" ]]; then
|
||||
EXPLORER_PROMPT="${EXPLORER_PROMPT}
|
||||
|
||||
${MEMORY_LESSONS}"
|
||||
CREATOR_PROMPT="${CREATOR_PROMPT}
|
||||
|
||||
${MEMORY_LESSONS}"
|
||||
fi
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 1. Plan Phase
|
||||
@@ -126,17 +145,83 @@ After Creator returns:
|
||||
|
||||
#### 1c. Confidence Gate (Adaptation Rule A3)
|
||||
|
||||
Read Creator's confidence scores from `plan-creator.md`. Apply A3 per `archeflow:orchestration`:
|
||||
- Task understanding < 0.5 → **Pause**, ask user
|
||||
- Solution completeness < 0.5 → **Upgrade** to standard, spawn Explorer
|
||||
- Risk coverage < 0.5 → **Spawn mini-Explorer** for risky area (parallel, 5 min max)
|
||||
**Parsing instructions:**
|
||||
|
||||
Read `plan-creator.md`, locate the `### Confidence` table. Extract scores for each axis as floats:
|
||||
|
||||
```bash
|
||||
CONF_FILE=".archeflow/artifacts/${RUN_ID}/plan-creator.md"
|
||||
|
||||
# Extract confidence scores (expects format: "| Task understanding | 0.8 |")
|
||||
TASK_UNDERSTANDING=$(grep -i "task understanding" "$CONF_FILE" | grep -oE '[0-9]+\.[0-9]+' | head -1)
|
||||
SOLUTION_COMPLETENESS=$(grep -i "solution completeness" "$CONF_FILE" | grep -oE '[0-9]+\.[0-9]+' | head -1)
|
||||
RISK_COVERAGE=$(grep -i "risk coverage" "$CONF_FILE" | grep -oE '[0-9]+\.[0-9]+' | head -1)
|
||||
|
||||
# Fallback: if unparseable, emit warning and default to 0.0 (triggers gate, not bypasses it)
|
||||
if [[ -z "$TASK_UNDERSTANDING" || -z "$SOLUTION_COMPLETENESS" || -z "$RISK_COVERAGE" ]]; then
|
||||
echo "WARNING: Could not parse confidence scores from plan-creator.md" >&2
|
||||
./lib/archeflow-event.sh "$RUN_ID" decision plan "" \
|
||||
'{"what":"confidence_parse_failure","chosen":"warn","rationale":"one or more scores unparseable"}' "$SEQ_CREATOR_COMPLETE"
|
||||
fi
|
||||
TASK_UNDERSTANDING="${TASK_UNDERSTANDING:-0.0}"
|
||||
SOLUTION_COMPLETENESS="${SOLUTION_COMPLETENESS:-0.0}"
|
||||
RISK_COVERAGE="${RISK_COVERAGE:-0.0}"
|
||||
```
|
||||
|
||||
**Pause branch** (Task understanding < 0.5):
|
||||
|
||||
The Creator does not sufficiently understand the task. Do not spawn Maker.
|
||||
|
||||
1. Emit decision event with `"chosen":"pause"`
|
||||
2. Display message to user: "Creator rated task understanding at <score>. Clarification needed before proceeding."
|
||||
3. Block until the user provides clarification
|
||||
4. Re-run Creator with the clarification appended to the task description
|
||||
|
||||
If A3 triggers, emit a `decision` event:
|
||||
```bash
|
||||
./lib/archeflow-event.sh "$RUN_ID" decision plan "" \
|
||||
'{"what":"confidence_gate","chosen":"<action>","rationale":"<axis> scored <score>"}' "$SEQ_CREATOR_COMPLETE"
|
||||
'{"what":"confidence_gate","chosen":"pause","rationale":"task_understanding scored '"$TASK_UNDERSTANDING"'"}' "$SEQ_CREATOR_COMPLETE"
|
||||
```
|
||||
|
||||
**Upgrade branch** (Solution completeness < 0.5):
|
||||
|
||||
The Creator's proposal is incomplete — more research is needed.
|
||||
|
||||
1. If fast workflow: upgrade to standard, spawn Explorer, then re-run Creator with Explorer output
|
||||
2. If already standard/thorough: re-run Explorer with a focused prompt targeting the incomplete areas
|
||||
|
||||
```bash
|
||||
./lib/archeflow-event.sh "$RUN_ID" decision plan "" \
|
||||
'{"what":"confidence_gate","chosen":"upgrade","rationale":"solution_completeness scored '"$SOLUTION_COMPLETENESS"'"}' "$SEQ_CREATOR_COMPLETE"
|
||||
|
||||
# If fast → standard upgrade:
|
||||
WORKFLOW="standard"
|
||||
# Spawn Explorer, then re-run Creator with Explorer findings
|
||||
```
|
||||
|
||||
**Mini-Explorer branch** (Risk coverage < 0.5):
|
||||
|
||||
The Creator identified risks but lacks confidence in their assessment. Spawn a focused Explorer to investigate.
|
||||
|
||||
```
|
||||
Agent(
|
||||
description: "Mini-Explorer: investigate risk area for <task>",
|
||||
prompt: "You are the EXPLORER archetype. The Creator rated risk coverage at <score>.
|
||||
Identified risks: <risks from plan-creator.md>
|
||||
Research ONLY the risky areas. Answer: Is the risk real? What mitigations exist? What tests/guards would help?
|
||||
Limit: focused output only.",
|
||||
subagent_type: "Explore"
|
||||
)
|
||||
```
|
||||
|
||||
Save output to `.archeflow/artifacts/${RUN_ID}/plan-mini-explorer.md`. The Maker receives both `plan-creator.md` and `plan-mini-explorer.md` as context.
|
||||
|
||||
```bash
|
||||
./lib/archeflow-event.sh "$RUN_ID" decision plan "" \
|
||||
'{"what":"confidence_gate","chosen":"mini_explorer","rationale":"risk_coverage scored '"$RISK_COVERAGE"'"}' "$SEQ_CREATOR_COMPLETE"
|
||||
```
|
||||
|
||||
**Note:** The mini-Explorer runs in parallel with Do phase preparation (5 min max). The Maker can proceed once both `plan-creator.md` and `plan-mini-explorer.md` are available.
|
||||
|
||||
#### 1d. Phase Transition: Plan to Do
|
||||
|
||||
```bash
|
||||
@@ -184,6 +269,28 @@ After Maker returns:
|
||||
|
||||
**Critical:** Verify the Maker committed its changes before proceeding. If uncommitted changes exist, instruct the Maker to commit.
|
||||
|
||||
#### 2a-ii. Test-First Validation
|
||||
|
||||
After Maker completes, check `do-maker-files.txt` for test files:
|
||||
```bash
|
||||
TEST_FILES=$(grep -iE '([/_.-](test|spec)[/_.-]|\.(test|spec)\.|_(test|spec)\.|/tests?/|/__tests__/|/specs?/)' ".archeflow/artifacts/${RUN_ID}/do-maker-files.txt" || true)
|
||||
```
|
||||
|
||||
If `TEST_FILES` is empty and domain is not `writing`:
|
||||
1. Check if `plan-creator.md` contains a `### Test Strategy` section
|
||||
2. If yes: re-run Maker with targeted test instruction (one retry within Do phase)
|
||||
3. If no test strategy specified: emit WARNING event and proceed
|
||||
|
||||
```bash
|
||||
./lib/archeflow-event.sh "$RUN_ID" decision do "" \
|
||||
'{"what":"test_first_gate","chosen":"<pass|warn|retry>","rationale":"<reason>"}' "$SEQ_MAKER_COMPLETE"
|
||||
```
|
||||
|
||||
The re-run prompt for the retry case:
|
||||
> "The proposal specified these test cases: <test strategy section>. No test files were found in your changes. Add the specified tests before finishing."
|
||||
|
||||
This is one retry within the Do phase, not a full PDCA cycle. If the retry also produces no tests, emit WARNING and proceed to Check.
|
||||
|
||||
#### 2b. Phase Transition: Do to Check
|
||||
|
||||
```bash
|
||||
@@ -301,12 +408,46 @@ If all reviewers approved (and completion criteria met, if defined):
|
||||
'{"cycle":<N>,"max_cycles":<M>,"exit_condition":"all_approved","met":true,"next_action":"complete"}' "$SEQ_CHECK_TO_ACT"
|
||||
```
|
||||
|
||||
2. Run pre-merge hooks (check `.archeflow/hooks.yaml`)
|
||||
3. Merge Maker's worktree branch: `git merge --no-ff <branch>`
|
||||
4. Run post-merge hooks + test suite
|
||||
- Tests pass → continue
|
||||
- Tests fail → auto-revert, cycle back with "integration test failure" feedback
|
||||
5. Clean up worktree
|
||||
2. **Pre-merge hook check:**
|
||||
```bash
|
||||
# Read hooks config if it exists
|
||||
if [[ -f ".archeflow/hooks.yaml" ]]; then
|
||||
PRE_MERGE_HOOKS=$(grep -A5 "pre-merge:" .archeflow/hooks.yaml || true)
|
||||
if [[ -n "$PRE_MERGE_HOOKS" ]]; then
|
||||
echo "Running pre-merge hooks..."
|
||||
# Execute hooks; abort merge if fail_action: abort
|
||||
# Hook execution is project-specific — see .archeflow/hooks.yaml
|
||||
fi
|
||||
fi
|
||||
```
|
||||
|
||||
3. **Merge the Maker's worktree branch:**
|
||||
```bash
|
||||
./lib/archeflow-git.sh merge "$RUN_ID" --no-ff
|
||||
```
|
||||
|
||||
4. **Post-merge test validation** (using the auto-rollback script):
|
||||
```bash
|
||||
# Run tests and auto-revert if they fail
|
||||
if ! ./lib/archeflow-rollback.sh "$RUN_ID"; then
|
||||
# Rollback script already reverted HEAD and emitted decision event
|
||||
# If cycles remain, cycle back with integration test failure feedback
|
||||
if [[ "$CYCLE" -lt "$MAX_CYCLES" ]]; then
|
||||
echo "Cycling back with integration test failure feedback..."
|
||||
# Build act-feedback.md with "integration test failure on main" as top finding
|
||||
# Continue to step 4d (Issues Found)
|
||||
else
|
||||
echo "Max cycles reached. Reporting failure to user."
|
||||
# Continue to step 4e (Max Cycles Reached)
|
||||
fi
|
||||
fi
|
||||
```
|
||||
|
||||
5. **Clean up worktree:**
|
||||
```bash
|
||||
./lib/archeflow-git.sh cleanup "$RUN_ID"
|
||||
```
|
||||
|
||||
6. Proceed to Completion (step 5)
|
||||
|
||||
#### 4d. Branch: Issues Found (cycles remaining)
|
||||
|
||||
Reference in New Issue
Block a user