@lorekit/cli 1.69.0 → 1.70.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/skill/lorekit-groom/rules/grooming-pass.md +34 -0
- package/skill/lorekit-setup/SKILL.md +141 -104
- package/skill/lorekit-setup/rules/cold-start-seeding.md +102 -0
- package/skill/lorekit-setup/rules/loop-health.md +117 -0
- package/skill/lorekit-setup/rules/proving-improvement.md +111 -0
- package/skill/lorekit-setup/rules/self-improvement-loops.md +52 -4
- package/skill/lorekit-setup/rules/team-and-portfolio.md +107 -0
- package/skill/lorekit-setup/templates/README.md +26 -0
- package/skill/lorekit-setup/templates/ci-job.md +90 -0
- package/skill/lorekit-setup/templates/code-changing-agent.md +89 -0
- package/skill/lorekit-setup/templates/multi-step-orchestrator.md +76 -0
- package/skill/lorekit-setup/templates/reviewer-reconcile-host.md +86 -0
- package/src/commands/lint.mjs +4 -2
- package/src/shared/lessons-view.mjs +71 -0
package/package.json
CHANGED
|
@@ -60,6 +60,14 @@ Findings are structural, not semantic — each names its rule:
|
|
|
60
60
|
entry has no `kind`, so it renders as a raw JSON blob in every SessionStart
|
|
61
61
|
digest instead of being excluded by `isGeneralLesson`. Set `--kind bus` or
|
|
62
62
|
`--kind signal` on the record.
|
|
63
|
+
- **hidden-metadata** — the body carries an HTML comment, a leading front-matter
|
|
64
|
+
block, or a `key=value` header before the `#` title. This is the **repudiated
|
|
65
|
+
legacy `<!-- meta: seen_count=… status=… trigger-context=… -->` convention** the
|
|
66
|
+
`lorekit-setup` skill once prescribed and now forbids: an HTML comment renders to
|
|
67
|
+
nothing (so a human sees a lesson starting mid-sentence) while a baked-in
|
|
68
|
+
`seen_count` / `status` / `trigger` silently disagrees with the store's own
|
|
69
|
+
column / tag / field. **This is grooming's job to clean, not just report** — see
|
|
70
|
+
the cleanup step below.
|
|
63
71
|
|
|
64
72
|
These are the cheapest wins and the least controversial, so clear them first.
|
|
65
73
|
For each: either **fix it in place** (rewrite a too-short value into a real
|
|
@@ -68,6 +76,32 @@ updates in place) or, if the lesson is genuinely empty of meaning, **queue it fo
|
|
|
68
76
|
removal** in the plan. `lint` exits non-zero while findings remain, which also
|
|
69
77
|
makes it a clean CI gate — a passing `lint` is your Phase 6 proof.
|
|
70
78
|
|
|
79
|
+
### Cleaning a `hidden-metadata` finding (fold, then strip)
|
|
80
|
+
|
|
81
|
+
A hidden-metadata lesson is **fixed in place**, never deleted for it (the prose is
|
|
82
|
+
usually a real lesson wearing a bad header). Recover the facts into their proper
|
|
83
|
+
homes, then strip the block:
|
|
84
|
+
|
|
85
|
+
1. **Read the whole record** (`lorekit show <scope::key> --json`) so you see the raw
|
|
86
|
+
body, including the `<!--` block the SessionStart digest hides.
|
|
87
|
+
2. **Fold each buried fact into its first-class home**, never back into prose:
|
|
88
|
+
- `seen_count=N` → **drop it entirely.** The column is the only true copy; a
|
|
89
|
+
baked number is stale. Do not try to "restore" it — the store's counter is
|
|
90
|
+
authoritative.
|
|
91
|
+
- `status=structural` / `status=promoted` → a `status::<value>` **tag** on the write.
|
|
92
|
+
(`status=active` is the default — drop it.)
|
|
93
|
+
- `trigger-context="…"` → the visible **`Applies when:`** line at the top of the
|
|
94
|
+
body, and/or the `trigger` **field** for the category.
|
|
95
|
+
- `expires=…` / `ttl=…` → a `ttl_days` on the write.
|
|
96
|
+
3. **Rewrite the body as pure markdown** to the lesson shape (takeaway title →
|
|
97
|
+
`Applies when` → bold-labelled paragraphs), with the `<!--`/front-matter/header
|
|
98
|
+
gone, via a `memory.write` to the same `scope`+`key` (updates in place, carrying
|
|
99
|
+
the recovered tags/fields).
|
|
100
|
+
4. **Re-lint** the record to confirm `hidden-metadata` no longer fires.
|
|
101
|
+
|
|
102
|
+
Do this whenever a pass surfaces the finding — that is how the store stops
|
|
103
|
+
re-teaching the pattern to the next agent that reads a neighbouring lesson.
|
|
104
|
+
|
|
71
105
|
## Phase 3 — Dedupe (read-only)
|
|
72
106
|
|
|
73
107
|
```bash
|
|
@@ -1,31 +1,29 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: lorekit-setup
|
|
3
3
|
description: >
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
a
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
mistakes", "self-improving memory", "memory in CI", "GitHub Actions state",
|
|
22
|
-
"remember the last CI run", "/lorekit-setup".
|
|
4
|
+
Turns a skill, workflow, agent, or CI job into one that gets better across runs
|
|
5
|
+
and can PROVE it. Walks a six-step lifecycle — Find where a loop pays off, Wire
|
|
6
|
+
it from a ready-made recipe card, Seed it so it delivers on run one, Prove it
|
|
7
|
+
improved something, Maintain it so it does not rot, and Scale it to a team — with
|
|
8
|
+
a 15-minute quickstart that ends in a loop firing once, live. Under the hood it
|
|
9
|
+
is a LoreKit lessons loop: a fast episodic tier of advisory lessons read at the
|
|
10
|
+
start of every run and written on failure; a slow procedural tier that promotes a
|
|
11
|
+
recurring lesson into a permanent rule; and, for the rare judgement-free case, a
|
|
12
|
+
third rung that compiles a lesson into a mechanically-checked CI invariant. Also
|
|
13
|
+
covers the non-LLM case (durable JSON state records for a deterministic job) and
|
|
14
|
+
the guards that stop a learning loop from reinforcing its own mistakes. Runtime
|
|
15
|
+
reading and writing of lessons is the lorekit-memory skill; this is the authoring
|
|
16
|
+
counterpart. Use when giving a host durable cross-run memory or wiring a lessons
|
|
17
|
+
loop. Triggers on "set up memory for my skill", "add a self-improvement loop",
|
|
18
|
+
"give my workflow memory", "make this learn from its mistakes", "where should I
|
|
19
|
+
add a loop", "prove my loop is working", "self-improving memory", "memory in CI",
|
|
20
|
+
"GitHub Actions state", "remember the last CI run", "/lorekit-setup".
|
|
23
21
|
user-invocable: true
|
|
24
22
|
argument-hint: '[host-name]'
|
|
25
23
|
license: MIT
|
|
26
24
|
metadata:
|
|
27
25
|
author: mthines
|
|
28
|
-
version: '
|
|
26
|
+
version: '2.0.0'
|
|
29
27
|
workflow_type: memory-loop-authoring
|
|
30
28
|
tags:
|
|
31
29
|
- lorekit
|
|
@@ -41,40 +39,74 @@ metadata:
|
|
|
41
39
|
|
|
42
40
|
# LoreKit Setup
|
|
43
41
|
|
|
44
|
-
Give a host durable cross-run memory
|
|
45
|
-
**self-improvement loop**: it reads its own
|
|
46
|
-
every run and hardens the proven ones into
|
|
47
|
-
more it runs. For a deterministic host — a
|
|
48
|
-
reads what was true at the end of its last
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
or REST for jobs.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
|
65
|
-
|
|
|
66
|
-
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
keep the
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
42
|
+
Give a host durable cross-run memory, and make its improvement **visible**. For a
|
|
43
|
+
model-driven host that means a **self-improvement loop**: it reads its own
|
|
44
|
+
accumulated lessons at the start of every run and hardens the proven ones into
|
|
45
|
+
permanent rules, so it gets better the more it runs. For a deterministic host — a
|
|
46
|
+
CI job — it means **state records**: it reads what was true at the end of its last
|
|
47
|
+
run instead of rediscovering it.
|
|
48
|
+
|
|
49
|
+
This is the **authoring** counterpart to `lorekit-memory`. `lorekit-memory` does the
|
|
50
|
+
runtime read/write of individual lessons; `lorekit-setup` wires the durable memory
|
|
51
|
+
that calls those primitives on a host's behalf. Both run on the same LoreKit store —
|
|
52
|
+
over the `memory.*` MCP tools for agents, over the `lorekit` CLI or REST for jobs.
|
|
53
|
+
|
|
54
|
+
> A loop that nobody can see helping is indistinguishable from no loop. This skill
|
|
55
|
+
> treats "the host measurably got better" as the deliverable — not "a loop is
|
|
56
|
+
> wired." Every step below is judged against that.
|
|
57
|
+
|
|
58
|
+
## The lifecycle (start here)
|
|
59
|
+
|
|
60
|
+
A working loop is six steps. Do them in order; each links to the rule that covers it.
|
|
61
|
+
|
|
62
|
+
| # | Step | What it answers | Read |
|
|
63
|
+
| - | ---- | --------------- | ---- |
|
|
64
|
+
| 1 | **Find** | *Where* does a loop actually pay off? (Do not guess — the data already knows.) | [rules/self-improvement-loops.md § Find where a loop pays off](./rules/self-improvement-loops.md#find-where-a-loop-pays-off) |
|
|
65
|
+
| 2 | **Wire** | Add the read/write steps with the least effort — copy a recipe card. | [templates/](./templates/) + [rules/self-improvement-loops.md](./rules/self-improvement-loops.md) |
|
|
66
|
+
| 3 | **Seed** | Deliver value on run **one**, before any lesson has been earned. | [rules/cold-start-seeding.md](./rules/cold-start-seeding.md) |
|
|
67
|
+
| 4 | **Prove** | Show the loop reduced a real failure — not just that lessons exist. | [rules/proving-improvement.md](./rules/proving-improvement.md) |
|
|
68
|
+
| 5 | **Maintain** | Keep it firing, keep the bucket clean, roll back a bad lesson. | [rules/loop-health.md](./rules/loop-health.md) |
|
|
69
|
+
| 6 | **Scale** | Turn one person's loop into a team practice that compounds. | [rules/team-and-portfolio.md](./rules/team-and-portfolio.md) |
|
|
70
|
+
|
|
71
|
+
If invoked with a `host-name`, set up memory for that host and walk this lifecycle.
|
|
72
|
+
Otherwise ask which skill / workflow / agent / job it is for, pick the shape from
|
|
73
|
+
[Pick the shape](#pick-the-shape), then walk it.
|
|
74
|
+
|
|
75
|
+
## Quickstart (15 minutes, one loop firing once)
|
|
76
|
+
|
|
77
|
+
The shortest path from "I have a host" to "I watched the loop close." Do it against a
|
|
78
|
+
real host with `memory.*` connected.
|
|
79
|
+
|
|
80
|
+
1. **Name the bucket.** From the host's name `<host>`: tag `loop::<host>-lessons`,
|
|
81
|
+
key namespace `<host>-lessons::<slug>`. One bucket per host.
|
|
82
|
+
2. **Copy a recipe card.** Pick the archetype in [templates/](./templates/) that
|
|
83
|
+
matches your host (code-changing agent, reviewer/reconcile host, multi-step
|
|
84
|
+
orchestrator, CI job) and paste its read step at the host's start and its write
|
|
85
|
+
step at the host's existing failure points. The card already carries the
|
|
86
|
+
injection cap, the TTL, and the entrenchment defaults — do not hand-roll them.
|
|
87
|
+
3. **Seed one real lesson** (optional but recommended) so run one is not empty —
|
|
88
|
+
[rules/cold-start-seeding.md](./rules/cold-start-seeding.md). Keep it to a
|
|
89
|
+
*handful*, hand-checked.
|
|
90
|
+
4. **Fire it once, on purpose.** Trigger the failure the loop is meant to catch.
|
|
91
|
+
Confirm a lesson was written to the right scope with the right tag:
|
|
92
|
+
|
|
93
|
+
```text
|
|
94
|
+
memory.list { scope: "<the scope you expect>", tags: ["loop::<host>-lessons"], limit: 10 }
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
5. **Run again and watch it read back.** Start a second run over the same
|
|
98
|
+
situation. Confirm the lesson surfaces in the read step and biases the run.
|
|
99
|
+
That is the loop closing — the whole point, demonstrated once.
|
|
100
|
+
6. **Write down the success metric** you will use to prove it keeps helping —
|
|
101
|
+
[rules/proving-improvement.md](./rules/proving-improvement.md). The required one
|
|
102
|
+
is the *immunity re-challenge*: after you promote a lesson to a rule, the failure
|
|
103
|
+
signature should stop recurring.
|
|
104
|
+
|
|
105
|
+
That is a live, working loop. Everything below is depth on each step.
|
|
106
|
+
|
|
107
|
+
## Pick the shape
|
|
108
|
+
|
|
109
|
+
Two kinds of host want memory, and they want a different record. Decide which first:
|
|
78
110
|
|
|
79
111
|
| The host is… | Wants | Read |
|
|
80
112
|
| ------------ | ----- | ---- |
|
|
@@ -85,20 +117,44 @@ before reading further:
|
|
|
85
117
|
A host can want both, in separate buckets: the state record carries *what is true
|
|
86
118
|
right now*, the lesson carries *what we learned about it*.
|
|
87
119
|
|
|
88
|
-
##
|
|
120
|
+
## The rungs of a lessons loop (in one screen)
|
|
89
121
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
122
|
+
The runtime loop is two tiers, fast and slow; a third, rarer rung sits past promotion.
|
|
123
|
+
|
|
124
|
+
| Rung | Mechanism | Changes behavior? | Advisory or enforced? |
|
|
125
|
+
| ---- | --------- | ----------------- | ---------------------- |
|
|
126
|
+
| **Fast (episodic)** | LoreKit lessons in a per-host bucket, read at the start of a run, written on failure | **No** — advisory input only | Advisory |
|
|
127
|
+
| **Slow (procedural)** | A human-reviewed edit that hardens a recurring lesson into a host rule | **Yes** | Advisory (works only if the next reader notices it) |
|
|
128
|
+
| **Compiled invariant** | A declarative `obligations-map.mjs` entry a CI gate checks against a changed-file set — see [rules/compiled-invariants.md](./rules/compiled-invariants.md) | **Yes** | Enforced once `gating`; most lessons never qualify |
|
|
129
|
+
|
|
130
|
+
A recurrence gate connects the first two: a lesson that recurs (`seen_count >= 3`) or
|
|
131
|
+
carries the `status::structural` tag becomes promotion-eligible. Entrenchment guards
|
|
132
|
+
keep the fast tier from reinforcing its own wrong conclusions.
|
|
133
|
+
|
|
134
|
+
## Non-negotiables (do not "optimize these away")
|
|
135
|
+
|
|
136
|
+
Five co-requirements make the difference between a loop that helps and one that
|
|
137
|
+
quietly rots or crowds out the run it was meant to help. Every recipe card bakes
|
|
138
|
+
them in; if you wire by hand, wire these too:
|
|
139
|
+
|
|
140
|
+
1. **A lesson body is markdown for humans — nothing hidden.** No HTML comment, no
|
|
141
|
+
front-matter, no JSON blob, no `key=value` header. Every fact the store already
|
|
142
|
+
models goes in its own field, never restated in prose — see
|
|
143
|
+
[the body contract](#a-lesson-body-is-markdown-for-humans--nothing-hidden) below.
|
|
144
|
+
2. **Every loop declares a per-host injection cap.** A loop reads *at most* N lessons
|
|
145
|
+
into a run (the cards default to a small N). Many cheap loops with no cap tax
|
|
146
|
+
every session's context until agents ignore injected lore entirely.
|
|
147
|
+
3. **Every lesson expires.** `ttl_days` on the write, refreshed on recurrence, so a
|
|
148
|
+
stale belief decays instead of entrenching. Decay is automatic, never staffed.
|
|
149
|
+
4. **Lessons are advisory, never auto-applied.** The only path from a lesson to
|
|
150
|
+
changed behavior is the human-reviewed slow tier.
|
|
151
|
+
5. **Prove it, or it did not happen.** A loop earns its keep only when a real failure
|
|
152
|
+
stops recurring — [rules/proving-improvement.md](./rules/proving-improvement.md).
|
|
95
153
|
|
|
96
154
|
### A lesson body is markdown for humans — nothing hidden
|
|
97
155
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
front-matter, no JSON blob, and no `key=value` header. Every fact the store
|
|
101
|
-
already models goes in its own write field, never restated in the prose:
|
|
156
|
+
The `value` is **markdown a person reads**, and it carries no hidden payload. Every
|
|
157
|
+
fact the store already models goes in its own write field:
|
|
102
158
|
|
|
103
159
|
| Fact | Field, not prose |
|
|
104
160
|
| ---- | ---------------- |
|
|
@@ -109,46 +165,27 @@ already models goes in its own write field, never restated in the prose:
|
|
|
109
165
|
| Repo / branch / commit / PR | the `origin_*` fields |
|
|
110
166
|
| What triggered the write | `trigger` |
|
|
111
167
|
|
|
112
|
-
A hidden block does not just look untidy — it is *wrong*. A `seen_count=1` baked
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
begins mid-sentence.
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
168
|
+
A hidden block does not just look untidy — it is *wrong*. A `seen_count=1` baked into
|
|
169
|
+
prose is stale the first time the lesson recurs, while the column that governs
|
|
170
|
+
promotion moves without it; an HTML comment renders to nothing, so a human is shown a
|
|
171
|
+
lesson that begins mid-sentence. The full shape, the field-by-field rationale, and the
|
|
172
|
+
writing rules are [the lesson record](./rules/self-improvement-loops.md#the-lesson-record).
|
|
173
|
+
This contract is now checkable — `lorekit lint` flags a body that violates it, and the
|
|
174
|
+
`lorekit-groom` skill cleans legacy offenders.
|
|
119
175
|
|
|
120
176
|
## The shared codebase-knowledge layer (automatic cross-loop synergy)
|
|
121
177
|
|
|
122
|
-
A per-host lessons bucket is private to one host. There is also **one shared
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
## Set up CI state (deterministic hosts)
|
|
138
|
-
|
|
139
|
-
Follow [rules/ci-state-records.md](./rules/ci-state-records.md). It covers: when
|
|
140
|
-
LoreKit beats `actions/cache` (and when it does not), the `ci::<job>-state` bucket
|
|
141
|
-
convention, the versioned JSON envelope, the read/write steps with the `lorekit`
|
|
142
|
-
CLI or REST, a full GitHub Actions example, the guards (bounded cardinality, no
|
|
143
|
-
secrets, explicit expiry, never on the critical path, last-write-wins), and a
|
|
144
|
-
wiring checklist.
|
|
145
|
-
|
|
146
|
-
If invoked with a `host-name`, set up memory for that host; otherwise ask which
|
|
147
|
-
skill / workflow / agent / job it is for, pick the shape from the table above,
|
|
148
|
-
then walk that rule file's setup.
|
|
149
|
-
|
|
150
|
-
A lessons loop's runtime tier needs LoreKit's `memory.*` tools connected; if they
|
|
151
|
-
are not, the host's loop is a silent no-op (the slow tier — a normal source edit —
|
|
152
|
-
still works). A CI job needs a `lk_*` token in its environment instead, and
|
|
153
|
-
degrades to its first-run path when the store is unreachable. Designing either
|
|
154
|
-
needs no connection.
|
|
178
|
+
A per-host lessons bucket is private to one host. There is also **one shared bucket
|
|
179
|
+
every code-touching host reads and, under a contract, writes**: `codebase-knowledge` —
|
|
180
|
+
a repo-scoped, structurally-keyed record (`knowledge::<symbol>@<path>` facts,
|
|
181
|
+
`hotspot::<path>` counters) of what the codebase has taught every LoreKit loop that
|
|
182
|
+
touched it. Because the name is fixed and the key is structural, a loop wired by one
|
|
183
|
+
person compounds with a loop wired by another. The full specification is
|
|
184
|
+
[rules/self-improvement-loops.md § Shared codebase-knowledge](./rules/self-improvement-loops.md#shared-codebase-knowledge-the-standard-cross-loop-layer).
|
|
185
|
+
|
|
186
|
+
## Connectivity
|
|
187
|
+
|
|
188
|
+
A lessons loop's runtime tier needs LoreKit's `memory.*` tools connected; if they are
|
|
189
|
+
not, the host's loop is a silent no-op (the slow tier — a normal source edit — still
|
|
190
|
+
works). A CI job needs a `lk_*` token in its environment instead, and degrades to its
|
|
191
|
+
first-run path when the store is unreachable. Designing either needs no connection.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Cold-start seeding — value on run one
|
|
2
|
+
|
|
3
|
+
The honest cold start is a lie. A loop does not really begin empty — the lessons already
|
|
4
|
+
exist, scattered across git history, PR review threads, CI guard scripts, and the
|
|
5
|
+
`obligations-map`. They were just never written down as reusable memory. Seeding
|
|
6
|
+
harvests a *handful* of them so the loop's very first run reads real institutional
|
|
7
|
+
knowledge instead of nothing.
|
|
8
|
+
|
|
9
|
+
This is optional, and it trades one thing for another — read
|
|
10
|
+
[the measurement trade-off](#the-hard-rule-never-seed-a-loop-you-will-measure) before
|
|
11
|
+
you reach for it.
|
|
12
|
+
|
|
13
|
+
## Contents
|
|
14
|
+
|
|
15
|
+
- [When to seed (and when not to)](#when-to-seed-and-when-not-to)
|
|
16
|
+
- [The cap: a handful, hand-checked](#the-cap-a-handful-hand-checked)
|
|
17
|
+
- [The hard rule: never seed a loop you will measure](#the-hard-rule-never-seed-a-loop-you-will-measure)
|
|
18
|
+
- [Where the lessons already are](#where-the-lessons-already-are)
|
|
19
|
+
- [The flow](#the-flow)
|
|
20
|
+
- [Guards](#guards)
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## When to seed (and when not to)
|
|
25
|
+
|
|
26
|
+
Seed when the host's value is **invisible for its first week** — lessons only accrue on
|
|
27
|
+
repeated runs, so a freshly-wired loop delivers config, not a win, and people abandon
|
|
28
|
+
it before it pays off. A few real seeded lessons make run one useful.
|
|
29
|
+
|
|
30
|
+
Do **not** seed when you intend to *prove* the loop's lift (below), or when you cannot
|
|
31
|
+
find genuinely recurring pain to seed from — a fabricated lesson is worse than an empty
|
|
32
|
+
bucket.
|
|
33
|
+
|
|
34
|
+
## The cap: a handful, hand-checked
|
|
35
|
+
|
|
36
|
+
**Seed a handful (roughly ≤ 5), each one hand-checked. Never bulk-mine.** This is the
|
|
37
|
+
single most important rule here, and it runs against the instinct to "import everything."
|
|
38
|
+
|
|
39
|
+
Bulk seeding floods the bucket with generic, machine-drafted lessons that never get
|
|
40
|
+
opened. That tanks the exact pull-through ratio [proving-improvement.md](./proving-improvement.md)
|
|
41
|
+
reads, triggers the bucket-bloat [loop-health.md](./loop-health.md#keep-the-bucket-from-bloating)
|
|
42
|
+
fights, and buries the few seeds that were actually good — on day one. A small,
|
|
43
|
+
curated set is worth more than a large, automatic one.
|
|
44
|
+
|
|
45
|
+
## The hard rule: never seed a loop you will measure
|
|
46
|
+
|
|
47
|
+
Seeding writes lessons before the loop has run, so it **erases the clean baseline** the
|
|
48
|
+
immunity re-challenge needs. A seeded loop's improvement is unattributable — you cannot
|
|
49
|
+
tell the loop's own learning from the head start you handed it.
|
|
50
|
+
|
|
51
|
+
So it is one or the other, per loop:
|
|
52
|
+
|
|
53
|
+
| You want… | Then… |
|
|
54
|
+
| --------- | ----- |
|
|
55
|
+
| Value on run one | Seed it (a handful, curated). Accept that its lift is not cleanly provable. |
|
|
56
|
+
| Provable lift | Leave it cold. The first weeks are quieter, but the immunity check reads a real baseline. |
|
|
57
|
+
|
|
58
|
+
## Where the lessons already are
|
|
59
|
+
|
|
60
|
+
Mine these — they are recurring pain the team already paid for:
|
|
61
|
+
|
|
62
|
+
- **Git fix/revert chains** — the same pattern fixed the same way 3+ times, or a
|
|
63
|
+
revert-then-refix. `git log`, `git log --grep=revert`, `git log -p` over a hot file.
|
|
64
|
+
- **Recurring PR review comments** — the same review note left across many PRs.
|
|
65
|
+
- **Existing CI guard scripts** — a guard that exists *is* a lesson someone learned;
|
|
66
|
+
seed a `codebase-knowledge` fact pointing at it.
|
|
67
|
+
- **The `obligations-map`** — its path-keyed partnerships are compiled lessons; the
|
|
68
|
+
ones not yet gating are candidates. `lorekit invariants candidates` surfaces clusters.
|
|
69
|
+
- **`lorekit dedupe`** — near-duplicate existing lessons that should be one seed.
|
|
70
|
+
|
|
71
|
+
## The flow
|
|
72
|
+
|
|
73
|
+
1. **Mine** one or two of the sources above for genuinely recurring pain.
|
|
74
|
+
2. **Draft** ≤ 5 candidate lessons to the normal body shape
|
|
75
|
+
([the lesson record](./self-improvement-loops.md#the-lesson-record)) — a takeaway
|
|
76
|
+
title, a concrete **Applies when**, a prescriptive **Do this instead**.
|
|
77
|
+
3. **A human approves** the survivors. This is not skippable; seeding is the one place
|
|
78
|
+
a bad lesson enters with no recurrence evidence behind it.
|
|
79
|
+
4. **Write** each with provenance and a `source::seed` tag, so seeds are auditable and
|
|
80
|
+
distinguishable from earned lessons:
|
|
81
|
+
|
|
82
|
+
```text
|
|
83
|
+
memory.write {
|
|
84
|
+
scope: "<global | repo::<owner>/<repo>>",
|
|
85
|
+
key: "<host>-lessons::<slug>",
|
|
86
|
+
value: "<markdown lesson body — no hidden blocks>",
|
|
87
|
+
tags: ["loop::<host>-lessons", "source::seed"],
|
|
88
|
+
trigger: "manual",
|
|
89
|
+
origin_commit: "<the commit this was learned from, if any>",
|
|
90
|
+
ttl_days: 90
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Guards
|
|
95
|
+
|
|
96
|
+
- **The body contract still applies** — seeds are markdown for humans, no hidden blocks.
|
|
97
|
+
- **Tag seeds `source::seed`** so [loop-health](./loop-health.md) and grooming can tell a
|
|
98
|
+
head start from an earned lesson.
|
|
99
|
+
- **Privacy pre-flight is not skipped** — a seed mined from history can carry a secret or
|
|
100
|
+
a name; drop it, do not write it. The bar is stricter for `repo::` (team-visible).
|
|
101
|
+
- **Re-check the cap after mining.** If your candidate list is 40 long, you are
|
|
102
|
+
bulk-seeding — cut to the handful that actually recur.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Loop health — keeping it firing, clean, and honest
|
|
2
|
+
|
|
3
|
+
A wired loop is not a working loop. This file is the maintenance layer: how to tell the
|
|
4
|
+
loop is firing at all, how to catch a lesson that will never match the read that should
|
|
5
|
+
surface it, how to roll back a bad lesson without losing the evidence, how to stop the
|
|
6
|
+
bucket bloating, and how to keep every body honest. Most of it is a check you run once
|
|
7
|
+
at wiring time; the rest the `lorekit-groom` skill automates.
|
|
8
|
+
|
|
9
|
+
## Contents
|
|
10
|
+
|
|
11
|
+
- [Is the loop firing?](#is-the-loop-firing)
|
|
12
|
+
- [Does the write match the read? (matchability check)](#does-the-write-match-the-read-matchability-check)
|
|
13
|
+
- [Rolling back a bad lesson: quarantine, not delete](#rolling-back-a-bad-lesson-quarantine-not-delete)
|
|
14
|
+
- [Keep the bucket from bloating](#keep-the-bucket-from-bloating)
|
|
15
|
+
- [The body contract is now enforced](#the-body-contract-is-now-enforced)
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Is the loop firing?
|
|
20
|
+
|
|
21
|
+
The most common silent failure is a loop that never runs — a read step behind a
|
|
22
|
+
condition that is never true, or a `memory.*` connection that quietly dropped. Silence
|
|
23
|
+
looks identical to "no failures happened."
|
|
24
|
+
|
|
25
|
+
Turn the absence into a presence with a **canary**: at wiring time, plant one canary
|
|
26
|
+
lesson per bucket with a unique key and a `ttl_days` shorter than the loop's cadence.
|
|
27
|
+
|
|
28
|
+
```text
|
|
29
|
+
memory.write {
|
|
30
|
+
scope: "repo::<owner>/<repo>",
|
|
31
|
+
key: "<host>-lessons::canary",
|
|
32
|
+
value: "# Canary — if the read step surfaced this, the loop's read path works.",
|
|
33
|
+
tags: ["loop::<host>-lessons", "status::canary"],
|
|
34
|
+
trigger: "manual",
|
|
35
|
+
ttl_days: <shorter than the loop's run cadence>
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
If the loop is alive, its own read/write touches the canary and the store's usage
|
|
40
|
+
telemetry records it; if the canary quietly expires without ever being touched, the loop
|
|
41
|
+
is not firing — a diagnosable signal where silence was not. Check recency with
|
|
42
|
+
`lorekit stats` / `lorekit list --tags loop::<host>-lessons`. Exclude `status::canary`
|
|
43
|
+
from the run's actual considerations.
|
|
44
|
+
|
|
45
|
+
## Does the write match the read? (matchability check)
|
|
46
|
+
|
|
47
|
+
A lesson that the read step will never surface is dead on arrival — and you only find
|
|
48
|
+
out much later, when the same failure recurs and the loop "did not help." The only
|
|
49
|
+
moment you can catch it is at **write** time, when you still know what the lesson was
|
|
50
|
+
supposed to catch.
|
|
51
|
+
|
|
52
|
+
Right after writing a failure lesson, re-query the store with the **same terms the read
|
|
53
|
+
step uses** and confirm the just-written lesson comes back:
|
|
54
|
+
|
|
55
|
+
```text
|
|
56
|
+
memory.search { q: "<the failure's key terms>", scopes: ["repo::<owner>/<repo>", "global"], limit: 10 }
|
|
57
|
+
# Is the lesson you just wrote in the results? If not, its tags / Applies-when / scope
|
|
58
|
+
# do not match how the read step looks for it — fix them NOW, while you have the context.
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
A miss means a mismatch between how the lesson was written and how it will be sought —
|
|
62
|
+
usually a too-specific **Applies when**, a wrong scope, or a missing tag. Fixing it at
|
|
63
|
+
write time is cheap; discovering it at the next failure is not.
|
|
64
|
+
|
|
65
|
+
## Rolling back a bad lesson: quarantine, not delete
|
|
66
|
+
|
|
67
|
+
A loop can store a wrong conclusion. Deleting it destroys the evidence of *what the
|
|
68
|
+
agent believed* when it got stuck — which is exactly the forensic value you want right
|
|
69
|
+
after the harm. Prefer a reversible demotion:
|
|
70
|
+
|
|
71
|
+
1. **Quarantine** the suspect lesson: add a `status::quarantine` tag and shorten its
|
|
72
|
+
`ttl_days`. The start-of-run read filters `status::quarantine` OUT, so it stops
|
|
73
|
+
biasing runs, but it survives long enough for a human to inspect it.
|
|
74
|
+
2. **Inspect**, decide: rewrite it (a real lesson, badly phrased) or let it expire (a
|
|
75
|
+
genuine mistake).
|
|
76
|
+
3. **Protect** a lesson a human has vetted with `memory.protect`, so grooming and
|
|
77
|
+
auto-quarantine never touch it.
|
|
78
|
+
|
|
79
|
+
Delete only a lesson that is both wrong *and* worthless to inspect. Quarantine is the
|
|
80
|
+
default; deletion is the exception.
|
|
81
|
+
|
|
82
|
+
## Keep the bucket from bloating
|
|
83
|
+
|
|
84
|
+
Every lesson in a bucket competes for the run's read budget. Two mechanisms keep it
|
|
85
|
+
bounded:
|
|
86
|
+
|
|
87
|
+
- **The injection cap (a wiring precondition).** The loop reads at most N lessons into a
|
|
88
|
+
run (the recipe cards default N = 5). This bounds read cost *regardless* of how big the
|
|
89
|
+
bucket grows — it is the backstop.
|
|
90
|
+
- **Grooming.** Run the `lorekit-groom` skill periodically to merge near-duplicates,
|
|
91
|
+
expire the stale, and retire the never-opened (low pull-through). Grooming is where a
|
|
92
|
+
bucket's total size is actually reduced; the cap only bounds what a single run reads.
|
|
93
|
+
|
|
94
|
+
A bucket whose read is always dominated by low-value lessons is a grooming problem, not
|
|
95
|
+
a reason to raise the cap.
|
|
96
|
+
|
|
97
|
+
## The body contract is now enforced
|
|
98
|
+
|
|
99
|
+
Every lesson body is markdown for humans — no HTML comment, no front-matter, no JSON
|
|
100
|
+
blob, no `key=value` header ([the full contract](./self-improvement-loops.md#never-put-machine-metadata-in-the-body)).
|
|
101
|
+
This is no longer honor-system:
|
|
102
|
+
|
|
103
|
+
- **`lorekit lint` flags a violation.** A body containing `<!-- meta` / any `<!--`
|
|
104
|
+
block, leading front-matter (`---`), or a `key=value` header before the `#` title is
|
|
105
|
+
reported by the `hidden-metadata` lint rule. Run `lorekit lint` after a batch of
|
|
106
|
+
writes.
|
|
107
|
+
- **The `lorekit-groom` skill cleans legacy offenders.** The store still contains records
|
|
108
|
+
written under the old `<!-- meta: seen_count=… status=… trigger-context=… -->`
|
|
109
|
+
convention (which this skill once prescribed and now forbids); grooming detects them,
|
|
110
|
+
folds any recoverable value into the proper column/tag/field, and strips the block. See
|
|
111
|
+
the `lorekit-groom` skill.
|
|
112
|
+
- **The matchability check above** is the natural moment to also eyeball the body: if you
|
|
113
|
+
find yourself reaching for a compact hidden header, stop — every fact in it has a
|
|
114
|
+
first-class field.
|
|
115
|
+
|
|
116
|
+
Never write a hidden block. It renders to nothing for a human and its baked-in values
|
|
117
|
+
silently disagree with the store's own columns.
|