@plurnk/plurnk-service 0.43.0 → 0.45.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/.env.example +28 -28
- package/README.md +37 -18
- package/SPEC.md +64 -35
- package/dist/core/ChannelWrite.d.ts +4 -0
- package/dist/core/ChannelWrite.d.ts.map +1 -1
- package/dist/core/ChannelWrite.js +9 -0
- package/dist/core/ChannelWrite.js.map +1 -1
- package/dist/core/ChannelWrite.sql +69 -0
- package/dist/core/Engine.d.ts.map +1 -1
- package/dist/core/Engine.js +115 -77
- package/dist/core/Engine.js.map +1 -1
- package/dist/core/Engine.sql +291 -0
- package/dist/core/ExecutorRegistry.d.ts +4 -2
- package/dist/core/ExecutorRegistry.d.ts.map +1 -1
- package/dist/core/ExecutorRegistry.js +14 -4
- package/dist/core/ExecutorRegistry.js.map +1 -1
- package/dist/core/SchemeRegistry.d.ts +1 -0
- package/dist/core/SchemeRegistry.d.ts.map +1 -1
- package/dist/core/SchemeRegistry.js +22 -21
- package/dist/core/SchemeRegistry.js.map +1 -1
- package/dist/core/fork.d.ts.map +1 -1
- package/dist/core/fork.js +8 -1
- package/dist/core/fork.js.map +1 -1
- package/dist/core/fork.sql +50 -0
- package/dist/core/plugin-attribution.d.ts +5 -0
- package/dist/core/plugin-attribution.d.ts.map +1 -0
- package/dist/core/plugin-attribution.js +39 -0
- package/dist/core/plugin-attribution.js.map +1 -0
- package/dist/core/run-ops.sql +16 -0
- package/dist/core/session-settings.d.ts +1 -0
- package/dist/core/session-settings.d.ts.map +1 -1
- package/dist/core/session-settings.js +2 -1
- package/dist/core/session-settings.js.map +1 -1
- package/dist/schemes/Exec.d.ts +1 -1
- package/dist/schemes/Exec.d.ts.map +1 -1
- package/dist/schemes/Exec.js +19 -6
- package/dist/schemes/Exec.js.map +1 -1
- package/dist/schemes/File.d.ts +0 -1
- package/dist/schemes/File.d.ts.map +1 -1
- package/dist/schemes/File.js +29 -4
- package/dist/schemes/File.js.map +1 -1
- package/dist/schemes/Known.d.ts +0 -1
- package/dist/schemes/Known.d.ts.map +1 -1
- package/dist/schemes/Known.js +2 -1
- package/dist/schemes/Known.js.map +1 -1
- package/dist/schemes/Log.d.ts +0 -1
- package/dist/schemes/Log.d.ts.map +1 -1
- package/dist/schemes/Log.js +2 -1
- package/dist/schemes/Log.js.map +1 -1
- package/dist/schemes/Log.sql +37 -0
- package/dist/schemes/Plurnk.d.ts +0 -1
- package/dist/schemes/Plurnk.d.ts.map +1 -1
- package/dist/schemes/Plurnk.js +2 -1
- package/dist/schemes/Plurnk.js.map +1 -1
- package/dist/schemes/Run.d.ts +0 -1
- package/dist/schemes/Run.d.ts.map +1 -1
- package/dist/schemes/Run.js +2 -1
- package/dist/schemes/Run.js.map +1 -1
- package/dist/schemes/Unknown.d.ts +0 -1
- package/dist/schemes/Unknown.d.ts.map +1 -1
- package/dist/schemes/Unknown.js +2 -1
- package/dist/schemes/Unknown.js.map +1 -1
- package/dist/schemes/_entry-crud.sql +88 -0
- package/dist/schemes/_entry-find.sql +31 -0
- package/dist/schemes/_entry-graph.sql +60 -0
- package/dist/schemes/_entry-manifest.d.ts.map +1 -1
- package/dist/schemes/_entry-manifest.js +4 -1
- package/dist/schemes/_entry-manifest.js.map +1 -1
- package/dist/schemes/_entry-ops.sql +20 -0
- package/dist/schemes/_entry-semantic.sql +64 -0
- package/dist/schemes/exec-env.js +1 -1
- package/dist/schemes/exec-env.js.map +1 -1
- package/dist/server/Daemon.d.ts.map +1 -1
- package/dist/server/Daemon.js +103 -37
- package/dist/server/Daemon.js.map +1 -1
- package/dist/server/clientTurn.sql +10 -0
- package/dist/server/drain.sql +82 -0
- package/dist/server/dsl.d.ts.map +1 -1
- package/dist/server/dsl.js +11 -4
- package/dist/server/dsl.js.map +1 -1
- package/dist/server/envelope.sql +75 -0
- package/dist/server/logEntry.sql +10 -0
- package/dist/server/methods/_dispatchAsClient.d.ts.map +1 -1
- package/dist/server/methods/_dispatchAsClient.js +11 -6
- package/dist/server/methods/_dispatchAsClient.js.map +1 -1
- package/dist/server/methods/entry_read.sql +21 -0
- package/dist/server/methods/log_read.sql +11 -0
- package/dist/server/methods/loop_run.d.ts.map +1 -1
- package/dist/server/methods/loop_run.js +4 -0
- package/dist/server/methods/loop_run.js.map +1 -1
- package/dist/server/methods/loop_run.sql +9 -0
- package/dist/server/methods/session_create.d.ts.map +1 -1
- package/dist/server/methods/session_create.js +10 -3
- package/dist/server/methods/session_create.js.map +1 -1
- package/dist/service.d.ts +6 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +221 -0
- package/dist/service.js.map +1 -0
- package/package.json +29 -15
- package/requirements.md +2 -1
- package/bin/plurnk-service.ts +0 -176
- package/dist/core/ProviderRegistry.d.ts +0 -42
- package/dist/core/ProviderRegistry.d.ts.map +0 -1
- package/dist/core/ProviderRegistry.js +0 -72
- package/dist/core/ProviderRegistry.js.map +0 -1
- package/dist/core/line-marker.d.ts +0 -23
- package/dist/core/line-marker.d.ts.map +0 -1
- package/dist/core/line-marker.js +0 -321
- package/dist/core/line-marker.js.map +0 -1
- package/dist/core/matcher.d.ts +0 -12
- package/dist/core/matcher.d.ts.map +0 -1
- package/dist/core/matcher.js +0 -72
- package/dist/core/matcher.js.map +0 -1
- package/dist/core/mimetype-binary.d.ts +0 -6
- package/dist/core/mimetype-binary.d.ts.map +0 -1
- package/dist/core/mimetype-binary.js +0 -82
- package/dist/core/mimetype-binary.js.map +0 -1
- package/dist/core/path-mimetype.d.ts +0 -3
- package/dist/core/path-mimetype.d.ts.map +0 -1
- package/dist/core/path-mimetype.js +0 -47
- package/dist/core/path-mimetype.js.map +0 -1
- package/dist/core/plugin-trust.d.ts +0 -4
- package/dist/core/plugin-trust.d.ts.map +0 -1
- package/dist/core/plugin-trust.js +0 -23
- package/dist/core/plugin-trust.js.map +0 -1
- package/dist/providers/Mock.d.ts +0 -43
- package/dist/providers/Mock.d.ts.map +0 -1
- package/dist/providers/Mock.js +0 -36
- package/dist/providers/Mock.js.map +0 -1
- package/dist/server/methods/op_hide.d.ts +0 -5
- package/dist/server/methods/op_hide.d.ts.map +0 -1
- package/dist/server/methods/op_hide.js +0 -24
- package/dist/server/methods/op_hide.js.map +0 -1
- package/dist/server/methods/op_show.d.ts +0 -5
- package/dist/server/methods/op_show.d.ts.map +0 -1
- package/dist/server/methods/op_show.js +0 -24
- package/dist/server/methods/op_show.js.map +0 -1
- package/dist/server/methods/session_set_persona.d.ts +0 -5
- package/dist/server/methods/session_set_persona.d.ts.map +0 -1
- package/dist/server/methods/session_set_persona.js +0 -29
- package/dist/server/methods/session_set_persona.js.map +0 -1
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
-- Engine SQL. SPEC §arch (architecture), §scheme (op dispatch + log).
|
|
2
|
+
|
|
3
|
+
-- PREP: engine_loop_status
|
|
4
|
+
SELECT status FROM loops WHERE id = $loop_id;
|
|
5
|
+
|
|
6
|
+
-- PREP: engine_count_active_loops_for_run
|
|
7
|
+
-- Wake-on-completion uses this to decide whether to open a new loop or
|
|
8
|
+
-- let the existing one pick up the channel transition at the next turn
|
|
9
|
+
-- boundary. Status 102 = "in progress" (any non-terminal state).
|
|
10
|
+
SELECT COUNT(*) AS n FROM loops WHERE run_id = $run_id AND status = 102;
|
|
11
|
+
|
|
12
|
+
-- PREP: engine_get_loop_flags
|
|
13
|
+
-- Loads the loop's persisted flags (json). Default '{}'; YOLO listener and
|
|
14
|
+
-- SchemeRegistry.resolveForLoop merge over DEFAULT_LOOP_FLAGS for missing
|
|
15
|
+
-- fields. Migration 014.
|
|
16
|
+
SELECT flags FROM loops WHERE id = $loop_id;
|
|
17
|
+
|
|
18
|
+
-- PREP: engine_set_loop_flags
|
|
19
|
+
-- Updates the loop's persisted flags (json). Called by loop.run RPC handler.
|
|
20
|
+
UPDATE loops SET flags = $flags WHERE id = $loop_id;
|
|
21
|
+
|
|
22
|
+
-- PREP: engine_get_loop_prompt
|
|
23
|
+
-- Loop's prompt + sequence — runTurn reads it on turn 1 to foist a
|
|
24
|
+
-- system-origin EDIT against plurnk:///prompt/<loop_id>/1 (§packet), at the
|
|
25
|
+
-- turn's first action sequence. Prompts are first-class log entries
|
|
26
|
+
-- (no synthetic / shim layer).
|
|
27
|
+
SELECT prompt, sequence FROM loops WHERE id = $loop_id;
|
|
28
|
+
|
|
29
|
+
-- PREP: engine_loop_set_status
|
|
30
|
+
-- The universal terminal setter. terminal_message carries either the loop's deliverable
|
|
31
|
+
-- (the SEND body) or the engine's abandonment reason (max_turns / budget_overflow /
|
|
32
|
+
-- strike_threshold) — rides the §run-scheme delta.
|
|
33
|
+
UPDATE loops SET status = $status, terminal_message = $message WHERE id = $loop_id;
|
|
34
|
+
|
|
35
|
+
-- PREP: session_get_settings
|
|
36
|
+
-- #231 — the session's client-chosen open-context bag ({ manifestItems?, mdDocs? }),
|
|
37
|
+
-- read at turn-0 with precedence over env.
|
|
38
|
+
SELECT settings FROM sessions WHERE id = $session_id;
|
|
39
|
+
|
|
40
|
+
-- PREP: engine_target_diverged_this_turn
|
|
41
|
+
-- #note10 — did this entry diverge on disk THIS turn? A source=file env-delta for the
|
|
42
|
+
-- target, materialized into this run's log at the current turn, means the model's view
|
|
43
|
+
-- predates the ambient change — a YOLO auto-accept of a same-turn EDIT would clobber it.
|
|
44
|
+
SELECT 1 AS hit
|
|
45
|
+
FROM log_entries
|
|
46
|
+
WHERE run_id = $run_id AND turn_id = $turn_id
|
|
47
|
+
AND origin = 'plurnk' AND source = 'file' AND op = 'EDIT'
|
|
48
|
+
AND scheme IS $scheme AND pathname = $pathname
|
|
49
|
+
LIMIT 1;
|
|
50
|
+
|
|
51
|
+
-- PREP: engine_list_session_entry_tags
|
|
52
|
+
-- #note13 — every (entry, tag) in the session, for the manifest catalog's tags field.
|
|
53
|
+
SELECT et.entry_id, et.tag
|
|
54
|
+
FROM entry_tags et
|
|
55
|
+
JOIN entries e ON e.id = et.entry_id
|
|
56
|
+
WHERE e.session_id = $session_id
|
|
57
|
+
ORDER BY et.entry_id, et.tag;
|
|
58
|
+
|
|
59
|
+
-- PREP: engine_next_turn_sequence
|
|
60
|
+
SELECT COALESCE(MAX(sequence), 0) + 1 AS next FROM turns WHERE loop_id = $loop_id;
|
|
61
|
+
|
|
62
|
+
-- PREP: engine_loop_usage
|
|
63
|
+
-- Per-loop usage totals — SUM the loop's turns (§tokenomics stores usage per turn).
|
|
64
|
+
-- Surfaced on loop.run + loop/terminated (#197).
|
|
65
|
+
SELECT COALESCE(SUM(usage_prompt), 0) AS prompt,
|
|
66
|
+
COALESCE(SUM(usage_completion), 0) AS completion,
|
|
67
|
+
COALESCE(SUM(usage_cost_pico), 0) AS cost_pico
|
|
68
|
+
FROM turns WHERE loop_id = $loop_id;
|
|
69
|
+
|
|
70
|
+
-- PREP: engine_loop_turn_seqs
|
|
71
|
+
-- Look up (loop_seq, turn_seq) for a given (loop_id, turn_id). Used by
|
|
72
|
+
-- #writeLog when an op needs to address itself or its output by log
|
|
73
|
+
-- coordinate (e.g. EXEC's stream entry at exec:///<loop_seq>/<turn_seq>/<sequence>/EXEC).
|
|
74
|
+
SELECT l.sequence AS loop_seq, t.sequence AS turn_seq
|
|
75
|
+
FROM loops l, turns t
|
|
76
|
+
WHERE l.id = $loop_id AND t.id = $turn_id;
|
|
77
|
+
|
|
78
|
+
-- PREP: engine_open_turn
|
|
79
|
+
-- Turn-as-container model: insert a turn row at runTurn open with a
|
|
80
|
+
-- placeholder packet and status=102 (in-progress). Pre-model writes
|
|
81
|
+
-- (the user prompt; later, system signals/telemetry events) land into
|
|
82
|
+
-- this row before the provider is called. The turn is then "closed"
|
|
83
|
+
-- via engine_close_turn with the final packet + status + usage stats
|
|
84
|
+
-- after dispatch completes.
|
|
85
|
+
INSERT INTO turns (loop_id, sequence, status, packet)
|
|
86
|
+
VALUES ($loop_id, $sequence, 102, '{}')
|
|
87
|
+
RETURNING id;
|
|
88
|
+
|
|
89
|
+
-- PREP: engine_close_turn
|
|
90
|
+
-- Updates the turn with the response packet, terminal status, and
|
|
91
|
+
-- provider usage stats once dispatch is complete. Paired with
|
|
92
|
+
-- engine_open_turn at runTurn boundaries.
|
|
93
|
+
UPDATE turns SET
|
|
94
|
+
status = $status,
|
|
95
|
+
packet = $packet,
|
|
96
|
+
usage_prompt = $usage_prompt,
|
|
97
|
+
usage_completion = $usage_completion,
|
|
98
|
+
usage_cached = $usage_cached,
|
|
99
|
+
usage_cost_pico = $usage_cost_pico,
|
|
100
|
+
finish_reason = $finish_reason,
|
|
101
|
+
model = $model
|
|
102
|
+
WHERE id = $id;
|
|
103
|
+
|
|
104
|
+
-- PREP: engine_list_session_entries
|
|
105
|
+
-- Every entry of a session — all schemes, all channels — the source for
|
|
106
|
+
-- plurnk:///manifest.json, the flat catalog of everything the session holds.
|
|
107
|
+
-- Session-scoped (persists across runs); FOLD doesn't drop from the catalog.
|
|
108
|
+
-- `seconds` is the live age of an active stream: now − the open subscription's
|
|
109
|
+
-- opened_at (closed_at IS NULL). NULL for static entries. unixepoch parses the
|
|
110
|
+
-- stored '...%fZ' timestamp directly; re-evaluated every render like tokens.
|
|
111
|
+
SELECT e.id AS entry_id, e.scheme, e.pathname, ec.name AS channel, ec.content, ec.mimetype, ec.tokens, e.deep_hash,
|
|
112
|
+
CAST(unixepoch('now') - unixepoch(s.opened_at) AS INTEGER) AS seconds
|
|
113
|
+
FROM entries e
|
|
114
|
+
JOIN entry_channels ec ON ec.entry_id = e.id
|
|
115
|
+
LEFT JOIN subscriptions s ON s.entry_id = e.id AND s.closed_at IS NULL
|
|
116
|
+
-- entries are session-scoped, shared across runs — §machine-processes-one-filesystem
|
|
117
|
+
WHERE e.scope = 'session' AND e.session_id = $session_id
|
|
118
|
+
-- User Note 5 — mtime-ascending: dormant entries hold the stable prompt-cache prefix; churn clusters at the tail.
|
|
119
|
+
ORDER BY e.updated_at ASC, e.id ASC, ec.name;
|
|
120
|
+
|
|
121
|
+
-- PREP: engine_run_prior_turn_time
|
|
122
|
+
-- §env-delta — timestamp of this run's most recent turn BEFORE the current one
|
|
123
|
+
-- (the "since I last looked" boundary). NULL on the run's first turn → no deltas.
|
|
124
|
+
SELECT MAX(t.timestamp) AS since
|
|
125
|
+
FROM turns t JOIN loops l ON l.id = t.loop_id
|
|
126
|
+
WHERE l.run_id = $run_id AND t.id != $turn_id;
|
|
127
|
+
|
|
128
|
+
-- PREP: engine_pull_env_deltas
|
|
129
|
+
-- §env-delta — other actors' resolved EDITs on shared entries since this run last
|
|
130
|
+
-- looked. Real edits (origin model/client) AND the plurnk run's fs-sync fictions
|
|
131
|
+
-- (origin=plurnk on the reserved 'plurnk' run); excludes this run's own rows and
|
|
132
|
+
-- other runs' already-materialized deltas (origin=plurnk on a real run). plurnk:///
|
|
133
|
+
-- entries (manifest/prompt/doc) never surface. This is the environment door (§actor-boundary-two-doors); the voice door is inject.
|
|
134
|
+
SELECT le.run_id, le.scheme, le.pathname, le.rx, le.source
|
|
135
|
+
FROM log_entries le
|
|
136
|
+
JOIN runs r ON r.id = le.run_id
|
|
137
|
+
WHERE r.session_id = $session_id
|
|
138
|
+
AND le.op = 'EDIT'
|
|
139
|
+
AND le.state = 'resolved'
|
|
140
|
+
AND le.status_rx IN (200, 201)
|
|
141
|
+
AND (le.scheme IS NULL OR le.scheme != 'plurnk')
|
|
142
|
+
AND le.run_id != $run_id
|
|
143
|
+
AND le.at > $since
|
|
144
|
+
AND (le.origin != 'plurnk'
|
|
145
|
+
OR le.run_id = (SELECT id FROM runs WHERE session_id = $session_id AND name = 'plurnk'))
|
|
146
|
+
ORDER BY le.at;
|
|
147
|
+
|
|
148
|
+
-- PREP: engine_insert_env_delta
|
|
149
|
+
-- §env-delta — materialize a pulled cross-actor edit as a FOLDED delta (expanded=0)
|
|
150
|
+
-- in this run's log. origin=plurnk; source carries the cause (sibling run id or
|
|
151
|
+
-- 'file'); rx reuses the originating row's result span (§edit-result-render).
|
|
152
|
+
INSERT INTO log_entries (
|
|
153
|
+
run_id, loop_id, turn_id, sequence, origin, source,
|
|
154
|
+
op, scheme, pathname, tx, mimetype_tx, rx, mimetype_rx, status_rx, expanded
|
|
155
|
+
) VALUES (
|
|
156
|
+
$run_id, $loop_id, $turn_id, $sequence, 'plurnk', $source,
|
|
157
|
+
'EDIT', $scheme, $pathname, '', 'text/plain', $rx, 'application/json', 200, 0
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
-- PREP: engine_pull_loop_terminations
|
|
161
|
+
-- §run-scheme — sibling runs' loops that reached a terminal status since this run last
|
|
162
|
+
-- looked (the loop-termination ambient delta). Carries terminal_message — the SEND[200]
|
|
163
|
+
-- deliverable or the abandonment reason. Excludes this run's own loops.
|
|
164
|
+
SELECT l.run_id, r.name AS run_name, l.status, l.prompt, l.terminal_message
|
|
165
|
+
FROM loops l
|
|
166
|
+
JOIN runs r ON r.id = l.run_id
|
|
167
|
+
WHERE r.session_id = $session_id
|
|
168
|
+
AND l.terminated_at IS NOT NULL
|
|
169
|
+
AND l.terminated_at > $since
|
|
170
|
+
AND l.run_id != $run_id
|
|
171
|
+
ORDER BY l.terminated_at;
|
|
172
|
+
|
|
173
|
+
-- PREP: engine_insert_loop_termination_delta
|
|
174
|
+
-- §run-scheme — materialize a sibling's loop-termination as a FOLDED delta: a SEND
|
|
175
|
+
-- from run:///<name> carrying the terminal status + message (the deliverable).
|
|
176
|
+
-- origin=plurnk, source=the terminated run — uniform with the env-delta.
|
|
177
|
+
INSERT INTO log_entries (
|
|
178
|
+
run_id, loop_id, turn_id, sequence, origin, source,
|
|
179
|
+
op, scheme, pathname, tx, mimetype_tx, rx, mimetype_rx, status_rx, expanded
|
|
180
|
+
) VALUES (
|
|
181
|
+
$run_id, $loop_id, $turn_id, $sequence, 'plurnk', $source,
|
|
182
|
+
'SEND', 'run', $pathname, '', 'text/plain', $rx, 'text/markdown', $status, 0
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
-- PREP: engine_entry_tags
|
|
186
|
+
SELECT tag FROM entry_tags WHERE entry_id = $entry_id ORDER BY tag;
|
|
187
|
+
|
|
188
|
+
-- PREP: engine_render_telemetry_errors
|
|
189
|
+
-- SPEC §telemetry: action-bound failures from the immediately previous turn
|
|
190
|
+
-- are mirrored into the next packet's telemetry.errors[]. Forces the
|
|
191
|
+
-- model to confront 4xx/5xx outcomes instead of letting them rot in
|
|
192
|
+
-- log:///. "Previous turn" = sequence one below the currently-open one
|
|
193
|
+
-- (turn-as-container model: the current turn exists with status=102
|
|
194
|
+
-- when this query fires, so we explicitly look one back).
|
|
195
|
+
SELECT
|
|
196
|
+
le.op, le.sequence, le.status_rx, le.rx, le.mimetype_rx,
|
|
197
|
+
le.scheme, le.pathname,
|
|
198
|
+
t.sequence AS turn_seq, l.sequence AS loop_seq
|
|
199
|
+
FROM log_entries le
|
|
200
|
+
JOIN turns t ON t.id = le.turn_id
|
|
201
|
+
JOIN loops l ON l.id = le.loop_id
|
|
202
|
+
WHERE le.loop_id = $loop_id
|
|
203
|
+
AND le.status_rx >= 400
|
|
204
|
+
AND t.sequence = $current_turn_seq - 1
|
|
205
|
+
ORDER BY le.sequence;
|
|
206
|
+
|
|
207
|
+
-- PREP: engine_grinder_prior_turn_logs
|
|
208
|
+
-- §grinder pass 1 (prior-turn rollback): the immediately-prior turn's still-open
|
|
209
|
+
-- log entries — the latest emissions that pushed the packet over. Folding them
|
|
210
|
+
-- (collapse to coordinate, not deleting) lightens the render; bodies persist, re-OPENable.
|
|
211
|
+
SELECT le.id, le.scheme
|
|
212
|
+
FROM log_entries le
|
|
213
|
+
WHERE le.loop_id = $loop_id AND le.expanded = 1
|
|
214
|
+
AND le.turn_id = (SELECT MAX(id) FROM turns WHERE loop_id = $loop_id AND id < $turn_id);
|
|
215
|
+
|
|
216
|
+
-- PREP: engine_grinder_fold_prior_turn_logs
|
|
217
|
+
-- §grinder pass 1: fold the prior turn's still-open logs in one set-op (same WHERE
|
|
218
|
+
-- as engine_grinder_prior_turn_logs above). Rows + bodies stay, re-OPENable.
|
|
219
|
+
UPDATE log_entries SET expanded = 0
|
|
220
|
+
WHERE loop_id = $loop_id AND expanded = 1
|
|
221
|
+
AND turn_id = (SELECT MAX(id) FROM turns WHERE loop_id = $loop_id AND id < $turn_id);
|
|
222
|
+
|
|
223
|
+
-- PREP: engine_fold_log_entry
|
|
224
|
+
-- §prompt-fold (User Note 6): fold a single log row by id — collapse to its
|
|
225
|
+
-- coordinate, body elided in the render, re-OPENable. Used for the foisted prompt
|
|
226
|
+
-- EDIT, which duplicates packet.user.prompt: logged for forensics, born folded.
|
|
227
|
+
UPDATE log_entries SET expanded = 0 WHERE id = $id;
|
|
228
|
+
|
|
229
|
+
-- PREP: engine_render_log
|
|
230
|
+
-- Render-time log assembly (SPEC §packet packet.system.log).
|
|
231
|
+
-- Yields log_entries for the whole RUN — the conversation's working
|
|
232
|
+
-- memory carries across loops within a session's run, not just the
|
|
233
|
+
-- current loop. Coordinate is log:///<loop_seq>/<turn_seq>/<sequence>/<op>.
|
|
234
|
+
-- Status 202 entries in state='proposed' are model-invisible until resolved.
|
|
235
|
+
-- `expanded = 0` rows are FOLDED — listed but collapsed to their coordinate
|
|
236
|
+
-- (FOLD); the renderer elides the body. §open-fold: folded rows stay listed, re-OPENable.
|
|
237
|
+
SELECT
|
|
238
|
+
l.sequence AS loop_seq,
|
|
239
|
+
t.sequence AS turn_seq,
|
|
240
|
+
le.sequence,
|
|
241
|
+
-- le.origin is attribution, never a render filter; the run's actor — §actor-boundary-origin-not-filter §machine-processes-run-origin
|
|
242
|
+
le.origin,
|
|
243
|
+
le.op, le.suffix, le.signal,
|
|
244
|
+
le.scheme, le.username, le.password,
|
|
245
|
+
le.hostname, le.port, le.pathname,
|
|
246
|
+
le.params, le.fragment,
|
|
247
|
+
le.status_rx, le.rx, le.mimetype_rx,
|
|
248
|
+
le.tx, le.mimetype_tx,
|
|
249
|
+
le.state, le.outcome, le.expanded, le.source
|
|
250
|
+
FROM log_entries le
|
|
251
|
+
JOIN turns t ON t.id = le.turn_id
|
|
252
|
+
JOIN loops l ON l.id = le.loop_id
|
|
253
|
+
-- WHERE renders exactly one run's log — §actor-boundary-isolation §machine-processes-run-is-its-log
|
|
254
|
+
-- the AND NOT clause keeps proposed (202) rows hidden until resolved — §proposal-proposed-hidden
|
|
255
|
+
WHERE le.run_id = $run_id
|
|
256
|
+
AND NOT (le.status_rx = 202 AND le.state = 'proposed')
|
|
257
|
+
ORDER BY l.sequence, t.sequence, le.sequence;
|
|
258
|
+
|
|
259
|
+
-- PREP: engine_insert_log_entry
|
|
260
|
+
-- Default state='resolved' covers the common path (non-proposing schemes
|
|
261
|
+
-- return their final status immediately). Status 202 + state='proposed'
|
|
262
|
+
-- triggers the proposal lifecycle (engine pauses dispatch; client resolves
|
|
263
|
+
-- via loop/resolve RPC; entry transitions through engine_resolve_log_entry).
|
|
264
|
+
INSERT INTO log_entries (
|
|
265
|
+
run_id, loop_id, turn_id, sequence, origin, source,
|
|
266
|
+
op, suffix, signal,
|
|
267
|
+
scheme, username, password, hostname, port,
|
|
268
|
+
pathname, params, fragment, lineMarker,
|
|
269
|
+
tx, mimetype_tx, rx, mimetype_rx, status_rx, tokens,
|
|
270
|
+
state, outcome, attrs
|
|
271
|
+
) VALUES (
|
|
272
|
+
$run_id, $loop_id, $turn_id, $sequence, $origin, $source,
|
|
273
|
+
$op, $suffix, $signal,
|
|
274
|
+
$scheme, $username, $password, $hostname, $port,
|
|
275
|
+
$pathname, $params, $fragment, $lineMarker,
|
|
276
|
+
$tx, $mimetype_tx, $rx, $mimetype_rx, $status_rx, $tokens,
|
|
277
|
+
$state, $outcome, $attrs
|
|
278
|
+
)
|
|
279
|
+
RETURNING id;
|
|
280
|
+
|
|
281
|
+
-- PREP: engine_resolve_log_entry
|
|
282
|
+
-- Transitions a proposed log entry to its terminal state. Used by the
|
|
283
|
+
-- proposal lifecycle (loop/resolve RPC, YOLO auto-accept, timeout, abort).
|
|
284
|
+
-- Updates status_rx + rx + state + outcome atomically.
|
|
285
|
+
UPDATE log_entries
|
|
286
|
+
SET state = $state,
|
|
287
|
+
outcome = $outcome,
|
|
288
|
+
status_rx = $status_rx,
|
|
289
|
+
rx = $rx
|
|
290
|
+
WHERE id = $id
|
|
291
|
+
AND state = 'proposed';
|
|
@@ -17,10 +17,12 @@ export interface RegistryEntry {
|
|
|
17
17
|
}
|
|
18
18
|
export default class ExecutorRegistry {
|
|
19
19
|
#private;
|
|
20
|
-
constructor(byTag: ReadonlyMap<string, RegistryEntry
|
|
21
|
-
|
|
20
|
+
constructor(byTag: ReadonlyMap<string, RegistryEntry>, attributions?: readonly string[]);
|
|
21
|
+
attributions(): string[];
|
|
22
|
+
static build({ defaultRuntime, probeTimeoutMs, cwd, discoverFn, load }?: {
|
|
22
23
|
defaultRuntime?: string | null;
|
|
23
24
|
probeTimeoutMs?: number;
|
|
25
|
+
cwd?: string;
|
|
24
26
|
discoverFn?: () => Promise<{
|
|
25
27
|
registry: ReadonlyMap<string, {
|
|
26
28
|
runtime: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExecutorRegistry.d.ts","sourceRoot":"","sources":["../../src/core/ExecutorRegistry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,mBAAmB,EAAoB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"ExecutorRegistry.d.ts","sourceRoot":"","sources":["../../src/core/ExecutorRegistry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,mBAAmB,EAAoB,MAAM,sBAAsB,CAAC;AAK7H,MAAM,WAAW,QAAQ;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;IACtD,GAAG,CAAC,IAAI,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AE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;KACxC,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAqElC,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAO7C,iBAAiB,IAAI,SAAS,MAAM,EAAE;CAKzC"}
|
|
@@ -7,6 +7,7 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
7
7
|
return path;
|
|
8
8
|
};
|
|
9
9
|
import { discover } from "@plurnk/plurnk-execs";
|
|
10
|
+
import PluginAttribution from "./plugin-attribution.js";
|
|
10
11
|
// Boot-time runtime registry. Discovers installed @plurnk/plurnk-execs-*
|
|
11
12
|
// siblings (plurnk.kind:"exec") and probes each runtime TAG independently —
|
|
12
13
|
// one executor instance per tag (this.runtime = the tag), so a multi-tag
|
|
@@ -18,11 +19,16 @@ import { discover } from "@plurnk/plurnk-execs";
|
|
|
18
19
|
// plurnk-service#181, #185.
|
|
19
20
|
export default class ExecutorRegistry {
|
|
20
21
|
#byTag;
|
|
21
|
-
|
|
22
|
+
#attributions; // #249 — declared attribution tags of discovered exec packages
|
|
23
|
+
constructor(byTag, attributions = []) {
|
|
22
24
|
this.#byTag = byTag;
|
|
25
|
+
this.#attributions = attributions;
|
|
23
26
|
}
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
// #249 — declared attribution tags of the discovered exec packages (opaque; the engine
|
|
28
|
+
// unions these across plugin families onto the generate() `attributions` wire).
|
|
29
|
+
attributions() { return [...this.#attributions]; }
|
|
30
|
+
static async build({ defaultRuntime = null, probeTimeoutMs = 3000, cwd, discoverFn, load = (name) => import(__rewriteRelativeImportExtension(name)) } = {}) {
|
|
31
|
+
const { registry: discovered, skipped = [] } = await (discoverFn ?? (() => discover({ cwd })))();
|
|
26
32
|
// #229 trust gate: discover() skips untrusted third-party packages
|
|
27
33
|
// (PLURNK_PLUGINS_TRUSTED_ONLY) and reports them here — note each, mirror
|
|
28
34
|
// of SchemeRegistry's untrusted-scheme warning. Discovered, not loaded.
|
|
@@ -50,7 +56,11 @@ export default class ExecutorRegistry {
|
|
|
50
56
|
});
|
|
51
57
|
}
|
|
52
58
|
ExecutorRegistry.#assertDefaultUsable(byTag, defaultRuntime);
|
|
53
|
-
|
|
59
|
+
// #249 — collect attribution per DISTINCT package (a multi-tag package — -common's
|
|
60
|
+
// sh/perl/ruby — shares one manifest); fail-hard if any claims the reserved @plurnk/.
|
|
61
|
+
const packages = new Set([...discovered.values()].map((info) => info.packageName));
|
|
62
|
+
const attributions = [...packages].flatMap((pkg) => PluginAttribution.read(pkg));
|
|
63
|
+
return new ExecutorRegistry(byTag, attributions);
|
|
54
64
|
}
|
|
55
65
|
// A configured default runtime that can't run is an operator misconfig the
|
|
56
66
|
// boot must surface, not hide behind a silent fallback.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExecutorRegistry.js","sourceRoot":"","sources":["../../src/core/ExecutorRegistry.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"ExecutorRegistry.js","sourceRoot":"","sources":["../../src/core/ExecutorRegistry.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,iBAAiB,MAAM,yBAAyB,CAAC;AA0BxD,yEAAyE;AACzE,4EAA4E;AAC5E,yEAAyE;AACzE,8EAA8E;AAC9E,0EAA0E;AAC1E,8EAA8E;AAC9E,wEAAwE;AACxE,0EAA0E;AAC1E,4BAA4B;AAC5B,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACxB,MAAM,CAAqC;IAC3C,aAAa,CAAoB,CAAC,+DAA+D;IAE1G,YAAY,KAAyC,EAAE,eAAkC,EAAE;QACvF,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACtC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QACvB,CAAC;IACL,CAAC;IAED,KAAK,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAED,6EAA6E;IAC7E,6EAA6E;IAC7E,6BAA6B;IAC7B,iBAAiB;QACb,MAAM,IAAI,GAAa,EAAE,CAAC;QAC1B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM;YAAE,IAAI,KAAK,CAAC,SAAS;gBAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC5E,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;IACrE,CAAC;CACJ"}
|
|
@@ -15,6 +15,7 @@ export default class SchemeRegistry {
|
|
|
15
15
|
}>;
|
|
16
16
|
transformSections(sections: PacketSection[]): Promise<PacketSection[]>;
|
|
17
17
|
discoverExternal(cwd?: string): Promise<void>;
|
|
18
|
+
attributions(): string[];
|
|
18
19
|
resolveForLoop(flags: LoopFlags): Set<string>;
|
|
19
20
|
}
|
|
20
21
|
//# sourceMappingURL=SchemeRegistry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemeRegistry.d.ts","sourceRoot":"","sources":["../../src/core/SchemeRegistry.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"SchemeRegistry.d.ts","sourceRoot":"","sources":["../../src/core/SchemeRegistry.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAItD,MAAM,CAAC,OAAO,OAAO,cAAc;;;IAmB/B,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAK7C,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAErC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAEjC,IAAI,IAAI,MAAM,EAAE;IAWhB,KAAK,IAAI,MAAM;IAcf,IAAI,IAAI,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAc1C,iBAAiB,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAiBtE,gBAAgB,CAAC,GAAG,GAAE,MAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBlE,YAAY,IAAI,MAAM,EAAE;IAIxB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC;CAGhD"}
|
|
@@ -16,12 +16,14 @@ import File from "../schemes/File.js";
|
|
|
16
16
|
import Run from "../schemes/Run.js";
|
|
17
17
|
import ResolveForLoop from "./resolveForLoop.js";
|
|
18
18
|
import { SchemeDiscovery } from "@plurnk/plurnk-schemes";
|
|
19
|
+
import PluginAttribution from "./plugin-attribution.js";
|
|
19
20
|
export default class SchemeRegistry {
|
|
20
21
|
// Heterogeneous handler store — in-tree schemes take PlurnkSchemeContext, external
|
|
21
22
|
// siblings the DB-free SchemeCtx of the imported SchemeHandler; the common supertype
|
|
22
23
|
// is `object`. Dispatch (Engine.#run) borrows SchemeHandler's op-key set, not its ctx.
|
|
23
24
|
#handlers = new Map();
|
|
24
25
|
#external = new Set();
|
|
26
|
+
#attributions = []; // #249 — declared attribution tags of discovered external schemes
|
|
25
27
|
constructor() {
|
|
26
28
|
this.register("plurnk", new Plurnk());
|
|
27
29
|
this.register("log", new Log());
|
|
@@ -43,31 +45,26 @@ export default class SchemeRegistry {
|
|
|
43
45
|
// DB-free SchemeCtx (caps), not the in-tree PlurnkSchemeContext.
|
|
44
46
|
isExternal(name) { return this.#external.has(name); }
|
|
45
47
|
list() { return [...this.#handlers.keys()].toSorted(); }
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
//
|
|
48
|
+
// The scheme directory — the `schemes` packet section (below tools). grammar
|
|
49
|
+
// 0.49+ teaches grammar/dialects only, not the scheme set (grammar#239), so the
|
|
50
|
+
// service advertises what schemes exist at packet-time. Each handler that ships a
|
|
51
|
+
// `manifest.example` contributes ONE terse line — its canonical usage — plus a
|
|
52
|
+
// doc-link when it ships `manifest.documentation` (materialized at
|
|
53
|
+
// plurnk://docs/<name>.md by loop_run, READ on demand). The verbose semantics live
|
|
54
|
+
// in that pull doc, not here: terse pushes, depth pulls — exactly the exec tools
|
|
55
|
+
// sheet's shape (#collectTools). Insertion order; a scheme with no example
|
|
56
|
+
// (provisional, e.g. skill) is omitted. The doc's token cost rides its manifest entry.
|
|
51
57
|
teach() {
|
|
52
|
-
const
|
|
58
|
+
const lines = [];
|
|
53
59
|
for (const [name, handler] of this.#handlers) {
|
|
54
|
-
const
|
|
55
|
-
|
|
60
|
+
const manifest = handler.constructor.manifest;
|
|
61
|
+
const example = manifest?.example;
|
|
62
|
+
if (typeof example !== "string" || example.length === 0)
|
|
56
63
|
continue;
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
const channels = channelNames.length > 0 ? channelNames.join(", ") : "none";
|
|
60
|
-
const defaultChannel = manifest.defaultChannel !== undefined && manifest.defaultChannel.length > 0 ? manifest.defaultChannel : "none";
|
|
61
|
-
const writableBy = (manifest.writableBy ?? []).join(", ") || "none";
|
|
62
|
-
// #note12 — the daughter's usage example (inline) + a doc-link to its fuller
|
|
63
|
-
// documentation when the manifest ships it (optional; in-tree schemes have none
|
|
64
|
-
// yet, so the link lights up the day plurnk-schemes adds `documentation`, exactly
|
|
65
|
-
// as execs do today). The doc's token cost rides the manifest entry it materializes.
|
|
66
|
-
const example = typeof manifest.example === "string" && manifest.example.length > 0 ? `\nExample: ${manifest.example}` : "";
|
|
67
|
-
const docLink = typeof manifest.documentation === "string" && manifest.documentation.length > 0 ? `\nDocs: plurnk://docs/${name}.md` : "";
|
|
68
|
-
sections.push(`### \`${name}:///\`\n${cls.teach}\nChannels: ${channels} (default: ${defaultChannel}). Writable by: ${writableBy}.${example}${docLink}`);
|
|
64
|
+
const docLink = typeof manifest?.documentation === "string" && manifest.documentation.length > 0 ? ` (docs: plurnk://docs/${name}.md)` : "";
|
|
65
|
+
lines.push(`* ${name}:/// ${example}${docLink}`);
|
|
69
66
|
}
|
|
70
|
-
return
|
|
67
|
+
return lines.join("\n");
|
|
71
68
|
}
|
|
72
69
|
// #note12 — schemes that ship a `documentation` string, for materialization at
|
|
73
70
|
// plurnk:///docs/<name>.md. Optional + currently none in-tree; future-proofs the link.
|
|
@@ -113,8 +110,12 @@ export default class SchemeRegistry {
|
|
|
113
110
|
const mod = await import(__rewriteRelativeImportExtension(packageName));
|
|
114
111
|
this.register(name, new mod.default());
|
|
115
112
|
this.#external.add(name);
|
|
113
|
+
this.#attributions.push(...PluginAttribution.read(packageName)); // #249 — fail-hard if it claims @plurnk/
|
|
116
114
|
}
|
|
117
115
|
}
|
|
116
|
+
// #249 — declared attribution tags of the discovered external schemes (opaque; the
|
|
117
|
+
// engine unions these across plugin families onto the generate() `attributions` wire).
|
|
118
|
+
attributions() { return [...this.#attributions]; }
|
|
118
119
|
// Active set under the given loop flags (SPEC §engine-rails). Delegates to
|
|
119
120
|
// the in-tree ResolveForLoop utility.
|
|
120
121
|
resolveForLoop(flags) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemeRegistry.js","sourceRoot":"","sources":["../../src/core/SchemeRegistry.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,MAA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IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,yCAAyC;QAC9G,CAAC;IACL,CAAC;IAED,mFAAmF;IACnF,uFAAuF;IACvF,YAAY,KAAe,OAAO,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAE5D,2EAA2E;IAC3E,sCAAsC;IACtC,cAAc,CAAC,KAAgB;QAC3B,OAAO,cAAc,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAChE,CAAC;CACJ"}
|
package/dist/core/fork.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fork.d.ts","sourceRoot":"","sources":["../../src/core/fork.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,EAAE,EAAc,MAAM,SAAS,CAAC;AAE9C,MAAM,CAAC,OAAO,OAAO,IAAI;WACR,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"fork.d.ts","sourceRoot":"","sources":["../../src/core/fork.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,EAAE,EAAc,MAAM,SAAS,CAAC;AAE9C,MAAM,CAAC,OAAO,OAAO,IAAI;WACR,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CA6CjF"}
|
package/dist/core/fork.js
CHANGED
|
@@ -31,7 +31,14 @@ export default class Fork {
|
|
|
31
31
|
const turns = await db.fork_get_turns.all({ run_id: parentRunId });
|
|
32
32
|
const turnMap = new Map();
|
|
33
33
|
for (const { id, loop_id, ...rest } of turns) {
|
|
34
|
-
|
|
34
|
+
// #254 — a fork inherits the parent's log for context but spends no new money:
|
|
35
|
+
// the copied turns are history, not fresh generations. Zero their usage so the
|
|
36
|
+
// cost-rollup triggers add nothing — the session total stays true lifetime spend
|
|
37
|
+
// (no double-count) and the branch's cost_pico accrues only what IT generates.
|
|
38
|
+
const nt = await db.fork_insert_turn.get({
|
|
39
|
+
...rest, usage_prompt: 0, usage_completion: 0, usage_cached: 0, usage_cost_pico: 0,
|
|
40
|
+
loop_id: loopMap.get(loop_id),
|
|
41
|
+
});
|
|
35
42
|
if (nt === undefined)
|
|
36
43
|
throw new Error("fork: turn insert returned no row");
|
|
37
44
|
turnMap.set(id, nt.id);
|
package/dist/core/fork.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fork.js","sourceRoot":"","sources":["../../src/core/fork.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,EAAE;AACF,iFAAiF;AACjF,+EAA+E;AAC/E,gFAAgF;AAChF,6EAA6E;AAC7E,oFAAoF;AACpF,2EAA2E;AAI3E,MAAM,CAAC,OAAO,OAAO,IAAI;IACrB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAM,EAAE,WAAmB,EAAE,IAAa;QACxD,MAAM,MAAM,GAAG,MAAO,EAAE,CAAC,YAA2B,CAAC,GAAG,CAAuD,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;QACpI,IAAI,MAAM,KAAK,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,aAAa,WAAW,YAAY,CAAC,CAAC;QAEhF,sFAAsF;QACtF,MAAM,MAAM,GAAG,MAAO,EAAE,CAAC,eAA8B,CAAC,GAAG,CAAiB;YACxE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,IAAI,GAAG,MAAM,CAAC,IAAI,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM;SACxH,CAAC,CAAC;QACH,IAAI,MAAM,KAAK,SAAS;YAA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E,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACxJ,CAAC;QAED,OAAO,WAAW,CAAC;IACvB,CAAC;CACJ"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
-- Fork a run: deep-copy its log into a NEW run in the SAME session (SPEC §machine-processes —
|
|
2
|
+
-- branch the log, share the world). loops → turns → entries are copied with their
|
|
3
|
+
-- fold-state (expanded) and attribution (origin/source) intact; only the run/loop/
|
|
4
|
+
-- turn ids are remapped. Nothing of the world is copied (§machine-processes-fork-shares-the-world) — the session's entries and
|
|
5
|
+
-- overlay are shared. The §env-delta reconciliation snapshot (run_watermarks) is NOT
|
|
6
|
+
-- copied; the branch first-sights its world like any fresh run.
|
|
7
|
+
|
|
8
|
+
-- PREP: fork_get_run
|
|
9
|
+
SELECT session_id, name, origin FROM runs WHERE id = $id;
|
|
10
|
+
|
|
11
|
+
-- PREP: fork_insert_run
|
|
12
|
+
-- A new run in the parent's session; lineage recorded via parent_run_id (§lifecycle-terms).
|
|
13
|
+
INSERT INTO runs (session_id, name, parent_run_id, origin)
|
|
14
|
+
VALUES ($session_id, $name, $parent_run_id, $origin)
|
|
15
|
+
RETURNING id;
|
|
16
|
+
|
|
17
|
+
-- PREP: fork_get_loops
|
|
18
|
+
SELECT id, sequence, status, prompt, flags
|
|
19
|
+
FROM loops WHERE run_id = $run_id ORDER BY id;
|
|
20
|
+
|
|
21
|
+
-- PREP: fork_insert_loop
|
|
22
|
+
INSERT INTO loops (run_id, sequence, status, prompt, flags)
|
|
23
|
+
VALUES ($run_id, $sequence, $status, $prompt, $flags)
|
|
24
|
+
RETURNING id;
|
|
25
|
+
|
|
26
|
+
-- PREP: fork_get_turns
|
|
27
|
+
-- All turns across the run's loops, in order — loop_id is remapped by the caller.
|
|
28
|
+
SELECT t.id, t.loop_id, t.sequence, t.timestamp, t.status,
|
|
29
|
+
t.usage_prompt, t.usage_completion, t.usage_cached, t.usage_cost_pico,
|
|
30
|
+
t.packet, t.finish_reason, t.model
|
|
31
|
+
FROM turns t JOIN loops l ON l.id = t.loop_id
|
|
32
|
+
WHERE l.run_id = $run_id ORDER BY t.id;
|
|
33
|
+
|
|
34
|
+
-- PREP: fork_insert_turn
|
|
35
|
+
INSERT INTO turns (loop_id, sequence, timestamp, status, usage_prompt, usage_completion, usage_cached, usage_cost_pico, packet, finish_reason, model)
|
|
36
|
+
VALUES ($loop_id, $sequence, $timestamp, $status, $usage_prompt, $usage_completion, $usage_cached, $usage_cost_pico, $packet, $finish_reason, $model)
|
|
37
|
+
RETURNING id;
|
|
38
|
+
|
|
39
|
+
-- PREP: fork_get_log_entries
|
|
40
|
+
-- Everything but the row id and run_id (run_id is the branch's; loop_id/turn_id are
|
|
41
|
+
-- remapped by the caller). origin/source (attribution) and expanded (fold-state) ride along. §machine-processes-fork-copies-the-log
|
|
42
|
+
SELECT loop_id, turn_id, sequence, at, origin, source, op, suffix, signal,
|
|
43
|
+
scheme, username, password, hostname, port, pathname, params, fragment,
|
|
44
|
+
lineMarker, tx, mimetype_tx, rx, mimetype_rx, status_rx, tokens,
|
|
45
|
+
state, outcome, attrs, expanded
|
|
46
|
+
FROM log_entries WHERE run_id = $run_id ORDER BY id;
|
|
47
|
+
|
|
48
|
+
-- PREP: fork_insert_log_entry
|
|
49
|
+
INSERT INTO log_entries (run_id, loop_id, turn_id, sequence, at, origin, source, op, suffix, signal, scheme, username, password, hostname, port, pathname, params, fragment, lineMarker, tx, mimetype_tx, rx, mimetype_rx, status_rx, tokens, state, outcome, attrs, expanded)
|
|
50
|
+
VALUES ($run_id, $loop_id, $turn_id, $sequence, $at, $origin, $source, $op, $suffix, $signal, $scheme, $username, $password, $hostname, $port, $pathname, $params, $fragment, $lineMarker, $tx, $mimetype_tx, $rx, $mimetype_rx, $status_rx, $tokens, $state, $outcome, $attrs, $expanded);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-attribution.d.ts","sourceRoot":"","sources":["../../src/core/plugin-attribution.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,OAAO,OAAO,iBAAiB;IAIlC,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE;IAkB7D,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE;CAS7C"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// #249 — plugin attribution. A plugin declares an opaque tag in its package.json
|
|
2
|
+
// (plurnk.attribution: string | string[]) that rides the generate() attributions wire.
|
|
3
|
+
// @plurnk/ is reserved: only a @plurnk/-scoped package may declare a @plurnk/ tag.
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
const RESERVED_PREFIX = "@plurnk/";
|
|
6
|
+
export default class PluginAttribution {
|
|
7
|
+
// Normalize a raw `plurnk.attribution` value to a tag list AND enforce the reservation.
|
|
8
|
+
// Pure (no I/O) so the contract is unit-testable. A plugin claiming the reserved
|
|
9
|
+
// namespace is a fail-hard contract violation, not a silently-dropped tag.
|
|
10
|
+
static normalize(raw, packageName) {
|
|
11
|
+
if (raw === undefined || raw === null)
|
|
12
|
+
return [];
|
|
13
|
+
const tags = Array.isArray(raw) ? raw : [raw];
|
|
14
|
+
const firstParty = packageName.startsWith(RESERVED_PREFIX);
|
|
15
|
+
const out = [];
|
|
16
|
+
for (const tag of tags) {
|
|
17
|
+
if (typeof tag !== "string" || tag.length === 0) {
|
|
18
|
+
throw new Error(`plugin '${packageName}': plurnk.attribution must be a non-empty string or string[]`);
|
|
19
|
+
}
|
|
20
|
+
if (tag.startsWith(RESERVED_PREFIX) && !firstParty) {
|
|
21
|
+
throw new Error(`plugin '${packageName}': '${RESERVED_PREFIX}' is reserved for ${RESERVED_PREFIX}-scoped packages — '${packageName}' cannot claim '${tag}'`);
|
|
22
|
+
}
|
|
23
|
+
out.push(tag);
|
|
24
|
+
}
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
// [] when the manifest can't be resolved (strict `exports` with no `./package.json`).
|
|
28
|
+
static read(packageName) {
|
|
29
|
+
let manifest;
|
|
30
|
+
try {
|
|
31
|
+
manifest = createRequire(import.meta.url)(`${packageName}/package.json`);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
return PluginAttribution.normalize(manifest?.plurnk?.attribution, packageName);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=plugin-attribution.js.map
|