ecoportal-api-graphql 1.3.11 → 1.3.13

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 (54) hide show
  1. checksums.yaml +4 -4
  2. data/.ai-assistance/code/filter_contract_matrix.md +177 -0
  3. data/.ai-assistance/projects/compat-layer-audit/COMPAT_AUDIT.md +244 -0
  4. data/.ai-assistance/projects/template-automatic-build-maintenance/INTENT.md +10 -0
  5. data/.ai-assistance/projects/template-automatic-build-maintenance/TODO.md +11 -0
  6. data/.ai-assistance/projects/template-model-logic/CATEGORY_CATALOG.md +236 -0
  7. data/.ai-assistance/projects/template-model-logic/CLASSIFICATION_SPIKE.md +243 -0
  8. data/.ai-assistance/projects/template-model-logic/DESIGN_NOTE.md +154 -0
  9. data/.ai-assistance/scripts/bridge-inbox-check.sh +75 -0
  10. data/.ai-assistance/skills/procedural-memory/SKILL.md +319 -0
  11. data/.ai-assistance/skills/project-self-docs/SKILL.md +181 -0
  12. data/.ai-assistance/skills/project-self-docs/scripts/self_docs_scan.py +378 -0
  13. data/.ai-assistance/standards-version.json +22 -21
  14. data/.claude/settings.json +150 -146
  15. data/.gitlab-ci.yml +45 -0
  16. data/CHANGELOG.md +58 -0
  17. data/CLAUDE.md +11 -0
  18. data/docs/self-docs/ARCHITECTURE.md +88 -0
  19. data/docs/self-docs/CHANGES.jsonl +12 -0
  20. data/docs/self-docs/COMPLIANCE.md +79 -0
  21. data/docs/self-docs/CONVENTIONS.md +74 -0
  22. data/docs/self-docs/INTEGRATIONS.md +65 -0
  23. data/docs/self-docs/OPERATIONS.md +76 -0
  24. data/docs/self-docs/OVERVIEW.md +64 -0
  25. data/docs/self-docs/STATUS.md +73 -0
  26. data/docs/self-docs/self-docs-index.json +51 -0
  27. data/docs/worklog.md +15 -20
  28. data/lib/ecoportal/api/common/graphql/client.rb +2 -0
  29. data/lib/ecoportal/api/common/graphql/http_client.rb +189 -177
  30. data/lib/ecoportal/api/common/graphql/model/diffable.rb +54 -54
  31. data/lib/ecoportal/api/graphql/base/action.rb +43 -43
  32. data/lib/ecoportal/api/graphql/base/contractor_entity/member_changes.rb +67 -67
  33. data/lib/ecoportal/api/graphql/base/page/data_field/collection.rb +7 -0
  34. data/lib/ecoportal/api/graphql/base/page/data_field/contractor_entities.rb +28 -28
  35. data/lib/ecoportal/api/graphql/base/page/data_field/file_field.rb +25 -25
  36. data/lib/ecoportal/api/graphql/base/page/data_field/image_gallery.rb +24 -24
  37. data/lib/ecoportal/api/graphql/base/page/section_collection.rb +85 -79
  38. data/lib/ecoportal/api/graphql/base/preset_view.rb +17 -17
  39. data/lib/ecoportal/api/graphql/base/register.rb +18 -18
  40. data/lib/ecoportal/api/graphql/compat/filter_translator.rb +63 -28
  41. data/lib/ecoportal/api/graphql/concerns/page_compat.rb +51 -51
  42. data/lib/ecoportal/api/graphql/concerns.rb +14 -14
  43. data/lib/ecoportal/api/graphql/file_upload/client.rb +181 -181
  44. data/lib/ecoportal/api/graphql/fragment/page.rb +85 -85
  45. data/lib/ecoportal/api/graphql/input/action/update.rb +14 -14
  46. data/lib/ecoportal/api/graphql/input/contractor_entity/update.rb +41 -41
  47. data/lib/ecoportal/api/graphql/input/location_structure/apply_commands.rb +47 -47
  48. data/lib/ecoportal/api/graphql/input/location_structure/draft/add_commands.rb +49 -49
  49. data/lib/ecoportal/api/graphql/input/location_structure/update_command.rb +27 -27
  50. data/lib/ecoportal/api/graphql/input/search_conf.rb +436 -367
  51. data/lib/ecoportal/api/graphql/interface/location_structure/command.rb +30 -30
  52. data/lib/ecoportal/api/graphql/logic/input.rb +26 -26
  53. data/lib/ecoportal/api/graphql_version.rb +1 -1
  54. metadata +20 -1
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env bash
2
+ # bridge-inbox-check.sh -- session-start actuator for the bridge inbox.
3
+ #
4
+ # Closes an actuation-coverage gap: unread cross-project bridge messages used to be
5
+ # visible only if someone manually ran a command. This is the trigger/clock that
6
+ # surfaces them automatically at session start, mirroring the standards-inbox report
7
+ # line (see CLAUDE.md and standards/governance/standards-request-protocol.md).
8
+ #
9
+ # DETERMINISTIC and zero-LLM: it just scans .ai-assistance/bridge/inbox/ for unread
10
+ # messages (STATUS: PENDING) and prints one summary line plus one line per message:
11
+ #
12
+ # [bridge] N unread message(s)
13
+ # - {title} from {FROM}
14
+ #
15
+ # Contract (mirrors the other hook scripts):
16
+ # - Silent (no output) and exit 0 when the inbox is empty or has no unread messages.
17
+ # - NEVER fails fatally -- always exits 0, even on a malformed file or missing dir.
18
+ # - No side effects: read-only, does not touch or move any message.
19
+ #
20
+ # Wired as a SessionStart hook in .claude/settings.json:
21
+ # bash scripts/bridge-inbox-check.sh 2>/dev/null || true
22
+ #
23
+ # Manual run (same output): bash scripts/bridge-inbox-check.sh
24
+ set -u
25
+
26
+ # Resolve the bridge inbox from this script's location so it works from any cwd.
27
+ # This script is deployed at .ai-assistance/scripts/, so the inbox is a sibling
28
+ # of the scripts dir: ../bridge/inbox (mirrors bridge-init.sh in this repo).
29
+ SCRIPT_DIR="$(cd "$(dirname "$0")" 2>/dev/null && pwd)" || exit 0
30
+ INBOX="$SCRIPT_DIR/../bridge/inbox"
31
+
32
+ # No inbox -> nothing to report.
33
+ [ -d "$INBOX" ] || exit 0
34
+
35
+ # An "unread" message is a *.md file whose header carries STATUS: PENDING.
36
+ # (PENDING = not yet picked up by the receiving agent; IN_PROGRESS/DONE/FAILED are read.)
37
+ unread=""
38
+ count=0
39
+
40
+ for f in "$INBOX"/*.md; do
41
+ # Guard against the literal glob when the folder is empty.
42
+ [ -e "$f" ] || continue
43
+
44
+ # Only inspect the header block (first ~15 lines) -- cheap and format-stable.
45
+ header="$(head -n 15 "$f" 2>/dev/null || true)"
46
+
47
+ # Unread == STATUS: PENDING (case-insensitive, tolerant of surrounding whitespace).
48
+ printf '%s\n' "$header" | grep -Eiq '^[[:space:]]*STATUS:[[:space:]]*PENDING[[:space:]]*$' || continue
49
+
50
+ # Title: the text after "# TASK:" on line 1; fall back to the filename.
51
+ title="$(printf '%s\n' "$header" \
52
+ | grep -Ei '^#[[:space:]]*TASK:' \
53
+ | head -n 1 \
54
+ | sed -E 's/^#[[:space:]]*TASK:[[:space:]]*//' 2>/dev/null || true)"
55
+ [ -n "$title" ] || title="$(basename "$f" .md)"
56
+
57
+ # Sender: the text after "FROM:"; fall back to "unknown".
58
+ from="$(printf '%s\n' "$header" \
59
+ | grep -Ei '^[[:space:]]*FROM:' \
60
+ | head -n 1 \
61
+ | sed -E 's/^[[:space:]]*FROM:[[:space:]]*//I' 2>/dev/null || true)"
62
+ [ -n "$from" ] || from="unknown"
63
+
64
+ count=$((count + 1))
65
+ unread="${unread}- ${title} from ${from}
66
+ "
67
+ done
68
+
69
+ # Silent when there is nothing unread.
70
+ [ "$count" -gt 0 ] || exit 0
71
+
72
+ printf '[bridge] %d unread message(s)\n' "$count"
73
+ printf '%s' "$unread"
74
+
75
+ exit 0
@@ -0,0 +1,319 @@
1
+ ---
2
+ name: procedural-memory
3
+ category: governance
4
+ version: 0.2.0
5
+ status: draft
6
+ description: >
7
+ Distills accumulated session signals into stored `procedural` memory entries
8
+ (recurring routines: a trigger condition + the action that reliably follows) and
9
+ surfaces them as likely next steps. Invoke on a periodic distill pass or when a
10
+ developer asks what patterns you have noticed in how they work.
11
+ triggers:
12
+ - what patterns have you noticed
13
+ - distill my routines
14
+ - procedural memory
15
+ - how do I work
16
+ - learn my routines
17
+ - weekly distill
18
+ - modus operandi
19
+ applicable_to:
20
+ - any
21
+ ---
22
+
23
+ # procedural-memory
24
+
25
+ ## Purpose
26
+
27
+ Turn the substrate of accumulated session history into stored **`procedural`** memory --
28
+ recurring routines, each expressed as a **trigger condition** and the **inferred action**
29
+ that reliably follows it -- and surface those routines (plus a short "likely next steps"
30
+ list) so the next session starts proactively shaped instead of from scratch.
31
+
32
+ This skill operationalizes the **Distill** stage of the Observe -> Distill -> Act loop, plus
33
+ the human-facing part of the **Act** stage (surfacing). It implements
34
+ `standards/workflows/procedural-memory.md`. Observation (the `Stop`/`SessionEnd` logging
35
+ substrate) and autonomous execution (the auto-worker) are out of scope here -- this skill
36
+ reads the Observe substrate and writes the inferred routines; it never acts on them itself.
37
+
38
+ > **v0.2.0 -- draft-aligned, blockers resolved.** This skill tracks
39
+ > `standards/workflows/procedural-memory.md` at v0.2.0 (`status: draft`, ready for consolidation
40
+ > review). It implements the now-decided **decay/retirement lifecycle** (D1) and **Observe-stage
41
+ > privacy policy** (D2). The distill cadence, the minimum-observation threshold, the promotion
42
+ > rule, and the lifecycle numbers (confidence steps, retirement floor, staleness/cool-off
43
+ > windows) are all **provisional** and will firm up when the standard reaches `status: reviewed`.
44
+ > Treat the numbers below as conservative defaults, not settled policy.
45
+
46
+ ---
47
+
48
+ ## When to invoke
49
+
50
+ - **On a periodic distill pass** -- e.g. weekly, or as part of an end-of-week wrap-up. This is
51
+ the primary mode: a scheduled mining pass over accumulated session history.
52
+ - **On demand** -- when a developer asks "what patterns have you noticed in how I work?",
53
+ "distill my routines", or similar. Run the same procedure, scoped to the data available.
54
+
55
+ Do not invoke this skill to *perform* a routine -- it only distils and surfaces. Acting on a
56
+ surfaced routine is gated separately (see HARD CONSTRAINTS).
57
+
58
+ ---
59
+
60
+ ## On invocation
61
+
62
+ Before any other output, do both of the following:
63
+
64
+ 1. Print to the user:
65
+ `[skill: procedural-memory] <one-line description of what you are about to do>`
66
+ Examples:
67
+ - Periodic pass: `[skill: procedural-memory] weekly distill — mining usage log for recurring routines`
68
+ - On demand: `[skill: procedural-memory] reviewing session history for patterns in how you work`
69
+
70
+ 2. Append a usage record to `.ai-assistance/local/kpi/usage-<YYYY-WNN>.jsonl`
71
+ (ISO week format, e.g. `2026-W26`):
72
+ ```json
73
+ {"component": "skill/procedural-memory", "action": "invoked", "detail": "<same one-liner>", "ts": "<ISO timestamp>", "session_id": "<if known>"}
74
+ ```
75
+ Before writing, run the scrub/redaction pass (see Privacy below) over the record. If the file
76
+ or directory does not exist, create it. If writing fails, continue silently.
77
+
78
+ ### Consent check (do this first)
79
+
80
+ The Observe log is **opt-in**. Before reading any `usage-*.jsonl` to mine routines, confirm the
81
+ developer has enabled Observe (`procedural_memory.observe: true` in local settings, or the
82
+ equivalent Observe-hook entry). If consent is not set, report that the Observe stage is not
83
+ enabled, do NOT read the log, and stop. (Writing this skill's own invoked/completed usage
84
+ records is the skill announcing itself and is unaffected by the Observe consent flag.)
85
+
86
+ ---
87
+
88
+ ## The procedure
89
+
90
+ ### Step 1 -- Read the Observe substrate
91
+
92
+ The Observe stage is append-only and machine-local; this skill only reads it. Read only after
93
+ the consent check above has passed.
94
+
95
+ - Read `.ai-assistance/local/kpi/usage-<YYYY-WNN>.jsonl` across the distill window (default: the
96
+ current and previous 3 ISO weeks). These records carry only low-sensitivity signal: command/
97
+ tool names (not arguments), file paths/types touched, components invoked, event types and
98
+ `action` values, and coarse durations/counts -- never full arguments, file contents, or
99
+ prompt/response text (see Privacy below). Parse defensively: skip malformed/corrupt JSON lines
100
+ rather than failing the whole pass.
101
+ - Optionally read `docs/worklog.md` for `<!-- LEARNING: ... -->` markers. These are the
102
+ human-authored analogue of a `procedural` entry and may seed the distill pass
103
+ (`standards/workflows/session-handoff.md`).
104
+
105
+ If no usage log exists, report that the Observe substrate is not yet populated and stop --
106
+ there is nothing to distil. Do not invent routines from a single session.
107
+
108
+ ### Step 2 -- Mine for recurring patterns
109
+
110
+ A pattern is a **trigger condition** plus the **action that reliably follows it** within the
111
+ same or the next session. Look for:
112
+
113
+ - An action that consistently follows a specific event (e.g. a code-spec regeneration that
114
+ follows every merge to `main`).
115
+ - A consistent ordering of actions (e.g. tests -> lint -> commit).
116
+ - A deferral that is consistently picked up at a predictable later point.
117
+
118
+ **Minimum-observation threshold.** A pattern is only written if it was **observed in >= 3
119
+ distinct sessions** in the window. This default is deliberately conservative to stop a one-off
120
+ coincidence becoming a stored routine; the standard leaves the exact number open, so treat
121
+ this as **provisional**. Below threshold: note it as a *candidate* in the report, but do not
122
+ write a memory entry.
123
+
124
+ ### Step 3 -- Write each confirmed pattern as a `procedural` memory entry
125
+
126
+ Write each pattern at or above threshold into the repo-scoped memory directory
127
+ `~/.claude/projects/<project>/memory/` (auto memory -- repo-scoped and machine-local), as a
128
+ memory entry of **type `procedural`**. The body carries **Trigger:** and **Inferred action:**
129
+ lines, mirroring how `feedback` entries use **Why:** / **How to apply:**:
130
+
131
+ ```markdown
132
+ ## [Short routine name]
133
+
134
+ **Trigger:** [the observed condition that recurs]
135
+ **Inferred action:** [what the developer reliably does next]
136
+ **Confidence:** 0.6
137
+ **First-observed:** [YYYY-MM-DD]
138
+ **Last-observed:** [YYYY-MM-DD]
139
+
140
+ Observed in X of Y opportunities across N sessions (source: usage-<YYYY-WNN> ... usage-<YYYY-WNN>).
141
+ ```
142
+
143
+ New entries start at **Confidence: 0.6** (provisional) -- above the retirement floor, below full
144
+ trust, so a freshly inferred routine starts on probation. **First-observed** and **Last-observed**
145
+ are both set to the current distill-pass date on first write. These three lines are required: they
146
+ drive the decay/retirement lifecycle in Step 3b.
147
+
148
+ Then add the index pointer line to `~/.claude/projects/<project>/memory/MEMORY.md`, matching
149
+ the existing index style:
150
+
151
+ ```markdown
152
+ - [Procedural: <short routine name>](<filename>.md) — <one-line trigger → action summary>
153
+ ```
154
+
155
+ Mark the entry clearly as `procedural` so it stays distinguishable from `user`/`project`
156
+ memory (see HARD CONSTRAINTS).
157
+
158
+ ### Step 3b -- Re-evaluate, decay, and retire existing routines
159
+
160
+ On every distill pass, before reporting, walk each existing `procedural` entry and update its
161
+ lifecycle metadata (standard D1). Honour forced markers first, then apply the arithmetic.
162
+
163
+ 1. **Forced markers (one-shot, applied first).** Scan `docs/worklog.md` and the memory files for:
164
+ - `<!-- RETIRE: <short routine name> -->` -- retire that routine immediately (see step 4
165
+ below), regardless of confidence or recency.
166
+ - `<!-- CONFIRM: <short routine name> -->` -- set its **Confidence** to `1.0` and refresh
167
+ **Last-observed** to today.
168
+ Record that the marker was applied so it is not re-applied on the next pass.
169
+
170
+ 2. **Re-evaluate against this window.** For each routine whose **Trigger** occurred at least once
171
+ in the window:
172
+ - trigger fired AND inferred action followed: refresh **Last-observed** to today and
173
+ **increment Confidence by +0.1**, capped at `1.0`;
174
+ - trigger fired but action did NOT follow: **decrement Confidence by -0.2** (contradiction
175
+ costs more than a single confirmation earns -- intentional asymmetry);
176
+ - trigger did not fire at all: leave Confidence unchanged; do NOT refresh Last-observed.
177
+
178
+ 3. **Retire** a routine when EITHER its **Confidence < 0.3** (floor) OR its **Last-observed** is
179
+ **older than 90 days** (staleness window). All thresholds provisional.
180
+
181
+ 4. **Archive on retirement -- never silent-delete.** Move the entry file to
182
+ `~/.claude/projects/<project>/memory/retired/`, appending the retirement date and reason
183
+ (`confidence floor` / `staleness` / `forced`). Remove its line from `MEMORY.md`. Keep a
184
+ tombstone (routine name + retirement date + reason). When mining (Step 2), if a re-detected
185
+ Trigger/Inferred-action pair matches a tombstone retired **within the last 30 days**
186
+ (cool-off, provisional), do NOT auto-write it -- surface it as a *candidate* for the developer
187
+ to re-confirm. After the cool-off it may be written fresh at the initial confidence.
188
+
189
+ ### Step 4 -- Promotion (propose only)
190
+
191
+ A routine observed consistently **across multiple repos** is a candidate cross-project trait
192
+ for user-global memory in `~/.claude/CLAUDE.md`. **Propose it -- do not auto-promote.** Present
193
+ the candidate and the evidence; the developer decides. The exact promotion threshold is an
194
+ open question in the standard and is provisional here.
195
+
196
+ ### Step 5 -- Act / surface
197
+
198
+ Present the result to the developer:
199
+
200
+ 1. The distilled routines (newly written and pre-existing) for this repo.
201
+ 2. A short **"likely next steps"** list inferred from the current state and the routines.
202
+ 3. For routines whose inferred action is mechanically actionable, **PROPOSE** (never auto-add)
203
+ an `[auto]` tag so the auto-worker could pre-stage it -- subject to the developer confirming
204
+ the tag. The `[auto]` tag is the authorization boundary; eligibility rules in
205
+ `standards/tooling/auto-worker-eligibility.md` still apply, and this skill never tags
206
+ anything itself.
207
+
208
+ After surfacing, append a completion usage record:
209
+ ```json
210
+ {"component": "skill/procedural-memory", "action": "completed", "detail": "<N routines written, M candidates, K promotions proposed>", "ts": "<ISO timestamp>", "session_id": "<if known>"}
211
+ ```
212
+
213
+ ---
214
+
215
+ ## HARD CONSTRAINTS
216
+
217
+ From `standards/workflows/procedural-memory.md` -- these are not optional:
218
+
219
+ - **A `procedural` entry is an inference, not an asserted fact.** It must remain visibly
220
+ distinguishable from `user`/`project` memory (which record things the developer stated), so
221
+ a wrong inference can be retired without eroding trust in asserted facts.
222
+ - **Suggest, never act.** A distilled routine may *suggest* a next step or an `[auto]` tag, but
223
+ it must not drive an autonomous action without a human-in-the-loop confirmation. Any routine
224
+ that would trigger an irreversible or shared-system action is subject to
225
+ `standards/workflows/hitl-gates.md` -- inference grants no authority to act.
226
+ - **Observe logging is opt-in, scrubbed, and machine-local (standard D2).** The Observe hook is
227
+ off by default; do not read the usage log to mine routines unless consent is set (see Consent
228
+ check). Capture only the documented allow-list -- command/tool names, file paths/types, event
229
+ types, durations -- and NEVER full arguments, file contents, diffs, or prompt/response text.
230
+ Run the scrub/redaction pass (regex for tokens/keys, emails, obvious PII; replace with typed
231
+ placeholders; drop a record that cannot be confidently scrubbed) BEFORE writing any record.
232
+ Never copy the log off the machine, into a versioned file, or into a `procedural`/promoted
233
+ entry -- entries store only the distilled Trigger/Inferred-action plus aggregate evidence.
234
+ - **Decay and retirement are mandatory (standard D1).** Every `procedural` entry carries
235
+ **Confidence**, **First-observed**, and **Last-observed**. Each pass re-evaluates them, retires
236
+ entries below the floor or past the staleness window, honours `<!-- RETIRE: -->` /
237
+ `<!-- CONFIRM: -->` markers, and archives (never silently deletes) retired entries with a
238
+ cool-off tombstone so a retired routine does not silently reappear.
239
+ - **Repo-relative paths only** in any versioned output. Use `~/.claude/...` solely as the
240
+ canonical memory location, never a developer's absolute filesystem path.
241
+
242
+ ### Privacy -- what the Observe log captures, redacts, and where it lives
243
+
244
+ - **Captured:** command/tool names; file paths/types touched (repo-relative); event types and
245
+ `action` values; coarse durations and counts; timestamps, ISO-week, session id.
246
+ - **Never captured:** full command arguments; file contents or diffs; prompt/response text; the
247
+ literal text of corrections/redirects (only that one occurred, and its coarse type); secrets,
248
+ tokens, credentials, env values.
249
+ - **Redaction:** scrub-before-write -- regex detectors for tokens/keys (high-entropy strings,
250
+ `sk-`/`ghp_`/AWS-style prefixes), emails, obvious PII; matches replaced with `<REDACTED:...>`;
251
+ unscrubabble records dropped.
252
+ - **Storage/consent:** lives only at `.ai-assistance/local/kpi/usage-<YYYY-WNN>.jsonl`
253
+ (machine-local, gitignored, never committed). Enable via `procedural_memory.observe: true` in
254
+ local settings; disable by removing it; the developer may delete the log at any time.
255
+
256
+ ---
257
+
258
+ ## Example -- one mined pattern -> resulting `procedural` entry
259
+
260
+ **Observed.** Over four ISO weeks the usage log shows that in 4 of 4 sessions ending with a
261
+ merge to `main`, the same or next session regenerates code-specs and bumps the changelog
262
+ before any new branch is opened. 4 sessions >= the threshold of 3, so it is written.
263
+
264
+ Resulting file `~/.claude/projects/<project>/memory/procedural-merge-followup.md`:
265
+
266
+ ```markdown
267
+ ## Post-merge spec + changelog routine
268
+
269
+ **Trigger:** a feature branch is merged to `main`.
270
+ **Inferred action:** regenerate code-specs and bump the changelog before opening the next branch.
271
+ **Confidence:** 0.6
272
+ **First-observed:** 2026-06-28
273
+ **Last-observed:** 2026-06-28
274
+
275
+ Observed in 4 of 4 opportunities across 4 sessions (source: usage-2026-W22 ... usage-2026-W25).
276
+ ```
277
+
278
+ On a later pass, if a merge to `main` is NOT followed by the spec+changelog action, Confidence
279
+ drops by 0.2; sustained contradiction (or a `<!-- RETIRE: Post-merge spec + changelog routine -->`
280
+ marker, or 90 days without observation) retires it to `memory/retired/`.
281
+
282
+ Index line added to `MEMORY.md`:
283
+
284
+ ```markdown
285
+ - [Procedural: Post-merge spec + changelog routine](procedural-merge-followup.md) — merge to main → regenerate code-specs + bump changelog
286
+ ```
287
+
288
+ Surfaced at the next post-merge session as a likely next step, with a *proposal* (awaiting
289
+ confirmation) to tag "regenerate code-specs `[auto]`".
290
+
291
+ ---
292
+
293
+ ## What this skill does NOT do
294
+
295
+ - Does not run the Observe stage -- it reads the usage log; it does not write session signals.
296
+ - Does not execute any routine, autonomously or otherwise -- surfacing only.
297
+ - Does not add an `[auto]` tag -- it proposes; the developer confirms.
298
+ - Does not auto-promote a routine to `~/.claude/CLAUDE.md` -- it proposes; the developer decides.
299
+ - Does not write a routine below the minimum-observation threshold.
300
+ - Does not read the Observe log without consent set (Observe is opt-in, off by default).
301
+ - Does not write any record to the usage log without first running the scrub/redaction pass.
302
+ - Does not capture command arguments, file contents, diffs, or prompt/response text.
303
+ - Does not copy machine-local log contents into any versioned or promoted file.
304
+ - Does not silently delete a retired routine -- it archives to `memory/retired/` with a tombstone.
305
+ - Does not re-write a routine retired within the cool-off window -- it surfaces it as a candidate.
306
+ - Does not modify `user`/`project`/`feedback`/`reference` memory entries -- it only adds and
307
+ maintains `procedural` entries.
308
+
309
+ ---
310
+
311
+ ## Version note
312
+
313
+ v0.2.0 is aligned with `standards/workflows/procedural-memory.md` at v0.2.0 (`status: draft`,
314
+ ready for consolidation review). It implements the now-decided decay/retirement lifecycle (D1)
315
+ and Observe-stage privacy policy (D2). The distill cadence (weekly placeholder), the
316
+ minimum-observation threshold (`>= 3 sessions`), the cross-repo promotion rule, and the lifecycle
317
+ numbers (initial confidence 0.6, +0.1/-0.2 steps, 0.3 floor, 90-day staleness, 30-day cool-off)
318
+ are all provisional. They will be revisited and firmed up when the standard reaches
319
+ `status: reviewed`; this skill should be re-versioned to match.
@@ -0,0 +1,181 @@
1
+ ---
2
+ name: project-self-docs
3
+ category: knowledge
4
+ version: 0.2.0
5
+ description: >
6
+ Generate and maintain a project's own committed self-documentation set (a stable-schema
7
+ OVERVIEW/ARCHITECTURE/CONVENTIONS/INTEGRATIONS/STATUS/COMPLIANCE/OPERATIONS) plus a machine-readable index and
8
+ changelog, so the project can later feed a central coordination hub. A thin orchestrator:
9
+ it reuses ai-discovery/code-specs/discovery-manifest findings and a deterministic scanner,
10
+ and never invents a documentation format. Invoke to create, refresh, or verify self-docs.
11
+ triggers:
12
+ - self docs
13
+ - self-documenting
14
+ - project-self-docs
15
+ - generate project docs
16
+ - refresh self docs
17
+ - self document this project
18
+ - hub docs
19
+ applicable_to:
20
+ - any
21
+ ---
22
+
23
+ # project-self-docs
24
+
25
+ ## Role
26
+
27
+ You maintain a project's SELF-DOCUMENTATION set: a small, stable set of committed markdown docs
28
+ that describe what the project is and how it is built, plus a machine-readable index and changelog
29
+ that a central coordination hub can consume. You are a THIN ORCHESTRATOR -- you compose facts that
30
+ `ai-discovery`, `code-specs`, and the deterministic scanner already produce; you do NOT re-analyse
31
+ the codebase from scratch, and you do NOT invent a new documentation format. Everything you write
32
+ is idempotent and re-runnable: running twice on an unchanged repo changes nothing.
33
+
34
+ This capability is the per-project half of the synergy hub (ADR-015, Section 8; and ADR-014). It exists
35
+ to detune the fleet by making reuse possible -- a project that documents itself against a shared
36
+ schema is a project others can find and build on instead of duplicating.
37
+
38
+ ---
39
+
40
+ ## On invocation
41
+
42
+ Before any other output, do both of the following:
43
+
44
+ 1. Print to the user:
45
+ `[skill: project-self-docs] <one-line description of what you are about to do>`
46
+ For example:
47
+ - `[skill: project-self-docs] scanning repo and reporting self-doc status`
48
+ - `[skill: project-self-docs] refreshing STATUS.md and ARCHITECTURE.md from current state`
49
+ - `[skill: project-self-docs] creating the self-doc set for the first time`
50
+
51
+ 2. Append a usage record to `.ai-assistance/local/kpi/usage-<YYYY-WNN>.jsonl`
52
+ (ISO week format: `YYYY-WNN`, e.g. `2026-W24`):
53
+ ```json
54
+ {"component": "skill/project-self-docs", "action": "invoked", "detail": "<same one-liner>", "ts": "<ISO timestamp>", "session_id": "<if known from token-budget session>"}
55
+ ```
56
+ Use `action` values: `invoked`, `completed`, `skipped`. If the file or directory does not
57
+ exist, create it. If writing fails, continue silently.
58
+
59
+ ---
60
+
61
+ ## Before answering -- run the deterministic scan FIRST
62
+
63
+ The deterministic scanner does the zero-LLM half. ALWAYS run it before writing any prose, so you
64
+ spend interactive tokens only on the semantic gaps it cannot fill:
65
+
66
+ ```bash
67
+ python .ai-assistance/skills/project-self-docs/scripts/self_docs_scan.py --json
68
+ ```
69
+
70
+ (From ep-ai-standards itself, the script lives at
71
+ `skills-library/project-self-docs/scripts/self_docs_scan.py`.)
72
+
73
+ The observation tells you deterministically: repo type, real repo name (from the remote), git
74
+ head/branch, top-level structure, key config + CI files, activity clusters (hot paths), which
75
+ existing inputs you can REUSE (`ai-discovery` `repo-context.md`/`conventions.md`, `code-specs`
76
+ under `.ai-assistance/code/`), and which self-docs already exist with their current content hash.
77
+
78
+ **Reuse before you write.** If `repo-context.md`, `conventions.md`, or code-specs exist, compose
79
+ the self-docs from them -- do not re-derive the same facts. If they do NOT exist, propose running
80
+ `ai-discovery` (first-time) or `code-specs` (per-area) first, rather than duplicating their work
81
+ here.
82
+
83
+ ---
84
+
85
+ ## The self-doc set (stable schema -- do not change filenames)
86
+
87
+ Copy the templates from `templates/project-self-docs/` into the project's self-docs directory
88
+ (default `docs/self-docs/`; configurable). The set is intentionally small and fixed:
89
+
90
+ | File | Covers |
91
+ |---|---|
92
+ | `OVERVIEW.md` | What the project is, who it serves, current priority (one screen) |
93
+ | `ARCHITECTURE.md` | Top-level structure, key components, how they fit, entry points |
94
+ | `CONVENTIONS.md` | Coding style, branch naming, commit style, test conventions |
95
+ | `INTEGRATIONS.md` | External services + data + permissions, upstream/downstream repos, dependencies |
96
+ | `STATUS.md` | Active work, migration state, known risks, open questions |
97
+ | `COMPLIANCE.md` | ISO-27001/audit, data classes + PII, third-party vendors, AI content, leak controls |
98
+ | `OPERATIONS.md` | Infrastructure, public exposure + Cloudflare, DevOps audit runbook, usage KPIs/ROI |
99
+
100
+ The set is the ROVO audit/compliance/discovery surface once mirrored into the EP Projects Register
101
+ (`docs/strategy/self-docs-audit-schema.md`). Schema is `1.1`. Each file carries YAML frontmatter
102
+ (`schema_version`, `repo`, `doc`, `last_generated`,
103
+ `source_head`, `review_status`) so the hub can parse it and so a human review gate is explicit.
104
+ Do NOT add, rename, or drop files without bumping the template `schema_version` and the scanner's
105
+ `SELF_DOC_SET` together (they are checked as a pair).
106
+
107
+ These docs are COMMITTED (not gitignored) -- they are the shareable artefact, unlike the
108
+ gitignored `.ai-assistance/local/` context that `ai-discovery` writes.
109
+
110
+ ---
111
+
112
+ ## Workflow
113
+
114
+ 1. **Scan.** Run `self_docs_scan.py --json`. Read the observation.
115
+ 2. **Reuse.** Pull facts from the existing inputs it lists. Only genuinely-missing semantic content
116
+ is yours to write.
117
+ 3. **Fill / refresh.** For each self-doc: if missing, copy the template and fill it; if present,
118
+ update only the sections whose underlying facts changed (structure, hot paths, status). Keep
119
+ `review_status: draft` on anything a human has not confirmed.
120
+ 4. **Batch heavy semantic work to Gemini.** For a large or unfamiliar repo, draft
121
+ ARCHITECTURE/OVERVIEW via the `gemini-assist` skill (no-training tier) rather than on
122
+ interactive Claude tokens -- per the token-frugality rule. Verify Gemini's output against the
123
+ scanner facts before writing.
124
+ 5. **Write the index + changelog (deterministic).** Run:
125
+ ```bash
126
+ python .ai-assistance/skills/project-self-docs/scripts/self_docs_scan.py --write
127
+ ```
128
+ This rewrites `docs/self-docs/self-docs-index.json` (the machine surface the hub reads) and
129
+ APPENDS one line per changed doc to `docs/self-docs/CHANGES.jsonl`. A no-op re-run appends
130
+ nothing -- this is what makes the capability idempotent.
131
+ 6. **Human review before any egress.** Leave publishing to a human-reviewed step (see below).
132
+
133
+ ---
134
+
135
+ ## Publish / egress -- CONFIGURABLE, default local-only (OPEN DECISION)
136
+
137
+ The Confluence publish destination is an OPEN DECISION being made separately (existing EPAI space
138
+ vs a new dedicated hub space vs the private EP-AI-MGMT space). Therefore:
139
+
140
+ - **Default: write to the repo/local filesystem ONLY.** This skill does not push to Confluence.
141
+ - The publish target is a PARAMETER, not a hardcoded value. When the decision is made, the egress
142
+ step becomes a call to the existing seed pipeline (`scripts/seed-epai-project-docs.py` pattern)
143
+ pointed at the chosen space, gated by human review.
144
+ - <!-- TODO(hub-target): wire egress to the chosen Confluence space once the publish-target
145
+ decision lands. Until then, self-docs live in docs/self-docs/ and are consumed from git. -->
146
+
147
+ Never emit `r` (a result) straight to a shared surface: a human review gate sits between the
148
+ generated self-docs and any hub publish. This is a damping control -- keep it.
149
+
150
+ ---
151
+
152
+ ## Actuation
153
+
154
+ - **Actor:** a developer (or `ai-discovery`/`project-cycle` calling this skill) IN THE REPO THAT
155
+ DOCUMENTS ITSELF, never an unattended agent -- and NEVER an ep-ai-standards session reaching into
156
+ another repo to generate that repo's self-docs. ep-ai-standards AUTHORS + DEPLOYS this skill and
157
+ AGGREGATES/publishes results; each repo RUNS it in its own session. (Running it on ep-ai-standards
158
+ ITSELF is fine -- that is why `docs/self-docs/` exists here.)
159
+ - **Trigger / clock:** on demand; recommended at project cycle-end (`project-cycle`) and after a
160
+ structural change. There is no autonomous fleet-wide trigger yet -- that depends on the unbuilt
161
+ ADR-014 upkeep loop; note this rather than inventing an actuator.
162
+ - **Coverage on neglect:** if self-docs are never refreshed, the scanner's `content_hash` +
163
+ `source_head` in the index let the hub (and `project-review`) flag them as stale. The doc is
164
+ never silently trusted; staleness is detectable.
165
+ - **Write authority:** writes ONLY under the self-docs directory (default `docs/self-docs/`), plus
166
+ the KPI usage line. It does not touch source code, `.ai-assistance/local/`, git remotes, or any
167
+ network target.
168
+
169
+ ---
170
+
171
+ ## What you do not do
172
+
173
+ - Do not invent a documentation format -- use the fixed self-doc set and templates.
174
+ - Do not re-analyse the codebase from scratch -- reuse `ai-discovery`, `code-specs`, and the
175
+ scanner; propose running those skills if their inputs are missing.
176
+ - Do not publish to Confluence or any network target -- egress is a separate, human-gated,
177
+ as-yet-undecided step.
178
+ - Do not write outside `docs/self-docs/` (or the configured self-docs dir).
179
+ - Do not run heavy semantic drafting on interactive Claude tokens for large repos -- batch to
180
+ Gemini (no-training tier).
181
+ - Do not mark a doc `review_status: reviewed` -- only a human does that.