@karmaniverous/jeeves-meta 0.15.3 → 0.15.5

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 (89) hide show
  1. package/dist/archive/index.d.ts +10 -0
  2. package/dist/archive/listArchive.d.ts +12 -0
  3. package/dist/archive/prune.d.ts +14 -0
  4. package/dist/archive/readArchive.d.ts +30 -0
  5. package/dist/archive/readLatest.d.ts +13 -0
  6. package/dist/archive/snapshot.d.ts +17 -0
  7. package/dist/bootstrap.d.ts +15 -0
  8. package/dist/cache.d.ts +22 -0
  9. package/dist/cli/jeeves-meta/architect.md +17 -0
  10. package/dist/cli/jeeves-meta/index.js +811 -734
  11. package/dist/cli.d.ts +10 -0
  12. package/dist/configHotReload.d.ts +30 -0
  13. package/dist/configLoader.d.ts +37 -0
  14. package/dist/constants.d.ts +13 -0
  15. package/dist/customCliCommands.d.ts +13 -0
  16. package/dist/descriptor.d.ts +19 -0
  17. package/dist/discovery/buildMinimalNode.d.ts +22 -0
  18. package/dist/discovery/computeSummary.d.ts +17 -0
  19. package/dist/discovery/discoverMetas.d.ts +19 -0
  20. package/dist/discovery/index.d.ts +11 -0
  21. package/dist/discovery/listMetas.d.ts +63 -0
  22. package/dist/discovery/ownershipTree.d.ts +25 -0
  23. package/dist/discovery/scope.d.ts +47 -0
  24. package/dist/discovery/types.d.ts +25 -0
  25. package/dist/ema.d.ts +14 -0
  26. package/dist/errors.d.ts +15 -0
  27. package/dist/escapeGlob.d.ts +23 -0
  28. package/dist/executor/GatewayExecutor.d.ts +48 -0
  29. package/dist/executor/SpawnAbortedError.d.ts +9 -0
  30. package/dist/executor/SpawnTimeoutError.d.ts +13 -0
  31. package/dist/executor/index.d.ts +8 -0
  32. package/dist/index.d.ts +34 -1660
  33. package/dist/index.js +1434 -1767
  34. package/dist/interfaces/MetaContext.d.ts +36 -0
  35. package/dist/interfaces/MetaExecutor.d.ts +46 -0
  36. package/dist/interfaces/WatcherClient.d.ts +75 -0
  37. package/dist/interfaces/index.d.ts +8 -0
  38. package/dist/lock.d.ts +70 -0
  39. package/dist/logger/index.d.ts +27 -0
  40. package/dist/mtimeFilter.d.ts +26 -0
  41. package/dist/normalizePath.d.ts +6 -0
  42. package/dist/orchestrator/buildTask.d.ts +38 -0
  43. package/dist/orchestrator/contextPackage.d.ts +30 -0
  44. package/dist/orchestrator/index.d.ts +10 -0
  45. package/dist/orchestrator/orchestratePhase.d.ts +38 -0
  46. package/dist/orchestrator/parseOutput.d.ts +41 -0
  47. package/dist/orchestrator/runPhase.d.ts +40 -0
  48. package/dist/phaseState/derivePhaseState.d.ts +41 -0
  49. package/dist/phaseState/index.d.ts +9 -0
  50. package/dist/phaseState/invalidate.d.ts +41 -0
  51. package/dist/phaseState/phaseScheduler.d.ts +57 -0
  52. package/dist/phaseState/phaseTransitions.d.ts +83 -0
  53. package/dist/progress/index.d.ts +38 -0
  54. package/dist/prompts/architect.md +17 -0
  55. package/dist/prompts/index.d.ts +15 -0
  56. package/dist/queue/index.d.ts +131 -0
  57. package/dist/readMetaJson.d.ts +17 -0
  58. package/dist/routes/__testUtils.d.ts +37 -0
  59. package/dist/routes/config.d.ts +11 -0
  60. package/dist/routes/configApply.d.ts +13 -0
  61. package/dist/routes/index.d.ts +50 -0
  62. package/dist/routes/metas.d.ts +9 -0
  63. package/dist/routes/metasUpdate.d.ts +11 -0
  64. package/dist/routes/preview.d.ts +8 -0
  65. package/dist/routes/queue.d.ts +13 -0
  66. package/dist/routes/seed.d.ts +8 -0
  67. package/dist/routes/status.d.ts +13 -0
  68. package/dist/routes/synthesize.d.ts +12 -0
  69. package/dist/routes/unlock.d.ts +8 -0
  70. package/dist/rules/healthCheck.d.ts +36 -0
  71. package/dist/rules/index.d.ts +39 -0
  72. package/dist/rules/verify.d.ts +22 -0
  73. package/dist/scheduler/index.d.ts +66 -0
  74. package/dist/scheduling/index.d.ts +7 -0
  75. package/dist/scheduling/staleness.d.ts +68 -0
  76. package/dist/scheduling/weightedFormula.d.ts +38 -0
  77. package/dist/schema/config.d.ts +54 -0
  78. package/dist/schema/error.d.ts +6 -0
  79. package/dist/schema/index.d.ts +8 -0
  80. package/dist/schema/meta.d.ts +71 -0
  81. package/dist/seed/autoSeed.d.ts +30 -0
  82. package/dist/seed/createMeta.d.ts +38 -0
  83. package/dist/seed/index.d.ts +7 -0
  84. package/dist/server.d.ts +24 -0
  85. package/dist/shutdown/index.d.ts +33 -0
  86. package/dist/structureHash.d.ts +15 -0
  87. package/dist/watcher-client/HttpWatcherClient.d.ts +38 -0
  88. package/dist/watcher-client/index.d.ts +6 -0
  89. package/package.json +17 -27
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Pure phase-state transition functions.
3
+ *
4
+ * Implements every row of the §8 "Transitions and invalidation cascade" table.
5
+ * No I/O — pure functions over PhaseState and documented inputs.
6
+ *
7
+ * @module phaseState/phaseTransitions
8
+ */
9
+ import type { PhaseState } from '../schema/meta.js';
10
+ /**
11
+ * Create a fresh (fully-complete) phase state.
12
+ */
13
+ export declare function freshPhaseState(): PhaseState;
14
+ /**
15
+ * Create a phase state for a never-synthesized meta (all pending from architect).
16
+ */
17
+ export declare function initialPhaseState(): PhaseState;
18
+ /**
19
+ * Enforce the per-meta invariant: at most one phase is pending or running,
20
+ * and it is the first non-fresh phase in pipeline order.
21
+ *
22
+ * Stale phases that become the first non-fresh phase are promoted to pending.
23
+ */
24
+ export declare function enforceInvariant(state: PhaseState): PhaseState;
25
+ /**
26
+ * Architect invalidated: architect → pending; builder, critic → stale.
27
+ * Triggers: _structureHash change, _steer change, _architect change,
28
+ * _crossRefs declaration change, _synthesisCount \>= architectEvery.
29
+ */
30
+ export declare function invalidateArchitect(state: PhaseState): PhaseState;
31
+ /**
32
+ * Builder invalidated (scope mtime or cross-ref _content change):
33
+ * builder → pending; critic → stale.
34
+ * Only applies when architect is fresh; otherwise, builder stays stale.
35
+ */
36
+ export declare function invalidateBuilder(state: PhaseState): PhaseState;
37
+ /**
38
+ * Architect completes successfully.
39
+ * architect → fresh; builder → pending; critic → stale.
40
+ */
41
+ export declare function architectSuccess(state: PhaseState): PhaseState;
42
+ /**
43
+ * Builder completes successfully.
44
+ * builder → fresh; critic → pending.
45
+ */
46
+ export declare function builderSuccess(state: PhaseState): PhaseState;
47
+ /**
48
+ * Critic completes successfully.
49
+ * critic → fresh. Meta becomes fully fresh.
50
+ */
51
+ export declare function criticSuccess(state: PhaseState): PhaseState;
52
+ /**
53
+ * A phase fails (error, timeout, or abort).
54
+ * Target phase → failed; upstream and downstream unchanged.
55
+ */
56
+ export declare function phaseFailed(state: PhaseState, phase: 'architect' | 'builder' | 'critic'): PhaseState;
57
+ /**
58
+ * Retry a failed phase: failed → pending.
59
+ * Only valid when the phase is currently failed.
60
+ */
61
+ export declare function retryPhase(state: PhaseState, phase: 'architect' | 'builder' | 'critic'): PhaseState;
62
+ /**
63
+ * Retry all failed phases: each failed phase → pending.
64
+ * Used by scheduler ticks and queue reads to auto-promote failed phases.
65
+ */
66
+ export declare function retryAllFailed(state: PhaseState): PhaseState;
67
+ /**
68
+ * Mark a phase as running (scheduler picks it).
69
+ */
70
+ export declare function phaseRunning(state: PhaseState, phase: 'architect' | 'builder' | 'critic'): PhaseState;
71
+ /**
72
+ * Get the owed phase: first non-fresh phase in pipeline order, or null.
73
+ */
74
+ export declare function getOwedPhase(state: PhaseState): 'architect' | 'builder' | 'critic' | null;
75
+ /**
76
+ * Check if a meta is fully fresh (all phases fresh).
77
+ */
78
+ export declare function isFullyFresh(state: PhaseState): boolean;
79
+ /**
80
+ * Get the scheduler priority band for a meta's owed phase.
81
+ * 1 = critic (highest), 2 = builder, 3 = architect, null = fully fresh.
82
+ */
83
+ export declare function getPriorityBand(state: PhaseState): 1 | 2 | 3 | null;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Progress reporting via OpenClaw gateway `/tools/invoke` → `message` tool.
3
+ *
4
+ * @module progress
5
+ */
6
+ import type { Logger } from 'pino';
7
+ export type ProgressPhase = 'architect' | 'builder' | 'critic';
8
+ export type ProgressEvent = {
9
+ type: 'synthesis_start' | 'phase_start' | 'phase_complete' | 'synthesis_complete' | 'error';
10
+ /** Owner path (not .meta path) of the entity being synthesized. */
11
+ path: string;
12
+ phase?: ProgressPhase;
13
+ tokens?: number;
14
+ durationMs?: number;
15
+ error?: string;
16
+ };
17
+ export type ProgressReporterConfig = {
18
+ gatewayUrl: string;
19
+ gatewayApiKey?: string;
20
+ /**
21
+ * Messaging channel name (e.g. 'slack'). When set alongside reportTarget,
22
+ * included in the gateway message payload as `channel`.
23
+ * Legacy: if reportTarget is unset, reportChannel is used as the target
24
+ * (single-channel mode, backward compatible).
25
+ */
26
+ reportChannel?: string;
27
+ /** Channel/user ID to send messages to. Takes priority over reportChannel as target. */
28
+ reportTarget?: string;
29
+ /** Optional base URL for the service, used to construct entity links. */
30
+ serverBaseUrl?: string;
31
+ };
32
+ export declare function formatProgressEvent(event: ProgressEvent, serverBaseUrl?: string): string;
33
+ export declare class ProgressReporter {
34
+ private readonly config;
35
+ private readonly logger;
36
+ constructor(config: ProgressReporterConfig, logger: Logger);
37
+ report(event: ProgressEvent): Promise<void>;
38
+ }
@@ -91,6 +91,23 @@ Define what "verify before asserting" means for this data shape:
91
91
  Always require: exact entity titles/names (not paraphrases), evidence citations,
