@karmaniverous/jeeves-meta-openclaw 0.11.0 → 0.12.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/README.md CHANGED
@@ -6,7 +6,8 @@ OpenClaw plugin for [jeeves-meta](../service/). A thin HTTP client that register
6
6
 
7
7
  - **Twelve tools** — standard: `meta_status`, `meta_config`, `meta_config_apply`, `meta_service`; custom: `meta_list`, `meta_detail`, `meta_trigger`, `meta_preview`, `meta_seed`, `meta_unlock`, `meta_queue` (list/clear/abort), `meta_update`
8
8
  - **MetaServiceClient** — typed HTTP client delegating all operations to the running service
9
- - **TOOLS.md injection** — periodic refresh of entity stats via `ComponentWriter` from `@karmaniverous/jeeves` (73-second prime interval)
9
+ - **TOOLS.md injection** — periodic refresh of entity stats, phase-state summary, failed-phase alerts, and next-phase indicator via `ComponentWriter` from `@karmaniverous/jeeves` (73-second prime interval)
10
+ - **Phase-state awareness** — tools expose per-meta `_phaseState`, `owedPhase`, and phase-state summary from the service's phase-state machine
10
11
  - **Cleanup escalation** — passes `gatewayUrl` into `ComponentWriter` so managed-content cleanup can request a gateway session when needed
11
12
  - **Dependency health** — shows warnings when watcher/gateway are degraded
12
13
  - **Consumer skill** — `SKILL.md` for agent integration
