arreio 1.0.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +81 -0
  2. package/package.json +42 -0
  3. package/scripts/postinstall.js +50 -0
  4. package/skills/arreio-init/SKILL.md +214 -0
  5. package/skills/arreio-init/references/architecture-template.md +85 -0
  6. package/skills/arreio-init/references/learn-index-template.md +15 -0
  7. package/skills/arreio-init/references/plan-index-template.md +29 -0
  8. package/skills/arreio-init/references/tasks-index-template.md +15 -0
  9. package/skills/learn/SKILL.md +151 -0
  10. package/skills/learn/modules/capture.md +108 -0
  11. package/skills/learn/modules/index.md +94 -0
  12. package/skills/learn/modules/maintain.md +116 -0
  13. package/skills/learn/modules/refine.md +104 -0
  14. package/skills/learn/references/dedup-rules.md +129 -0
  15. package/skills/learn/references/entry-schema.md +152 -0
  16. package/skills/learn/references/error-handling.md +178 -0
  17. package/skills/learn/references/id-generation.md +114 -0
  18. package/skills/learn/references/index-format.md +140 -0
  19. package/skills/learn/references/interaction-mode-propagation.md +89 -0
  20. package/skills/learn/references/migration-bootstrap.md +142 -0
  21. package/skills/learn/references/templates/artifacts/captured-entry.md +172 -0
  22. package/skills/learn/references/templates/artifacts/index-update.md +135 -0
  23. package/skills/learn/references/templates/artifacts/learn-input.md +100 -0
  24. package/skills/learn/references/templates/artifacts/maintain-log.md +142 -0
  25. package/skills/learn/references/templates/artifacts/refined-entry.md +168 -0
  26. package/skills/plan/SKILL.md +129 -0
  27. package/skills/plan/modules/design.md +140 -0
  28. package/skills/plan/modules/generate.md +156 -0
  29. package/skills/plan/modules/research.md +122 -0
  30. package/skills/plan/modules/scope.md +121 -0
  31. package/skills/plan/modules/tasks.md +190 -0
  32. package/skills/plan/references/design-complexity-assessment.md +118 -0
  33. package/skills/plan/references/error-handling.md +155 -0
  34. package/skills/plan/references/external-research-guidance.md +61 -0
  35. package/skills/plan/references/high-risk-detection.md +111 -0
  36. package/skills/plan/references/id-generation.md +55 -0
  37. package/skills/plan/references/interaction-mode-propagation.md +75 -0
  38. package/skills/plan/references/learnings-gate-logic.md +93 -0
  39. package/skills/plan/references/plan-tier-selection.md +174 -0
  40. package/skills/plan/references/task-slicing-rules.md +220 -0
  41. package/skills/plan/references/templates/artifacts/design.md +134 -0
  42. package/skills/plan/references/templates/artifacts/final-plan.md +265 -0
  43. package/skills/plan/references/templates/artifacts/research-findings.md +50 -0
  44. package/skills/plan/references/templates/artifacts/scoped-context.md +53 -0
  45. package/skills/plan/references/templates/artifacts/task.md +192 -0
  46. package/skills/plan/references/templates/artifacts/user-input.md +112 -0
  47. package/skills/review/SKILL.md +163 -0
  48. package/skills/review/modules/analyze.md +104 -0
  49. package/skills/review/modules/prepare.md +103 -0
  50. package/skills/review/modules/report.md +109 -0
  51. package/skills/review/modules/scope.md +126 -0
  52. package/skills/review/references/approval-criteria.md +101 -0
  53. package/skills/review/references/change-set-resolution.md +126 -0
  54. package/skills/review/references/error-handling.md +172 -0
  55. package/skills/review/references/id-generation.md +80 -0
  56. package/skills/review/references/interaction-mode-propagation.md +80 -0
  57. package/skills/review/references/review-categories.md +124 -0
  58. package/skills/review/references/scope-creep-detection.md +120 -0
  59. package/skills/review/references/severity-rubric.md +107 -0
  60. package/skills/review/references/templates/artifacts/findings.md +161 -0
  61. package/skills/review/references/templates/artifacts/review-input.md +116 -0
  62. package/skills/review/references/templates/artifacts/review-kit.md +135 -0
  63. package/skills/review/references/templates/artifacts/review-report.md +175 -0
  64. package/skills/review/references/templates/artifacts/review-scope.md +146 -0
  65. package/skills/work/SKILL.md +163 -0
  66. package/skills/work/modules/execute.md +109 -0
  67. package/skills/work/modules/prepare.md +140 -0
  68. package/skills/work/modules/review.md +164 -0
  69. package/skills/work/modules/triage.md +181 -0
  70. package/skills/work/references/ad-hoc-input-resolution.md +122 -0
  71. package/skills/work/references/error-handling.md +183 -0
  72. package/skills/work/references/execution-mode-selection.md +95 -0
  73. package/skills/work/references/id-generation.md +85 -0
  74. package/skills/work/references/interaction-mode-propagation.md +80 -0
  75. package/skills/work/references/review-checklist.md +94 -0
  76. package/skills/work/references/task-execution-rules.md +116 -0
  77. package/skills/work/references/templates/artifacts/execution-log.md +123 -0
  78. package/skills/work/references/templates/artifacts/execution-plan.md +111 -0
  79. package/skills/work/references/templates/artifacts/work-input.md +78 -0
  80. package/skills/work/references/templates/artifacts/work-manifest.md +119 -0
  81. package/skills/work/references/templates/artifacts/work-report.md +143 -0