92
92
  partial implementation notes, config default verification from schema files.
93
93
 
94
+ {{#if (gt scope.fileCount 500)}}
95
+ ## LARGE SCOPE — SAMPLING MODE
96
+
97
+ This entity has {{scope.fileCount}} files. Do NOT attempt to read or
98
+ explore the full scope. Instead:
99
+
100
+ 1. Read _state and _content from previous cycles to understand existing
101
+ data shape knowledge
102
+ 2. Sample at most 5–10 representative files to verify the data shape
103
+ hasn't fundamentally changed
104
+ 3. Focus your brief updates on what the _feedback says needs improving
105
+ 4. Preserve the existing progressive processing strategy unless the
106
+ data shape has materially changed
107
+
108
+ Your job on re-runs is refinement, not rediscovery.
109
+ {{/if}}
110
+
94
111
  ### 7. Progressive Processing (_state)
95
112
 
96
113
  When the scope is large (hundreds of files or more), instruct the Builder to
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Built-in default prompts for the synthesis pipeline.
3
+ *
4
+ * Prompts ship as .md files bundled into dist/prompts/ via rollup-plugin-copy.
5
+ * Loaded at runtime relative to the compiled module location.
6
+ *
7
+ * Users can override via `defaultArchitect` / `defaultCritic` in the service
8
+ * config. Most installations should use the built-in defaults.
9
+ *
10
+ * @module prompts
11
+ */
12
+ /** Built-in default architect prompt. */
13
+ export declare const DEFAULT_ARCHITECT_PROMPT: string;
14
+ /** Built-in default critic prompt. */
15
+ export declare const DEFAULT_CRITIC_PROMPT: string;
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Hybrid 3-layer synthesis queue.
3
+ *
4
+ * Layer 1: Current — the single item currently executing (at most one).
5
+ * Layer 2: Overrides — items manually enqueued via POST /synthesize with path.
6
+ * FIFO among overrides, ahead of automatic candidates.
7
+ * Layer 3: Automatic — computed on read, not persisted. All metas with a
8
+ * pending phase, ranked by scheduler priority.
9
+ *
10
+ * Legacy: `pending` array is the union of overrides + automatic.
11
+ *
12
+ * @module queue
13
+ */
14
+ import type { Logger } from 'pino';
15
+ import type { PhaseName } from '../schema/meta.js';
16
+ /** A queued synthesis work item. */
17
+ export interface QueueItem {
18
+ path: string;
19
+ priority: boolean;
20
+ enqueuedAt: string;
21
+ }
22
+ /** An override entry in the explicit queue layer. */
23
+ export interface OverrideEntry {
24
+ path: string;
25
+ enqueuedAt: string;
26
+ }
27
+ /** The currently executing item with phase info. */
28
+ export interface CurrentItem {
29
+ path: string;
30
+ phase: PhaseName;
31
+ startedAt: string;
32
+ }
33
+ /** Result returned by {@link SynthesisQueue.enqueue}. */
34
+ export interface EnqueueResult {
35
+ position: number;
36
+ alreadyQueued: boolean;
37
+ }
38
+ /** Snapshot of queue state for the /status endpoint. */
39
+ export interface QueueState {
40
+ depth: number;
41
+ items: Array<{
42
+ path: string;
43
+ priority: boolean;
44
+ enqueuedAt: string;
45
+ }>;
46
+ }
47
+ /**
48
+ * Hybrid 3-layer synthesis queue.
49
+ *
50
+ * Only one synthesis runs at a time. Override items (explicit triggers)
51
+ * take priority over automatic candidates.
52
+ */
53
+ export declare class SynthesisQueue {
54
+ /** Legacy queue (used by processQueue for backward compat). */
55
+ private queue;
56
+ private currentItem;
57
+ private processing;
58
+ private logger;
59
+ private onEnqueueCallback;
60
+ /** Explicit override entries (3-layer model). */
61
+ private overrideEntries;
62
+ /** Currently executing item with phase info (3-layer model). */
63
+ private currentPhaseItem;
64
+ constructor(logger: Logger);
65
+ /** Set a callback to invoke when a new (non-duplicate) item is enqueued. */
66
+ onEnqueue(callback: () => void): void;
67
+ /**
68
+ * Add an explicit override entry (from POST /synthesize with path).
69
+ * Deduped by path. Returns position and whether already queued.
70
+ */
71
+ enqueueOverride(path: string): EnqueueResult;
72
+ /** Dequeue the next override entry, or undefined if empty. */
73
+ dequeueOverride(): OverrideEntry | undefined;
74
+ /** Get all override entries (shallow copy). */
75
+ get overrides(): OverrideEntry[];
76
+ /** Clear all override entries. Returns count removed. */
77
+ clearOverrides(): number;
78
+ /** Check if a path is in the override layer. */
79
+ hasOverride(path: string): boolean;
80
+ /** Set the currently executing phase item. */
81
+ setCurrentPhase(path: string, phase: PhaseName): void;
82
+ /** Clear the current phase item. */
83
+ clearCurrentPhase(): void;
84
+ /** The currently executing phase item, or null. */
85
+ get currentPhase(): CurrentItem | null;
86
+ /**
87
+ * Add a path to the synthesis queue.
88
+ *
89
+ * @param path - Meta path to synthesize.
90
+ * @param priority - If true, insert at front of queue.
91
+ * @returns Position and whether the path was already queued.
92
+ */
93
+ enqueue(path: string, priority?: boolean): EnqueueResult;
94
+ /** Remove and return the next item from the queue. */
95
+ dequeue(): QueueItem | undefined;
96
+ /** Mark the currently-running synthesis as complete. */
97
+ complete(): void;
98
+ /** Number of items waiting in the queue (excludes current). */
99
+ get depth(): number;
100
+ /** The item currently being synthesized, or null. */
101
+ get current(): QueueItem | null;
102
+ /** A shallow copy of the queued items. */
103
+ get items(): QueueItem[];
104
+ /** A shallow copy of the pending items (alias for items). */
105
+ get pending(): QueueItem[];
106
+ /**
107
+ * Remove all pending items from the queue.
108
+ * Does not affect the currently-running item.
109
+ *
110
+ * @returns The number of items removed.
111
+ */
112
+ clear(): number;
113
+ /** Check whether a path is in the queue or currently being synthesized. */
114
+ has(path: string): boolean;
115
+ /** Get the 0-indexed position of a path in the queue. */
116
+ getPosition(path: string): number | null;
117
+ /** Dequeue the next item: overrides first, then legacy queue. */
118
+ private nextItem;
119
+ /** Return a snapshot of queue state for the /status endpoint. */
120
+ getState(): QueueState;
121
+ /**
122
+ * Process queued items one at a time until all queues are empty.
123
+ *
124
+ * Override entries are processed first (FIFO), then legacy queue items.
125
+ * Re-entry is prevented: if already processing, the call returns
126
+ * immediately. Errors are logged and do not block subsequent items.
127
+ *
128
+ * @param synthesizeFn - Async function that performs synthesis for a path.
129
+ */
130
+ processQueue(synthesizeFn: (path: string) => Promise<void>): Promise<void>;
131
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Read and parse a meta.json file from a `.meta/` directory.
3
+ *
4
+ * Shared utility to eliminate repeated `JSON.parse(readFileSync(...))` across
5
+ * discovery, orchestration, and route handlers.
6
+ *
7
+ * @module readMetaJson
8
+ */
9
+ import type { MetaJson } from './schema/index.js';
10
+ /**
11
+ * Read and parse a meta.json file from a `.meta/` directory path (async).
12
+ *
13
+ * @param metaPath - Path to the `.meta/` directory.
14
+ * @returns Parsed meta.json content.
15
+ * @throws If the file doesn't exist or contains invalid JSON.
16
+ */
17
+ export declare function readMetaJson(metaPath: string): Promise<MetaJson>;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Shared test utilities for route test files.
3
+ *
4
+ * Provides factories for RouteDeps, logger mocks, watcher mocks, and
5
+ * filesystem-based meta fixtures. Eliminates duplication across 9+ test files.
6
+ *
7
+ * @module routes/__testUtils
8
+ */
9
+ import type { Logger } from 'pino';
10
+ import type { WatcherClient } from '../interfaces/index.js';
11
+ import type { RouteDeps } from './index.js';
12
+ /** Create a mock pino logger with all standard methods. */
13
+ export declare function makeTestLogger(): Logger;
14
+ /** Overrides for makeTestDeps — config can be partially specified. */
15
+ type TestDepsOverrides = Omit<Partial<RouteDeps>, 'config'> & {
16
+ config?: Partial<RouteDeps['config']>;
17
+ };
18
+ /** Create a RouteDeps object with sensible test defaults. */
19
+ export declare function makeTestDeps(overrides?: TestDepsOverrides): RouteDeps;
20
+ /**
21
+ * Create a mock WatcherClient that resolves walk() with given paths.
22
+ *
23
+ * @param metaJsonPaths - Paths to return from walk().
24
+ * @param scan - Optional custom scan mock (defaults to empty results).
25
+ */
26
+ export declare function makeTestWatcher(metaJsonPaths?: string[], scan?: import("vitest").Mock<import("@vitest/spy").Procedure>): WatcherClient;
27
+ /** Create a mock WatcherClient that rejects walk() calls. */
28
+ export declare function makeFailingTestWatcher(): WatcherClient;
29
+ /**
30
+ * Create a .meta/meta.json on disk and return the meta.json path.
31
+ *
32
+ * @param ownerDir - The owner directory to create .meta/ in.
33
+ * @param meta - Additional meta fields (merged with default _id).
34
+ * @returns The path to the created meta.json file.
35
+ */
36
+ export declare function createTestMeta(ownerDir: string, meta?: Record<string, unknown>): string;
37
+ export {};
@@ -0,0 +1,11 @@
1
+ /**
2
+ * GET /config — query service configuration with optional JSONPath.
3
+ *
4
+ * Replaces the old GET /config/validate endpoint with the core SDK's
5
+ * `createConfigQueryHandler()` for JSONPath support.
6
+ *
7
+ * @module routes/config
8
+ */
9
+ import type { FastifyInstance } from 'fastify';
10
+ import type { RouteDeps } from './index.js';
11
+ export declare function registerConfigRoute(app: FastifyInstance, deps: RouteDeps): void;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * POST /config/apply — apply a config patch using the runtime config path.
3
+ *
4
+ * The core SDK's `createConfigApplyHandler` derives the config path from
5
+ * `getComponentConfigDir()` which uses the npm global config root. This
6
+ * local implementation uses the actual runtime config path instead, so
7
+ * temp files are written alongside the active config file.
8
+ *
9
+ * @module routes/configApply
10
+ */
11
+ import type { FastifyInstance } from 'fastify';
12
+ /** Register the POST /config/apply route. */
13
+ export declare function registerConfigApplyRoute(app: FastifyInstance, configPath?: string): void;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Route registration for jeeves-meta service.
3
+ *
4
+ * @module routes
5
+ */
6
+ import type { FastifyInstance } from 'fastify';
7
+ import type { Logger } from 'pino';
8
+ import type { MetaCache } from '../cache.js';
9
+ import type { GatewayExecutor } from '../executor/index.js';
10
+ import type { WatcherClient } from '../interfaces/index.js';
11
+ import type { SynthesisQueue } from '../queue/index.js';
12
+ import type { RuleRegistrar } from '../rules/index.js';
13
+ import type { Scheduler } from '../scheduler/index.js';
14
+ import type { ServiceConfig } from '../schema/config.js';
15
+ /** Runtime stats tracked by the service. */
16
+ export interface ServiceStats {
17
+ totalSyntheses: number;
18
+ totalTokens: number;
19
+ totalErrors: number;
20
+ lastCycleDurationMs: number | null;
21
+ lastCycleAt: string | null;
22
+ }
23
+ /**
24
+ * Large generated fields excluded from detail/update response projections.
25
+ * Shared between metas detail and metasUpdate routes.
26
+ */
27
+ export declare const DEFAULT_EXCLUDE_FIELDS: Set<string>;
28
+ /** Dependencies injected into route handlers. */
29
+ export interface RouteDeps {
30
+ config: ServiceConfig;
31
+ logger: Logger;
32
+ queue: SynthesisQueue;
33
+ watcher: WatcherClient;
34
+ scheduler: Scheduler | null;
35
+ stats: ServiceStats;
36
+ /** Cached listMetas results with TTL. */
37
+ cache: MetaCache;
38
+ /** Service readiness flag — false during startup. */
39
+ ready: boolean;
40
+ /** Rule registrar for reporting registration state in /status. */
41
+ registrar?: RuleRegistrar;
42
+ /** Executor instance for abort support. */
43
+ executor?: Pick<GatewayExecutor, 'abort'>;
44
+ /** Set to true during graceful shutdown. */
45
+ shuttingDown?: boolean;
46
+ /** Runtime config file path for config-apply. */
47
+ configPath?: string;
48
+ }
49
+ /** Register all HTTP routes on the Fastify instance. */
50
+ export declare function registerRoutes(app: FastifyInstance, deps: RouteDeps): void;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * GET /metas — list metas with optional filters.
3
+ * GET /metas/:path — single meta detail.
4
+ *
5
+ * @module routes/metas
6
+ */
7
+ import type { FastifyInstance } from 'fastify';
8
+ import { type RouteDeps } from './index.js';
9
+ export declare function registerMetasRoutes(app: FastifyInstance, deps: RouteDeps): void;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * PATCH /metas/:path — update user-settable reserved properties on a meta.
3
+ *
4
+ * Supported fields: _steer, _emphasis, _depth, _crossRefs, _disabled.
5
+ * Set a field to null to remove it. Unknown keys are rejected.
6
+ *
7
+ * @module routes/metasUpdate
8
+ */
9
+ import type { FastifyInstance } from 'fastify';
10
+ import { type RouteDeps } from './index.js';
11
+ export declare function registerMetasUpdateRoute(app: FastifyInstance, deps: RouteDeps): void;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * GET /preview — dry-run synthesis preview.
3
+ *
4
+ * @module routes/preview
5
+ */
6
+ import type { FastifyInstance } from 'fastify';
7
+ import type { RouteDeps } from './index.js';
8
+ export declare function registerPreviewRoute(app: FastifyInstance, deps: RouteDeps): void;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Queue management and abort routes.
3
+ *
4
+ * - GET /queue — 3-layer queue model (current, overrides, automatic, pending)
5
+ * - POST /queue/clear — remove override entries only
6
+ * - POST /synthesize/abort — abort the current synthesis
7
+ *
8
+ * @module routes/queue
9
+ */
10
+ import type { FastifyInstance } from 'fastify';
11
+ import type { RouteDeps } from './index.js';
12
+ /** Register queue management routes. */
13
+ export declare function registerQueueRoutes(app: FastifyInstance, deps: RouteDeps): void;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * POST /seed — create a .meta/ directory with an empty meta.json.
3
+ *
4
+ * @module routes/seed
5
+ */
6
+ import type { FastifyInstance } from 'fastify';
7
+ import type { RouteDeps } from './index.js';
8
+ export declare function registerSeedRoute(app: FastifyInstance, deps: RouteDeps): void;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * GET /status — service health and status overview.
3
+ *
4
+ * Uses the core SDK's `createStatusHandler` factory with a custom
5
+ * `getHealth` callback that preserves all existing health details.
6
+ *
7
+ * @module routes/status
8
+ */
9
+ import type { ServiceState } from '@karmaniverous/jeeves-meta-core';
10
+ import type { FastifyInstance } from 'fastify';
11
+ import type { RouteDeps } from './index.js';
12
+ export type { ServiceState };
13
+ export declare function registerStatusRoute(app: FastifyInstance, deps: RouteDeps): void;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * POST /synthesize route handler.
3
+ *
4
+ * Path-targeted triggers create explicit override entries in the queue.
5
+ * Corpus-wide triggers discover the stalest candidate.
6
+ *
7
+ * @module routes/synthesize
8
+ */
9
+ import type { FastifyInstance } from 'fastify';
10
+ import type { RouteDeps } from './index.js';
11
+ /** Register the POST /synthesize route. */
12
+ export declare function registerSynthesizeRoute(app: FastifyInstance, deps: RouteDeps): void;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * POST /unlock — remove .lock from a .meta/ directory.
3
+ *
4
+ * @module routes/unlock
5
+ */
6
+ import type { FastifyInstance } from 'fastify';
7
+ import type { RouteDeps } from './index.js';
8
+ export declare function registerUnlockRoute(app: FastifyInstance, deps: RouteDeps): void;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Periodic watcher health check for rule registration resilience.
3
+ *
4
+ * Pings watcher `/status` on a configurable interval, detects restarts
5
+ * (uptime decrease), and re-registers virtual rules automatically.
6
+ * Independent of the synthesis scheduler.
7
+ *
8
+ * @module rules/healthCheck
9
+ */
10
+ import type { Logger } from 'pino';
11
+ import type { RuleRegistrar } from './index.js';
12
+ /**
13
+ * Manages the periodic watcher health check loop.
14
+ *
15
+ * Starts a `setInterval` that pings the watcher and delegates
16
+ * restart detection to `RuleRegistrar.checkAndReregister()`.
17
+ */
18
+ export declare class WatcherHealthCheck {
19
+ private readonly watcherUrl;
20
+ private readonly intervalMs;
21
+ private readonly registrar;
22
+ private readonly logger;
23
+ private handle;
24
+ constructor(opts: {
25
+ watcherUrl: string;
26
+ intervalMs: number;
27
+ registrar: RuleRegistrar;
28
+ logger: Logger;
29
+ });
30
+ /** Start the periodic health check. No-op if intervalMs is 0. */
31
+ start(): void;
32
+ /** Stop the periodic health check. */
33
+ stop(): void;
34
+ /** Single health check iteration. */
35
+ private check;
36
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Virtual rule registration with jeeves-watcher.
3
+ *
4
+ * Service registers inference rules at startup (with retry) and
5
+ * re-registers opportunistically when watcher restart is detected.
6
+ *
7
+ * @module rules
8
+ */
9
+ import type { Logger } from 'pino';
10
+ import type { WatcherClient } from '../interfaces/index.js';
11
+ import type { MetaConfig } from '../schema/config.js';
12
+ /**
13
+ * Manages virtual rule registration with watcher.
14
+ *
15
+ * - Registers at startup with exponential retry
16
+ * - Tracks watcher uptime for restart detection
17
+ * - Re-registers opportunistically when uptime decreases
18
+ */
19
+ export declare class RuleRegistrar {
20
+ private readonly config;
21
+ private readonly logger;
22
+ private readonly watcherClient;
23
+ private lastWatcherUptime;
24
+ private registered;
25
+ constructor(config: MetaConfig, logger: Logger, watcher: WatcherClient);
26
+ /** Whether rules have been successfully registered. */
27
+ get isRegistered(): boolean;
28
+ /**
29
+ * Register rules with watcher. Retries with exponential backoff.
30
+ * Non-blocking — logs errors but never throws.
31
+ */
32
+ register(): Promise<void>;
33
+ /**
34
+ * Check watcher uptime and re-register if it decreased (restart detected).
35
+ *
36
+ * @param currentUptime - Current watcher uptime in seconds.
37
+ */
38
+ checkAndReregister(currentUptime: number): Promise<void>;
39
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Post-registration verification of virtual rule application.
3
+ *
4
+ * After rules are registered with the watcher, verifies that .meta/meta.json
5
+ * files are discoverable via watcher walk (which depends on virtual rules
6
+ * being applied). Logs a warning if expected metas are not found.
7
+ *
8
+ * @module rules/verify
9
+ */
10
+ import type { WatcherClient } from '../interfaces/index.js';
11
+ import type { MinimalLogger } from '../logger/index.js';
12
+ /**
13
+ * Verify that virtual rules are applied to indexed .meta/meta.json files.
14
+ *
15
+ * Runs a discovery pass and logs the result. If no metas are found but
16
+ * the filesystem likely has some, logs a warning suggesting reindex.
17
+ *
18
+ * @param watcher - WatcherClient for discovery.
19
+ * @param logger - Logger for reporting results.
20
+ * @returns Number of metas discovered.
21
+ */
22
+ export declare function verifyRuleApplication(watcher: WatcherClient, logger: MinimalLogger): Promise<number>;