package/dist/index.js CHANGED
@@ -18842,6 +18842,63 @@ async function generateMetaMenu(client) {
18842
18842
  if (dependencies.gateway.status !== 'ok') {
18843
18843
  depLines.push('> ⚠️ **Gateway**: ' + dependencies.gateway.status);
18844
18844
  }
18845
+ // Phase-state summary from /status health
18846
+ const phaseLines = [];
18847
+ const phaseSummary = status.health.phaseStateSummary;
18848
+ if (phaseSummary) {
18849
+ // Aggregate counts across all phases
18850
+ const totals = {};
18851
+ for (const phase of ['architect', 'builder', 'critic']) {
18852
+ const counts = phaseSummary[phase];
18853
+ for (const [state, count] of Object.entries(counts)) {
18854
+ if (count > 0) {
18855
+ totals[state] = (totals[state] ?? 0) + count;
18856
+ }
18857
+ }
18858
+ }
18859
+ const parts = [];
18860
+ for (const state of ['fresh', 'pending', 'running', 'failed']) {
18861
+ if (totals[state]) {
18862
+ parts.push(totals[state].toString() + ' ' + state);
18863
+ }
18864
+ }
18865
+ if (parts.length > 0) {
18866
+ phaseLines.push('Phases: ' + parts.join(', '));
18867
+ }
18868
+ // Failed-phase alert
18869
+ const failedParts = [];
18870
+ for (const item of metas.metas) {
18871
+ const ps = item.phaseState;
18872
+ if (!ps)
18873
+ continue;
18874
+ for (const phase of ['architect', 'builder', 'critic']) {
18875
+ if (ps[phase] === 'failed') {
18876
+ const p = item.path;
18877
+ failedParts.push(p + ' (' + phase + ')');
18878
+ }
18879
+ }
18880
+ }
18881
+ if (failedParts.length > 0) {
18882
+ phaseLines.push('> Failed: ' +
18883
+ failedParts.slice(0, 10).join(', ') +
18884
+ (failedParts.length > 10
18885
+ ? ' (+' + (failedParts.length - 10).toString() + ' more)'
18886
+ : ''));
18887
+ }
18888
+ }
18889
+ // Next-phase indicator from /status health
18890
+ const nextPhase = status.health.nextPhase;
18891
+ if (nextPhase) {
18892
+ phaseLines.push('Next: ' +
18893
+ nextPhase.path +
18894
+ ' → ' +
18895
+ nextPhase.phase +
18896
+ ' (band ' +
18897
+ nextPhase.band.toString() +
18898
+ ', staleness ' +
18899
+ formatAge(nextPhase.staleness) +
18900
+ ')');
18901
+ }
18845
18902
  return [
18846
18903
  'The jeeves-meta synthesis engine manages ' +
18847
18904
  summary.total.toString() +
@@ -18856,6 +18913,7 @@ async function generateMetaMenu(client) {
18856
18913
  '| Never synthesized | ' + summary.neverSynthesized.toString() + ' |',
18857
18914
  '| Stalest | ' + stalestDisplay + ' |',
18858
18915
  '| Last synthesized | ' + lastSynthDisplay + ' |',
18916
+ ...(phaseLines.length > 0 ? ['', '### Phase State', ...phaseLines] : []),
18859
18917
  ...(depLines.length > 0 ? ['', '### Dependencies', ...depLines] : []),
18860
18918
  '',
18861
18919
  'Read the `jeeves-meta` skill for usage guidance, configuration, and troubleshooting.',
@@ -19003,7 +19061,7 @@ function wrap(baseUrl, fn) {
19003
19061
  function buildMetaListTool(client, baseUrl) {
19004
19062
  return {
19005
19063
  name: 'meta_list',
19006
- description: 'List metas with summary stats and per-meta projection. Replaces meta_status + meta_entities.',
19064
+ description: 'List metas with summary stats and per-meta projection. Response includes _phaseState and owedPhase per meta.',
19007
19065
  parameters: {
19008
19066
  type: 'object',
19009
19067
  properties: {
@@ -19046,7 +19104,7 @@ function buildMetaListTool(client, baseUrl) {
19046
19104
  function buildMetaDetailTool(client, baseUrl) {
19047
19105
  return {
19048
19106
  name: 'meta_detail',
19049
- description: 'Full detail for a single meta, with optional archive history.',
19107
+ description: 'Full detail for a single meta, with optional archive history. Response includes _phaseState and owedPhase.',
19050
19108
  parameters: {
19051
19109
  type: 'object',
19052
19110
  properties: {
@@ -19075,7 +19133,7 @@ function buildMetaDetailTool(client, baseUrl) {
19075
19133
  function buildMetaPreviewTool(client, baseUrl) {
19076
19134
  return {
19077
19135
  name: 'meta_preview',
19078
- description: 'Dry-run: show what inputs would be gathered for the next synthesis cycle without running LLM.',
19136
+ description: 'Dry-run preview of next synthesis. Returns owedPhase, priorityBand, phaseState, stalenessInputs, and architectInvalidators.',
19079
19137
  parameters: {
19080
19138
  type: 'object',
19081
19139
  properties: {
@@ -19091,7 +19149,7 @@ function buildMetaPreviewTool(client, baseUrl) {
19091
19149
  function buildMetaTriggerTool(client, baseUrl) {
19092
19150
  return {
19093
19151
  name: 'meta_trigger',
19094
- description: 'Manually trigger synthesis for a specific meta or the next-stalest candidate.',
19152
+ description: 'Trigger synthesis. Path-targeted creates an override queue entry; returns owedPhase. Fully-fresh metas return status:skipped.',
19095
19153
  parameters: {
19096
19154
  type: 'object',
19097
19155
  properties: {
@@ -19167,7 +19225,7 @@ function buildMetaUnlockTool(client, baseUrl) {
19167
19225
  function buildMetaQueueTool(client, baseUrl) {
19168
19226
  return {
19169
19227
  name: 'meta_queue',
19170
- description: 'Queue management: list pending items, clear the queue, or abort current synthesis.',
19228
+ description: 'Queue management. list: 3-layer model (current with phase, overrides, automatic, pending). clear: removes overrides only. abort: returns {status,path,phase} or {status:idle}.',
19171
19229
  parameters: {
19172
19230
  type: 'object',
19173
19231
  properties: {
@@ -7,6 +7,12 @@ jeeves-meta is the Jeeves platform's knowledge synthesis engine. It discovers
7
7
  gathers context from co-located source files, and uses a three-step LLM process
8
8
  (architect, builder, critic) to produce structured synthesis artifacts.
9
9
 
10
+ Each meta entity carries a **phase-state machine** (`_phaseState`) tracking
11
+ the state of each phase independently: `fresh`, `stale`, `pending`, `running`,
12
+ or `failed`. The scheduler picks **one phase per tick** across the entire
13
+ corpus (critic > builder > architect priority), enabling surgical retries of
14
+ failed phases without re-running the full pipeline.
15
+
10
16
  **Requires:** jeeves-watcher ≥ 0.10.0 (provides `POST /walk` and auto
11
17
  rules-reindex on registration).
12
18
 
@@ -21,6 +27,8 @@ registration health.
21
27
  List all `.meta/` directories with summary stats and per-meta projection.
22
28
  Supports filtering by path prefix, error status, staleness, lock state, and
23
29
  disabled status. Use for engine health checks and finding stale knowledge.
30
+ Each meta entry includes `phaseState` (`{ architect, builder, critic }`)
31
+ showing the per-phase state.
24
32
 
25
33
  **Parameters:**
26
34
  - `pathPrefix` (optional): Filter by path prefix (e.g. "github/")
@@ -28,7 +36,8 @@ disabled status. Use for engine health checks and finding stale knowledge.
28
36
  - `fields` (optional): Property projection array
29
37
 
30
38
  ### meta_detail
31
- Full detail for a single meta, with optional archive history.
39
+ Full detail for a single meta, with optional archive history. Includes
40
+ `_phaseState` showing the per-phase state machine status.
32
41
 
33
42
  **Parameters:**
34
43
  - `path` (required): `.meta/` or owner directory path
@@ -36,20 +45,22 @@ Full detail for a single meta, with optional archive history.
36
45
  - `includeArchive` (optional): false, true, or number (N most recent)
37
46
 
38
47
  ### meta_preview
39
- Dry-run for the next synthesis cycle. Shows scope files, delta files,
40
- architect trigger reasons, steer status, and structure changes without
41
- running any LLM calls. Use before `meta_trigger` to understand what
42
- will happen.
48
+ Dry-run for the next synthesis candidate. Shows scope files, delta files,
49
+ architect trigger reasons, steer status, structure changes, and the
50
+ phase that would execute next — without running any LLM calls. Includes
51
+ `phaseState` and `owedPhase` (the phase that would run). Use before
52
+ `meta_trigger` to understand what will happen.
43
53
 
44
54
  **Parameters:**
45
55
  - `path` (optional): Specific `.meta/` or owner directory path. If omitted,
46
56
  previews the stalest candidate.
47
57
 
48
58
  ### meta_trigger
49
- Enqueue a synthesis cycle for a specific meta or the next-stalest candidate.
59
+ Enqueue a synthesis for a specific meta or the next-stalest candidate.
50
60
  The synthesis runs asynchronously in the service queue; the tool returns
51
- immediately with the queue position. The full cycle (architect builder
52
- critic) runs in the background.
61
+ immediately with the queue position. Only one phase runs per tick (the
62
+ owed phase). Includes `owedPhase` in the response showing which phase
63
+ will execute.
53
64
 
54
65
  **Parameters:**
55
66
  - `path` (optional): Specific `.meta/` or owner directory path. If omitted,
@@ -99,14 +110,17 @@ modify `_crossRefs` — without editing `meta.json` directly on the filesystem.
99
110
 
100
111
  ### meta_queue
101
112
  Queue management: list pending items, clear the queue, or abort current
102
- synthesis. The synthesis queue is single-threaded; use this tool to inspect
103
- what's running, clear queued work, or abort a stuck synthesis.
113
+ synthesis. The queue has three layers: `current` (the running phase),
114
+ `overrides` (explicitly triggered entries), and `automatic` (scheduler-
115
+ computed candidates). The `pending` and `state` fields provide legacy
116
+ compatibility.
104
117
 
105
118
  **Parameters:**
106
119
  - `action` (required): One of `list`, `clear`, `abort`.
107
- - `list`: Show current queue state (current synthesis, pending items).
108
- - `clear`: Remove all pending queue items.
109
- - `abort`: Stop the currently running synthesis and release its lock.
120
+ - `list`: Show current queue state (current with phase, overrides,
121
+ automatic candidates, pending items).
122
+ - `clear`: Remove all override queue entries.
123
+ - `abort`: Stop the currently running phase and release its lock.
110
124
 
111
125
  ## When to Use
112
126
 
@@ -158,6 +172,17 @@ what's running, clear queued work, or abort a stuck synthesis.
158
172
  (e.g. phased analysis, incremental refinement). On builder timeout, the
159
173
  engine attempts to recover partial output — if `_state` advanced, it saves
160
174
  the new state without overwriting existing content.
175
+ - **Phase-state machine (`_phaseState`):** Each meta tracks its three phases
176
+ independently: `{ architect: <state>, builder: <state>, critic: <state> }`.
177
+ States are `fresh`, `stale`, `pending`, `running`, or `failed`. The
178
+ scheduler picks the single highest-priority owed phase across all metas
179
+ each tick (critic > builder > architect, with staleness tiebreaking).
180
+ Failed phases are automatically retried on the next tick (promoted from
181
+ `failed` → `pending`). Only the failed phase reruns — upstream/downstream
182
+ phases are untouched (surgical retries). A full cycle completes only when
183
+ all three phases are `fresh`, at which point the archive snapshot is taken
184
+ and `_synthesisCount` increments. Legacy metas without `_phaseState` have
185
+ their state derived automatically from existing fields on first load.
161
186
 
162
187
  ## Configuration
163
188
 
@@ -516,7 +541,7 @@ The service exposes these endpoints (default port 1938):
516
541
 
517
542
  | Method | Path | Description |
518
543
  |--------|------|-------------|
519
- | GET | `/status` | Service health, queue state, dependency checks |
544
+ | GET | `/status` | Service health, queue state, dependency checks, phase-state summary |
520
545
  | GET | `/metas` | List metas with filtering and field projection |
521
546
  | GET | `/metas/:path` | Single meta detail with optional archive |
522
547
  | PATCH | `/metas/:path` | Update user-settable reserved properties |
@@ -527,8 +552,8 @@ The service exposes these endpoints (default port 1938):
527
552
  | POST | `/unlock` | Remove `.lock` file from a meta entity |
528
553
  | GET | `/config` | Query sanitized config with optional JSONPath (`?path=$.schedule`) |
529
554
  | POST | `/config/apply` | Apply a config patch (merge or replace) |
530
- | GET | `/queue` | Current queue state (current, pending, stats) |
531
- | POST | `/queue/clear` | Remove all pending queue items |
555
+ | GET | `/queue` | Queue state: current (with phase), overrides, automatic, pending |
556
+ | POST | `/queue/clear` | Remove all override queue entries |
532
557
 
533
558
  All endpoints return JSON. The OpenClaw plugin tools are thin wrappers
534
559
  around these endpoints.
@@ -553,15 +578,22 @@ The `start` command uses `--config`/`-c` instead (port is read from the config f
553
578
  Recommended periodic checks:
554
579
  - **Errors:** `meta_list` with `filter: { hasError: true }` — investigate
555
580
  and retry with `meta_trigger`
581
+ - **Failed phases:** The TOOLS.md injection shows a "Failed:" alert listing
582
+ metas with failed phases. Failed phases auto-retry on the next scheduler
583
+ tick. Use `meta_detail` to inspect the `_phaseState` and `_error` fields.
556
584
  - **Stuck locks:** `meta_list` with `filter: { locked: true }` — locks
557
585
  older than 30 minutes indicate a crashed synthesis; use `jeeves-meta unlock`
558
586
  - **Stale knowledge:** `meta_list` with `filter: { staleHours: 48 }` — check
559
587
  if the scheduler is running and the watcher is up
588
+ - **Phase health:** `/status` includes `phaseStateSummary` with aggregate
589
+ counts per phase (`fresh`, `stale`, `pending`, `running`, `failed`) and
590
+ `nextPhase` showing the next candidate.
560
591
  - **Service health:** `/status` endpoint (via `meta_list` summary or direct
561
592
  HTTP) includes dependency status for watcher and gateway
562
593
 
563
594
  The TOOLS.md injection surfaces the most critical stats (entity count, errors,
564
- stalest entity) in the agent's system prompt automatically.
595
+ stalest entity, phase summary, failed-phase alerts, next-phase indicator) in
596
+ the agent's system prompt automatically.
565
597
 
566
598
  ## Troubleshooting
567
599
 
@@ -622,18 +654,22 @@ progressive work is not lost on timeout — only the content update is skipped.
622
654
  3. Check if the LLM provider is slow or rate-limited
623
655
  4. Check scope size: large scopes with many files take longer
624
656
 
625
- ### LLM errors in synthesis steps
657
+ ### LLM errors in synthesis phases
626
658
 
627
- **Symptom:** `meta_detail` shows `_error` field with step/code/message
659
+ **Symptom:** `meta_detail` shows `_error` field with step/code/message, and
660
+ `_phaseState` shows `failed` for one or more phases.
628
661
  **Cause:** Subprocess failed (API error, malformed output, rate limit)
629
662
  **Fix:**
630
663
  1. Check error details: `meta_detail <path>` — `_error.step` tells you
631
- which step failed
632
- 2. Architect failure with existing `_builder`: engine reuses cached brief
664
+ which phase failed; `_phaseState` shows the exact state of each phase
665
+ 2. Failed phases are **automatically retried** on the next scheduler tick
666
+ (promoted from `failed` → `pending`). Only the failed phase reruns —
667
+ other phases are untouched (surgical retry).
668
+ 3. Architect failure with existing `_builder`: engine reuses cached brief
633
669
  (self-healing)
634
- 3. Architect failure without `_builder` (first run): retry with `meta_trigger`
635
- 4. Builder failure: meta stays stale, retried next cycle automatically
636
- 5. Critic failure: content saved without feedback, not critical
670
+ 4. Architect failure without `_builder` (first run): retry with `meta_trigger`
671
+ 5. Builder failure: meta stays stale, retried next tick automatically
672
+ 6. Critic failure: content saved without feedback, not critical
637
673
 
638
674
  ### Discovery returns wrong/stale results
639
675
 
@@ -649,8 +685,9 @@ not yet indexed new files
649
685
 
650
686
  ## Gotchas
651
687
 
652
- - `meta_trigger` runs a full LLM cycle (3 subprocess calls). It can take
653
- several minutes.
688
+ - `meta_trigger` enqueues a single phase (not all three). A full cycle
689
+ requires three separate ticks (one per phase). Use `meta_detail` to
690
+ check `_phaseState` for progress.
654
691
  - A locked meta (another synthesis in progress) will be skipped silently.
655
692
  - First-run quality is lower — the feedback loop needs 2-3 cycles to calibrate.
656
693
  - Changing `metaProperty` requires both a meta service restart AND a watcher reindex.
@@ -661,9 +698,12 @@ not yet indexed new files
661
698
  - All prompts are compiled as Handlebars templates. Avoid using `{{` in prompt
662
699
  overrides unless you intend template variable resolution. Escape with `\{{`
663
700
  for literal double-braces.
664
- - The synthesis queue is single-threaded: one synthesis at a time. HTTP-triggered
665
- syntheses get priority over scheduler-triggered ones.
701
+ - The synthesis queue is single-threaded with three layers: `current` (the
702
+ running phase), `overrides` (explicitly triggered entries, highest priority),
703
+ and `automatic` (scheduler-computed candidates). Override entries are
704
+ processed before automatic candidates.
666
705
  - The scheduler uses adaptive backoff: if no stale candidates are found, it
667
- doubles the skip interval (max 4×). Backoff resets after a successful synthesis.
706
+ doubles the skip interval (max 4×). Backoff resets after any successful
707
+ phase execution (not just full-cycle completion).
668
708
  - All CLI commands except `start` require the service to be running (they call
669
709
  the HTTP API).
@@ -2,7 +2,7 @@
2
2
  "id": "jeeves-meta-openclaw",
3
3
  "name": "Jeeves Meta",
4
4
  "description": "Knowledge synthesis tools — trigger synthesis, view status, manage entities.",
5
- "version": "0.11.0",
5
+ "version": "0.12.0",
6
6
  "skills": [
7
7
  "dist/skills/jeeves-meta"
8
8
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@karmaniverous/jeeves-meta-openclaw",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "author": "Jason Williscroft",
5
5
  "description": "OpenClaw plugin for jeeves-meta — synthesis tools and virtual rule registration",
6
6
  "license": "BSD-3-Clause",