@@ -0,0 +1,135 @@
1
+ ---
2
+ title: Index Update Artifact
3
+ description: Template for the Index Update Artifact produced by the Index phase. Carries the entry-path, the resolved slug, the derived index-applicability enum, the index-action (created/updated/merged), the index-coherence flag, and any merge de-index performed. The authoring run's final artifact; the entry is now durable at docs/learn/<type>/<slug>.md and indexed in docs/learn/index.md.
4
+ type: template
5
+ version: 1.0
6
+ timestamp: "2026-08-08"
7
+ ---
8
+
9
+ # Index Update Artifact
10
+
11
+ The product of the **Index** phase is the authoring run's final artifact. Index **writes** the entry file at `docs/learn/<type>/<slug>.md` (upsert on `slug`), derives the index-record `applicability` enum from the per-entry numeric scores per [index-format.md](../../index-format.md), and **upserts** `docs/learn/index.md` (YAML `entries:` block record plus By Category / By Domain markdown rows). On a merge resolution, Index de-indexes the analog (removes its index record), writes `superseded-by` into the analog's file, and adds the analog's `slug` to the canonical's `related` — keeping the analog's file (lineage preserved, never deleted). Index is the only authoring-phase writer of the entry file and the index.
12
+
13
+ ## Schema
14
+
15
+ ```yaml
16
+ index-id: YYYY-MM-DD-NNN-index
17
+ refine-id: YYYY-MM-DD-NNN-refine
18
+ capture-id: YYYY-MM-DD-NNN-capture
19
+ learn-id: YYYY-MM-DD-NNN
20
+ input-shape: explicit | candidate
21
+ interactionMode: detailed | smart | autopilot
22
+ status: complete
23
+ timestamp: ISO-8601 timestamp
24
+
25
+ entry-path: "docs/learn/<type>/<slug>.md" # where the entry file was written
26
+ slug: "<resolved-slug>" # the upsert key (matches the entry's frontmatter slug)
27
+ type: decision | pattern | gotcha | workflow # the entry's type
28
+
29
+ index-applicability: DIRECT | RECOMMENDED | CONTEXTUAL | HISTORICAL | INFORMATIONAL
30
+ # DERIVED per index-format.md from the frontmatter's numeric scores
31
+
32
+ index-action: created | updated | merged # what Index did
33
+ # created: new slug written
34
+ # updated: existing slug overwritten (update-existing resolution)
35
+ # merged: merge-into-canonical — analog de-indexed + canonical updated
36
+
37
+ merge: # present ONLY when index-action == merged
38
+ analog-slug: <the analog being de-indexed>
39
+ analog-file: "docs/learn/<type>/<analog-slug>.md"
40
+ analog-deindexed: true # its index record + rows removed; file KEPT
41
+ analog-superseded-note-written: true # superseded-by + status:obsolete written into the analog's frontmatter
42
+ canonical-related-updated: true # analog-slug added to canonical's related list
43
+
44
+ index-coherent: true # the YAML entries: length == on-disk entry-file count;
45
+ # per-type (N) counts consistent; no duplicate rows; the orchestrator's gate #5
46
+
47
+ source-candidate: <carried through> | null
48
+
49
+ entry-written: true # the entry file was written (false only on a failed-write recovery; would be status: failed)
50
+ index-updated: true # docs/learn/index.md was upserted
51
+ ```
52
+
53
+ Also save the Index Update Artifact to `docs/plans/.learn/.index/<index-id>.md`.
54
+
55
+ ## Validation Rules
56
+
57
+ - **index-id:** Required. Format `YYYY-MM-DD-NNN-index` per [id-generation.md](../../id-generation.md).
58
+ - **refine-id, capture-id, learn-id, input-shape:** Required, inherited (cross-phase consistency).
59
+ - **interactionMode:** Required, identical across the authoring chain.
60
+ - **status:** Required. `complete`.
61
+ - **entry-path:** Required. Repo-relative, of the form `docs/learn/<type>/<slug>.md`; the directory `docs/learn/<type>/` created if missing.
62
+ - **slug:** Required. The resolved slug (matches the entry's frontmatter).
63
+ - **type:** Required. One of the four.
64
+ - **index-applicability:** Required. The **derived** enum, per [index-format.md](../../index-format.md) (not re-encoded inline here; the artifact records the result of applying the derivation rule to the frontmatter's numeric scores).
65
+ - **index-action:** Required. `created` (new slug), `updated` (existing slug overwritten via `update-existing`), or `merged` (`merge-into-canonical` executed).
66
+ - **merge:** Required when `index-action: merged`; absent otherwise. On a merge:
67
+ - `analog-deindexed: true` — the analog's record was removed from the YAML block + By Category / By Domain tables.
68
+ - `analog-superseded-note-written: true` — `superseded-by: <canonical-slug>` and `status: obsolete` written into the analog file's frontmatter.
69
+ - `canonical-related-updated: true` — the analog's `slug` added to the canonical's `related` list.
70
+ - The analog **file is never deleted** (lineage preservation per [dedup-rules.md](../../dedup-rules.md)).
71
+ - **index-coherent:** Required. `true` — the post-upsert invariants hold (YAML length == on-disk count; per-type counts consistent; no duplicate rows). If `false`, Index reconciled in-place (non-destructive) and flagged it; the orchestrator's quality gate #5 requires `true` to finalize the run.
72
+ - **entry-written, index-updated:** Required. `true` on success; `status: failed` would cover a write failure.
73
+
74
+ ## Example (created — new decision entry)
75
+
76
+ ```yaml
77
+ index-id: 2026-08-08-001-index
78
+ refine-id: 2026-08-08-001-refine
79
+ capture-id: 2026-08-08-001-capture
80
+ learn-id: 2026-08-08-001
81
+ input-shape: explicit
82
+ interactionMode: smart
83
+ status: complete
84
+ timestamp: 2026-08-08T14:34:00Z
85
+ entry-path: docs/learn/decision/use-pnpm-when-both-lockfiles-exist.md
86
+ slug: use-pnpm-when-both-lockfiles-exist
87
+ type: decision
88
+ index-applicability: DIRECT # current_project=8, general=6 → RECOMMENDED; refine higher if any
89
+ index-action: created
90
+ index-coherent: true
91
+ source-candidate: null
92
+ entry-written: true
93
+ index-updated: true
94
+ ```
95
+
96
+ ## Example (merged — analog de-indexed, canonical updated, lineage preserved)
97
+
98
+ ```yaml
99
+ index-id: 2026-08-08-002-index
100
+ refine-id: 2026-08-08-002-refine
101
+ capture-id: 2026-08-08-002-capture
102
+ learn-id: 2026-08-08-002
103
+ input-shape: candidate
104
+ interactionMode: smart
105
+ status: complete
106
+ timestamp: 2026-08-08T14:42:00Z
107
+ entry-path: docs/learn/gotcha/ttl-must-propagate-to-redis-set.md
108
+ slug: ttl-must-propagate-to-redis-set
109
+ type: gotcha
110
+ index-applicability: DIRECT # current_project=8, general=7 → DIRECT
111
+ index-action: merged
112
+ merge:
113
+ analog-slug: redis-ttl-set-vs-expire
114
+ analog-file: docs/learn/gotcha/redis-ttl-set-vs-expire.md
115
+ analog-deindexed: true
116
+ analog-superseded-note-written: true
117
+ canonical-related-updated: true
118
+ index-coherent: true
119
+ source-candidate:
120
+ title: "Redis TTL must be propagated to the SET command"
121
+ domain: data-storage
122
+ source: { type: candidate, reference: "2026-07-10-001-review#F02" }
123
+ summary: "TTL test failed because SET ... EX must carry the TTL."
124
+ type: gotcha
125
+ entry-written: true
126
+ index-updated: true
127
+ ```
128
+
129
+ ## Notes
130
+
131
+ - Index is the **sole authoring-phase writer** of the entry file and the index; the upsert on `slug` is idempotent (a re-author overwrites, never duplicates).
132
+ - The `index-applicability` enum is **derived** from the frontmatter's numeric scores per [index-format.md](../../index-format.md); the artifact records the **result** of that derivation — it does not re-encode the derivation rule (no second formula).
133
+ - A `merged` action de-indexes the analog **without deleting its file** — the analog carries `superseded-by` + `status: obsolete`, and the canonical's `related` list links the analog's `slug`. The reader can walk either direction. This honors the [dedup-rules.md](../../dedup-rules.md) lineage-preservation rule (the `path-convention-split` gotcha is the model: a merged entry carries both the old and new knowledge, never just the new).
134
+ - `index-coherent: true` is the orchestrator's quality gate #5; the Index phase is responsible for leaving the index coherent (the YAML block, the per-type `(N)` counts, and the By Domain bullets are all in lockstep with the on-disk file tree).
135
+ - This artifact is the authoring run's **final** output. The Orchestrator marks the run complete; the durable knowledge entry now lives at `entry-path` and is discoverable via `docs/learn/index.md` (the source-of-truth index Plan/Work/Review search).
@@ -0,0 +1,100 @@
1
+ ---
2
+ title: Learn Input Artifact
3
+ description: Template for the Learn Input Artifact produced by the Orchestrator. Carries the input shape (explicit type+text, candidate ref, or maintain flag) and interactionMode; consumed by Capture (authoring shapes) or routed directly to Maintain (maintain shape).
4
+ type: template
5
+ version: 1.0
6
+ timestamp: "2026-08-08"
7
+ ---
8
+
9
+ # Learn Input Artifact
10
+
11
+ The Orchestrator produces a Learn Input Artifact as the entry point to the Learn workflow. It carries the input shape (one of explicit `<type> <text>`, a candidate ref, or a `maintain` flag) and the user-selected `interactionMode`. The Orchestrator routes an authoring shape to Capture; a `maintain` shape bypasses Capture/Refine/Index and routes directly to Maintain.
12
+
13
+ ## Schema
14
+
15
+ ```yaml
16
+ type: learn-input
17
+ timestamp: ISO-8601 timestamp (e.g., 2026-08-08T14:30:00Z)
18
+ source: user | saved-prompt | document | combination
19
+ status: complete
20
+ interactionMode: detailed | smart | autopilot
21
+ shape: explicit | candidate | maintain # REQUIRED. Determines the route.
22
+
23
+ # Input cargo — exactly one shape's fields:
24
+ explicit:
25
+ type: decision | pattern | gotcha | workflow # REQUIRED when shape == explicit
26
+ text: "<prose | file ref | commit ref | short description>" # REQUIRED when shape == explicit
27
+ candidate:
28
+ ref: "work-review-id | review-report-id" # REQUIRED when shape == candidate
29
+ # e.g. "2026-07-10-001-review" (Work) or "2026-08-08-001-report" (Review)
30
+ maintain:
31
+ run: true # REQUIRED when shape == maintain
32
+
33
+ # Optional context carried (explicit/candidate):
34
+ goals: [ ... ]
35
+ constraints: [ ... ]
36
+ references: [ ... ]
37
+ ```
38
+
39
+ ## Validation Rules
40
+
41
+ - **type:** Required. Must be `learn-input`.
42
+ - **timestamp:** Required. ISO-8601.
43
+ - **source:** Required. One of `user`, `saved-prompt`, `document`, `combination`.
44
+ - **status:** Required. `complete` (the Orchestrator marks it complete once it has the input and the interaction mode).
45
+ - **interactionMode:** Required. One of `detailed`, `smart`, `autopilot`. (If missing, default to `smart`; see [error-handling.md](../../error-handling.md) Category 5.)
46
+ - **shape:** Required. One of `explicit`, `candidate`, `maintain`.
47
+ - **Exactly one shape's cargo is present** (the others null/absent):
48
+ - `explicit` requires `explicit.type` ∈ the four types **and** non-empty `explicit.text`.
49
+ - `candidate` requires a non-empty `candidate.ref` resolving to a Work `review-id` or Review `report-id`.
50
+ - `maintain` requires `maintain.run: true`.
51
+ - **Routing:** the Orchestrator routes `shape: maintain` directly to the Maintain phase (Phase 4); `shape: explicit` and `shape: candidate` route to Capture (Phase 1). A routing mismatch (e.g., a `maintain` shape reaching Capture) is a Category 2 error ([error-handling.md](../../error-handling.md)).
52
+
53
+ ## Example (explicit author)
54
+
55
+ ```yaml
56
+ type: learn-input
57
+ timestamp: 2026-08-08T09:00:00Z
58
+ source: user
59
+ status: complete
60
+ interactionMode: smart
61
+ shape: explicit
62
+ explicit:
63
+ type: decision
64
+ text: "Use pnpm over npm when both lockfiles exist; prefer the packageManager field lock for invocations"
65
+ goals: null
66
+ constraints: null
67
+ references: null
68
+ ```
69
+
70
+ ## Example (candidate curation)
71
+
72
+ ```yaml
73
+ type: learn-input
74
+ timestamp: 2026-08-08T09:05:00Z
75
+ source: user
76
+ status: complete
77
+ interactionMode: detailed
78
+ shape: candidate
79
+ candidate:
80
+ ref: "2026-07-10-001-review" # a Work review-id with a learnings-to-capture list
81
+ ```
82
+
83
+ ## Example (maintain)
84
+
85
+ ```yaml
86
+ type: learn-input
87
+ timestamp: 2026-08-08T09:10:00Z
88
+ source: user
89
+ status: complete
90
+ interactionMode: smart
91
+ shape: maintain
92
+ maintain:
93
+ run: true
94
+ ```
95
+
96
+ ## Notes
97
+
98
+ - The Orchestrator's Pre-Flight Check ensures `docs/learn/`, `docs/plans/.learn/.{capture,refine,index,maintain}/` exist, and seeds `docs/learn/index.md` if missing (self-healing via `mkdir -p`), before routing the artifact.
99
+ - `interactionMode` flows from this artifact into every downstream artifact (Capture → Refine → Index for authoring; straight to Maintain otherwise); the orchestrator quality gate #2 cross-checks it is identical across the authoring chain (Maintain carries it standalone).
100
+ - The shape **determines the route**, not just the allocation: a `maintain` shape never reaches Capture, Refine, or Index. The phase ids reflect this — `maintain-id` is standalone (no `learn-id` umbrella) per [id-generation.md](../../id-generation.md).
@@ -0,0 +1,142 @@
1
+ ---
2
+ title: Maintain Log Artifact
3
+ description: Template for the Maintain Log Artifact produced by the Maintain phase. Carries the one-time migration result (no-op or N entries migrated), the base-wide dedup merges performed, the refresh normalization/flag counts, the explicit prune decisions, the rebuilt index state, and the index-coherence flag. Maintain's only deliverable; the canonical knowledge base is reconciled.
4
+ type: template
5
+ version: 1.0
6
+ timestamp: "2026-08-08"
7
+ ---
8
+
9
+ # Maintain Log Artifact
10
+
11
+ The product of the **Maintain** phase is the Maintain Log — the Maintain run's only deliverable. It records the one-time **migration** result (a self-gating no-op when already migrated, or `<N> entries migrated`), the **base-wide dedup** merges performed, the **refresh** (frontmatter normalization + flagged-for-review entries), the explicit **prune** decisions (deletes and de-indexes, each confirmed), and the rebuilt **index** state. The canonical knowledge base at `docs/learn/` is reconciled; `docs/learn/index.md` is rebuilt from the on-disk file tree (the source of truth). Maintain allocates its own `maintain-id` — there is no `learn-id` umbrella (Maintain authors no new entry).
12
+
13
+ ## Schema
14
+
15
+ ```yaml
16
+ maintain-id: YYYY-MM-DD-NNN-maintain # standalone; no learn-id umbrella (Maintain authors no new entry)
17
+ interactionMode: detailed | smart | autopilot
18
+ status: complete
19
+ timestamp: ISO-8601 timestamp
20
+
21
+ migration:
22
+ ran: true | false # false when self-gated (no-op)
23
+ result: "no-op (already migrated)" | "<N> entries migrated"
24
+ marker-written: true | false # the .migrated marker at docs/learn/.migrated
25
+ legacy-store-deleted: false # ALWAYS false — migration never deletes docs/learnings/; removal is a separate prune
26
+
27
+ merges: # base-wide dedup performed (Step 2)
28
+ - analog-slug: <the analog folded>
29
+ canonical-slug: <the canonical entry>
30
+ analog-file: "docs/learn/<type>/<analog-slug>.md"
31
+ analog-kept: true # the analog file is KEPT (de-indexed, not deleted)
32
+ analog-superseded-note-written: true # superseded-by + status:obsolete into the analog's frontmatter
33
+ canonical-related-updated: true # analog-slug added to the canonical's related list
34
+ []
35
+
36
+ refresh:
37
+ normalized-count: <N> # entries with non-destructive fixes applied (priority default, casing, updated_at)
38
+ flagged-for-review-count: <N> # entries with destructive changes needed (field-rewrite, missing sections) — NOT auto-applied
39
+ flagged-entries: [ "<slug>", ... ]
40
+
41
+ prune: # each prune was explicitly confirmed (destructive never silent, even in Autopilot)
42
+ - slug: <slug>
43
+ action: deleted | de-indexed # deleted: file removed; de-indexed: file kept, status:obsolete, index record removed (recommended default)
44
+ reason: "<user-confirmed rationale>"
45
+ []
46
+
47
+ rebuild:
48
+ ran: true
49
+ entries-indexed: <N> # the count of on-disk non-de-indexed entries in the rebuilt index
50
+ coherence-fixes-applied: <N> # any (YAML length vs file count) drift reconciled (should be 0 on a clean store)
51
+
52
+ index-coherent: true # the rebuilt YAML entries: length == on-disk entry-file count;
53
+ # per-type (N) counts consistent; no duplicate rows; the orchestrator's gate #5
54
+
55
+ summary: # a one-line human-readable summary
56
+ "<N> entries migrated; <M> merged; <R> normalized, <F> flagged; <P> pruned; <I> indexed"
57
+ ```
58
+
59
+ Also save the Maintain Log Artifact to `docs/plans/.learn/.maintain/<maintain-id>.md`.
60
+
61
+ ## Validation Rules
62
+
63
+ - **maintain-id:** Required. Format `YYYY-MM-DD-NNN-maintain` per [id-generation.md](../../id-generation.md). A maintain artifact **never** carries a `learn-id` (a `learn-id` here is treated as an orphan and logged per [error-handling.md](../../error-handling.md) Cross-Phase Consistency Checks).
64
+ - **interactionMode:** Required, propagated from the Learn Input Artifact.
65
+ - **status:** Required. `complete` (a partial maintain is `failed`; the user re-runs `/learn maintain` — runs are idempotent).
66
+ - **migration:** Required. `ran: false` with `result: "no-op (already migrated)"` (self-gated; the fast path is the `.migrated` marker, the robust path is slug-set parity per [migration-bootstrap.md](../../migration-bootstrap.md)). When `ran: true`: `result: "<N> entries migrated"`, `marker-written: true`. `legacy-store-deleted` is **always false** — the migration never deletes `docs/learnings/` (its removal is a separate prune the user explicitly runs if desired).
67
+ - **merges:** Required (may be `[]`). Each merge has `analog-slug`, `canonical-slug`, `analog-file`, `analog-kept: true`, `analog-superseded-note-written: true`, `canonical-related-updated: true`. **The analog file is never deleted** (lineage preserved per [dedup-rules.md](../../dedup-rules.md)).
68
+ - **refresh:** Required. `normalized-count` (non-destructive fixes; counted), `flagged-for-review-count`, `flagged-entries` (the slug list needing destructive changes — these are **not** auto-applied; the user decides).
69
+ - **prune:** Required (may be `[]`). Each prune has `slug`, `action` (`deleted` or `de-indexed`), and a `reason`. Each prune was **explicitly confirmed** by the user (destructive never silent, even in Autopilot). A deleted entry's file is gone; a de-indexed entry's file is kept with `status: obsolete`.
70
+ - **rebuild:** Required. `ran: true`, `entries-indexed: <N>` (the count of non-de-indexed on-disk entries), `coherence-fixes-applied: <N>` (should be 0 on a clean store; the rebuild reconciles any prior drift).
71
+ - **index-coherent:** Required. `true` — the orchestrator's quality gate #5; the rebuilt `docs/learn/index.md` YAML block length matches the on-disk entry-file count, per-type `(N)` counts are consistent, and no duplicate rows.
72
+ - **summary:** Required. A one-line human-readable record of what Maintain did.
73
+
74
+ ## Example (first-run maintain after the legacy store exists — migration + a merge + a prune)
75
+
76
+ ```yaml
77
+ maintain-id: 2026-08-08-001-maintain
78
+ interactionMode: smart
79
+ status: complete
80
+ timestamp: 2026-08-08T16:00:00Z
81
+ migration:
82
+ ran: true
83
+ result: "28 entries migrated"
84
+ marker-written: true
85
+ legacy-store-deleted: false
86
+ merges:
87
+ - analog-slug: redis-ttl-set-vs-expire
88
+ canonical-slug: ttl-must-propagate-to-redis-set
89
+ analog-file: docs/learn/gotcha/redis-ttl-set-vs-expire.md
90
+ analog-kept: true
91
+ analog-superseded-note-written: true
92
+ canonical-related-updated: true
93
+ refresh:
94
+ normalized-count: 14 # the older-layout pattern/workflow entries normalized to the canonical schema
95
+ flagged-for-review-count: 2
96
+ flagged-entries: [ cross-phase-id-chaining-2026-07-04, capability-described-not-tool-named-2026-08-07 ]
97
+ prune:
98
+ - slug: deprecated-skill-format-2026-06-01
99
+ action: de-indexed # the recommended default — file kept, status:obsolete, index record removed
100
+ reason: "Superseded by the canonical skill-format convention; user confirmed de-index."
101
+ rebuild:
102
+ ran: true
103
+ entries-indexed: 27
104
+ coherence-fixes-applied: 0
105
+ index-coherent: true
106
+ summary: "28 entries migrated; 1 merged; 14 normalized, 2 flagged; 1 pruned; 27 indexed"
107
+ ```
108
+
109
+ ## Example (steady-state maintain — no migration, just a refresh + rebuild)
110
+
111
+ ```yaml
112
+ maintain-id: 2026-08-25-003-maintain
113
+ interactionMode: autopilot
114
+ status: complete
115
+ timestamp: 2026-08-25T10:00:00Z
116
+ migration:
117
+ ran: false
118
+ result: "no-op (already migrated)"
119
+ marker-written: false
120
+ legacy-store-deleted: false
121
+ merges: []
122
+ refresh:
123
+ normalized-count: 0
124
+ flagged-for-review-count: 0
125
+ flagged-entries: []
126
+ prune: []
127
+ rebuild:
128
+ ran: true
129
+ entries-indexed: 31
130
+ coherence-fixes-applied: 0
131
+ index-coherent: true
132
+ summary: "0 entries migrated; 0 merged; 0 normalized, 0 flagged; 0 pruned; 31 indexed"
133
+ ```
134
+
135
+ ## Notes
136
+
137
+ - Maintain is **on-demand** (`/learn maintain`); it authors no new entry, hence the standalone `maintain-id` (no `learn-id` umbrella).
138
+ - The **migration is one-time and self-gating** — the `.migrated` marker is the fast path; slug-set parity is the robust path. A steady-state maintain records `migration.ran: false` with `result: "no-op (already migrated)"`.
139
+ - **Destructive operations are never silent**, even in Autopilot (per [interaction-mode-propagation.md](../../interaction-mode-propagation.md)): the migration rewrite, each merge, and each prune surface for user confirmation. Non-destructive refresh and the rebuild auto-proceed.
140
+ - **Lineage is preserved everywhere**: a merge keeps the analog's file with `superseded-by` + `status: obsolete`; the recommended prune action is `de-indexed` (keep the file, mark obsolete), not `deleted`. The legacy store is **never deleted by the migration** — removal is a separate, explicit prune the user runs.
141
+ - **`index-coherent: true`** is the orchestrator's quality gate #5; Maintain is responsible for leaving the rebuilt index coherent (the file tree is the source of truth, the YAML block and the markdown tables are two projections in lockstep).
142
+ - This artifact is Maintain's only **deliverable** — it describes what was reconciled, never a session transcript. The canonical knowledge base at `docs/learn/` is the durable source-of-truth outcome.
@@ -0,0 +1,168 @@
1
+ ---
2
+ title: Refined Entry Artifact
3
+ description: Template for the Refined Entry Artifact produced by the Refine phase. Carries the validated entry (frontmatter + body conforming to entry-schema), the resolved slug (may differ from Capture's proposal after a conflict), the dup-status (exact/analog/none) + the chosen resolution, and a lineage block when a merge occurred; consumed by Index.
4
+ type: template
5
+ version: 1.0
6
+ timestamp: "2026-08-08"
7
+ ---
8
+
9
+ # Refined Entry Artifact
10
+
11
+ The product of the **Refine** phase is a validated, conflict-resolved entry: frontmatter and body conforming to the authoritative [entry-schema.md](../../entry-schema.md) (which Refine validates against, never re-encodes), the **resolved** `slug` (may differ from Capture's proposal after a duplicate/analog conflict), the `dup-status` + `resolution` chosen by the user, and a `lineage` block when a merge occurred. Index consumes it to write the entry file and upsert the index. Refine validates and reconciles; it does not write.
12
+
13
+ ## Schema
14
+
15
+ ```yaml
16
+ refine-id: YYYY-MM-DD-NNN-refine
17
+ capture-id: YYYY-MM-DD-NNN-capture
18
+ learn-id: YYYY-MM-DD-NNN
19
+ input-shape: explicit | candidate
20
+ interactionMode: detailed | smart | autopilot
21
+ status: complete
22
+ timestamp: ISO-8601 timestamp
23
+
24
+ type: decision | pattern | gotcha | workflow # validated
25
+ slug: "<resolved-kebab-case-slug>" # validated; may differ from Capture's proposal (new-slug case)
26
+
27
+ frontmatter: # validated per entry-schema.md; Refine does not coerce silently
28
+ type: <same as type>
29
+ slug: <same as slug>
30
+ domain: <primary-domain>
31
+ priority: important | normal
32
+ applicability: { current_project: <0-10>, general: <0-10> }
33
+ tags: [tag-1, ..., tag-6] # 2-6 tags validated
34
+ created_at: ISO-8601 # preserved from Capture
35
+ updated_at: ISO-8601 # stamp of Refine's validation
36
+ source: { type, reference, extracted_at }
37
+ confidence: high | medium | low
38
+
39
+ body: | # per-type section template validated present (Refine does not auto-fill)
40
+ # <Title>
41
+
42
+ ## Problem
43
+ ...
44
+ ## ... remaining sections for the type ...
45
+
46
+ dup-status: exact | analog | none # the ref result of Refine Step 3 against existing entries
47
+ matched-slug: <existing-slug> | null # the entry Refine matched (exact or analog); null when none
48
+ match-evidence: | null # the shared signals (slug match, or domain+tags+type+conclusion)
49
+ resolution: update-existing | new-slug | merge-into-canonical | keep-separate | none
50
+ # chosen by the user per dedup-rules.md; none when dup-status==none
51
+
52
+ lineage: # set ONLY when resolution == merge-into-canonical
53
+ analog-slug: <the entry being merged-away> # the entry Refine matched (matched-slug) when merging
54
+ canonical-slug: <slug> # the canonical slug; same as the entry's slug above
55
+ analog-kept: true # the analog file is KEPT (de-indexed, not deleted) per dedup-rules.md
56
+ rationale: "<why merge, in one line>"
57
+
58
+ source-candidate: <carried from Capture> | null
59
+ ```
60
+
61
+ Also save the Refined Entry Artifact to `docs/plans/.learn/.refine/<refine-id>.md`.
62
+
63
+ ## Validation Rules
64
+
65
+ - **refine-id:** Required. Format `YYYY-MM-DD-NNN-refine` per [id-generation.md](../../id-generation.md).
66
+ - **capture-id, learn-id, input-shape:** Required, inherited from Capture (cross-phase consistency).
67
+ - **interactionMode:** Required, identical to the Capture artifact.
68
+ - **status:** Required. `complete`.
69
+ - **type:** Required. One of the four (re-confirmed by Refine Step 1).
70
+ - **slug:** Required. The **resolved** slug; kebab-case; globally unique (Refine confirmed no exact collision unless `resolution: new-slug`/`update-existing`).
71
+ - **frontmatter:** Required. Every required field validated per [entry-schema.md](../../entry-schema.md); `tags` length 2–6; numeric scores 0–10; `confidence`/`priority` in enums; `created_at` preserved, `updated_at` stamped.
72
+ - **body:** Required. The per-type section template present in full (Refine flagged any missing section as a pause trigger; auto-fill is forbidden).
73
+ - **dup-status:** Required. `exact`, `analogs`, or `none`.
74
+ - **matched-slug:** Required (= the existing slug) when `dup-status` is `exact` or `analog`; `null` when `none`.
75
+ - **match-evidence:** Required when `dup-status` is `exact` or `analog`; the shared signals (slug match, or domain+tags+type+conclusion overlap) so the user can confirm the match is real.
76
+ - **resolution:** Required. Must be one of `update-existing`, `new-slug`, `merge-into-canonical`, `keep-separate`, `none`; `none` only when `dup-status: none`.
77
+ - **lineage:** Required when `resolution: merge-into-canonical` (`analog-slug`, `canonical-slug`, `analogs-kept: true`, `rationale`); absent otherwise. `analogs-kept: true` is mandatory — Refine may not authorize deletion (the analog is de-indexed, not deleted, per [dedup-rules.md](../../dedup-rules.md)).
78
+ - **source-candidate:** Carried through from Capture (setter of the entry's `source.reference` traceability).
79
+
80
+ ## Example (explicit decision, no duplicate)
81
+
82
+ ```yaml
83
+ refine-id: 2026-08-08-001-refine
84
+ capture-id: 2026-08-08-001-capture
85
+ learn-id: 2026-08-08-001
86
+ input-shape: explicit
87
+ interactionMode: smart
88
+ status: complete
89
+ timestamp: 2026-08-08T14:32:00Z
90
+ type: decision
91
+ slug: use-pnpm-when-both-lockfiles-exist
92
+ frontmatter:
93
+ type: decision
94
+ slug: use-pnpm-when-both-lockfiles-exist
95
+ domain: tooling
96
+ priority: normal
97
+ applicability: { current_project: 8, general: 6 }
98
+ tags: [package-management, npm, pnpm, lockfiles]
99
+ created_at: 2026-08-08T14:30:00Z
100
+ updated_at: 2026-08-08T14:32:00Z
101
+ source: { type: commit, reference: "1ee04e2", extracted_at: 2026-08-08T14:30:00Z }
102
+ confidence: high
103
+ body: |
104
+ # Use pnpm When Both Lockfiles Exist
105
+ ## Problem
106
+ ...
107
+ ## Solution
108
+ ...
109
+ dup-status: none
110
+ matched-slug: null
111
+ match-evidence: null
112
+ resolution: none
113
+ source-candidate: null
114
+ ```
115
+
116
+ ## Example (analog → merge-into-canonical, lineage preserved)
117
+
118
+ ```yaml
119
+ refine-id: 2026-08-08-002-refine
120
+ capture-id: 2026-08-08-002-capture
121
+ learn-id: 2026-08-08-002
122
+ input-shape: candidate
123
+ interactionMode: smart
124
+ status: complete
125
+ timestamp: 2026-08-08T14:40:00Z
126
+ type: gotcha
127
+ slug: ttl-must-propagate-to-redis-set # the canonical stays (older entry here)
128
+ frontmatter:
129
+ type: gotcha
130
+ slug: ttl-must-propagate-to-redis-set
131
+ domain: data-storage
132
+ priority: important
133
+ applicability: { current_project: 8, general: 7 }
134
+ tags: [redis, ttl, session-store, caching]
135
+ created_at: 2026-07-10T00:00:00Z # preserved (older entry's created_at retained on merge)
136
+ updated_at: 2026-08-08T14:40:00Z
137
+ source: { type: candidate, reference: "2026-07-10-001-review#F02", extracted_at: 2026-08-08T14:35:00Z }
138
+ confidence: medium
139
+ body: |
140
+ # Redis TTL Must Propagate to the SET Command
141
+ ## Problem
142
+ ...
143
+ ## Trap / Solution / Prevention / Source ...
144
+ dup-status: analog
145
+ matched-slug: redis-ttl-set-vs-expire # the older lower-priority analog
146
+ match-evidence: |
147
+ same domain (data-storage) + 3 shared tags (redis, ttl, session-store) + same type (gotcha)
148
+ + same conclusion (SET ... EX must carry the TTL); different slug.
149
+ resolution: merge-into-canonical
150
+ lineage:
151
+ analog-slug: redis-ttl-set-vs-expire
152
+ canonical-slug: ttl-must-propagate-to-redis-set
153
+ analog-kept: true
154
+ rationale: "Same gotcha, same prevention; redis-ttl-set-vs-expire folds into the canonical with lineage."
155
+ source-candidate:
156
+ title: "Redis TTL must be propagated to the SET command"
157
+ domain: data-storage
158
+ source: { type: candidate, reference: "2026-07-10-001-review#F02" }
159
+ summary: "TTL test failed because SET ... EX must carry the TTL."
160
+ type: gotcha
161
+ ```
162
+
163
+ ## Notes
164
+
165
+ - Refine is the **validator + conflict resolver**; it does not write the entry file (Index does) and does not coerce frontmatter silently (a wrong field surfaces as a pause trigger, never a silent fix).
166
+ - The `slug` here is the **resolved** slug — it may differ from Capture's proposal only when a conflict chose `new-slug` (Capture proposed → existing collision → user renamed) or `update-existing` (Capture proposed → existing match → keep existing slug).
167
+ - The `lineage` block is the **single** place the merge's bookkeeping lives at Refine-time; Index reads it to perform the de-index + `superseded-by` write + `related` link on the canonical. `analogs-kept: true` is mandatory — Refine may not authorize deletion (de-index only, per [dedup-rules.md](../../dedup-rules.md)).
168
+ - `created_at` on a merge is the **older** entry's timestamp (the canonical's, often the existing entry's); `updated_at` stamps the merge. This preserves chronology across the absorption.