@volter/supercode-orchestrator 0.5.158 → 0.5.159
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/board/cli.mjs +2 -2
- package/board/store.mjs +26 -0
- package/package.json +1 -1
package/board/cli.mjs
CHANGED
|
@@ -26,7 +26,7 @@ import * as slowLog from '@volter/supercode-harness-sdk/slow-log';
|
|
|
26
26
|
import { basename, dirname, join, resolve } from 'node:path';
|
|
27
27
|
import { fileURLToPath } from 'node:url';
|
|
28
28
|
import { homedir, tmpdir, userInfo } from 'node:os';
|
|
29
|
-
import { actorOf, heldConfigWatched, heldDocumentsChanged, heldDocumentsWatched, holdBoards, retireHeldBoards, releaseHeldBoards, publishMarked, view, backingPaths, layOut, backingOf, boardExists, boardPath, briefPath, DEFAULT_BOARD, event, json, listBoards, logsDir, now, openBoard, setActor, setPrincipal, principalOf, isCaller, tx } from './store.mjs';
|
|
29
|
+
import { actorOf, CALLER_RUN_ADDRESS, heldConfigWatched, heldDocumentsChanged, heldDocumentsWatched, holdBoards, retireHeldBoards, releaseHeldBoards, publishMarked, view, backingPaths, layOut, backingOf, boardExists, boardPath, briefPath, DEFAULT_BOARD, event, json, listBoards, logsDir, now, openBoard, setActor, setPrincipal, principalOf, isCaller, tx } from './store.mjs';
|
|
30
30
|
import { isLocalWorkspace } from './workspace.mjs';
|
|
31
31
|
import { openZtrackBoard } from './ztrack.mjs';
|
|
32
32
|
import * as engine from './engine.mjs';
|
|
@@ -357,7 +357,7 @@ export async function runVerb(argv) {
|
|
|
357
357
|
await readAgentMains(root);
|
|
358
358
|
const sid = listing && !args.mine ? null : callerSession();
|
|
359
359
|
// what this command records is the calling session's act (its address, as its subscriptions name it)
|
|
360
|
-
current().recorded = sid && boardExists(root, slug) ? withBoard((b) => b.db.prepare(
|
|
360
|
+
current().recorded = sid && boardExists(root, slug) ? withBoard((b) => b.db.prepare(CALLER_RUN_ADDRESS).get(sid)?.address) ?? null : null;
|
|
361
361
|
if (sid) setActor(callerAddress());
|
|
362
362
|
setPrincipal(await callerPrincipal(root, sid, { teams: !sid && !READS.has(verb) }));
|
|
363
363
|
// the dispatcher as the owner holds it, said once per call (owner-health.mjs; nothing is read for it)
|
package/board/store.mjs
CHANGED
|
@@ -143,6 +143,14 @@ export function listBoards(root) {
|
|
|
143
143
|
return out;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
+
// The run a session's own verb is recorded against, by the session the dispatcher wrote in the run's metadata: asked on
|
|
147
|
+
// every verb a session runs (cli.mjs). The lookup and its index are written from the same two expressions, because
|
|
148
|
+
// SQLite uses an expression index only for a statement that writes the expression the same way.
|
|
149
|
+
const RUN_SESSION = "json_extract(metadata, '$.supercode.session_id')";
|
|
150
|
+
const RUN_ADDRESS = "json_extract(metadata, '$.supercode.address')";
|
|
151
|
+
export const CALLER_RUN_ADDRESS = `SELECT ${RUN_ADDRESS} AS address FROM task_runs WHERE ${RUN_SESSION} = ? ORDER BY id DESC LIMIT 1`;
|
|
152
|
+
const RUN_SESSION_INDEX = 'idx_runs_supercode_session';
|
|
153
|
+
|
|
146
154
|
/** Hermes's tables on a fresh board, supercode's own table and columns on every one. */
|
|
147
155
|
export function layOut(db, { fresh }) {
|
|
148
156
|
if (fresh) db.exec(SCHEMA);
|
|
@@ -154,6 +162,24 @@ export function layOut(db, { fresh }) {
|
|
|
154
162
|
// each read walked every card's row. Laid out here, after the column it names exists on a store of any age and before
|
|
155
163
|
// any statement is prepared; no statement names it, so a store without it is only slower.
|
|
156
164
|
db.exec('CREATE INDEX IF NOT EXISTS idx_supercode_cards_subtask_of ON supercode_cards(subtask_of)');
|
|
165
|
+
// The calling session's run (CALLER_RUN_ADDRESS): without this index each lookup read every run's whole metadata,
|
|
166
|
+
// overflow pages included. `id` keeps a session's runs in the order the lookup asks for, and the address makes the
|
|
167
|
+
// index answer the lookup without reading the run. No statement names it, so a store without it is only slower, and a
|
|
168
|
+
// release that does not know it keeps it current like any other index. Its first creation reads `task_runs` once.
|
|
169
|
+
// A run whose metadata SQLite cannot read as JSON refuses the creation: the board opens without the index, says which
|
|
170
|
+
// rows to look for, and tries again on its next open. Once the index is there, SQLite refuses a write of such
|
|
171
|
+
// metadata to a run.
|
|
172
|
+
if (db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'task_runs'").get()) {
|
|
173
|
+
try { db.exec(`CREATE INDEX IF NOT EXISTS ${RUN_SESSION_INDEX} ON task_runs(${RUN_SESSION}, id, ${RUN_ADDRESS})`); }
|
|
174
|
+
catch (error) {
|
|
175
|
+
if (contention(error)) throw error;
|
|
176
|
+
const said = current().said;
|
|
177
|
+
if (!said.has(RUN_SESSION_INDEX)) {
|
|
178
|
+
said.add(RUN_SESSION_INDEX);
|
|
179
|
+
current().err(`board: warning: index ${RUN_SESSION_INDEX} on task_runs was not created (${error.message}); the board is open without it and each session's verb reads every run. The runs that refuse it: SELECT id FROM task_runs WHERE metadata IS NOT NULL AND NOT json_valid(metadata, 6)\n`);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
157
183
|
const effectColumns = new Set(db.prepare('PRAGMA table_info(supercode_effects)').all().map((c) => c.name));
|
|
158
184
|
for (const [column, type] of Object.entries(EFFECT_COLUMNS)) if (!effectColumns.has(column)) db.exec(`ALTER TABLE supercode_effects ADD COLUMN ${column} ${type}`);
|
|
159
185
|
// what changed is marked by the store itself, whoever writes it (published.mjs)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volter/supercode-orchestrator",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.159",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The orchestrator runtime over the Volter Harness ontology: one typed operational model whose folder is its serialization, read and written through the harness orchestration doors (docs/ORCHESTRATOR-IR.md)",
|
|
6
6
|
"exports": {
|