@gentbajko/slopify 4.3.3 → 4.3.4
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.
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Slopify 4.3.4
|
|
2
|
+
|
|
3
|
+
Released 10 November 2026.
|
|
4
|
+
|
|
5
|
+
The plan a run is made from is worked out once and shared, instead of again for every step that asks.
|
|
6
|
+
|
|
7
|
+
## A run no longer blocks the app
|
|
8
|
+
|
|
9
|
+
- **Ten places ask the project what it is making, and each worked it out from scratch** — the whole revision read back off disk, a check for every output and every picture, the article read again, every step derived from the narration up. With twelve pictures that was a few dozen times across a run and nobody saw it. With 240 it ran into the tens of thousands, one core went to nothing but that, and the app stopped answering.
|
|
10
|
+
- **It is now worked out once and handed to every caller that asks** while nothing it was made from has changed.
|
|
11
|
+
- **It is thrown away the moment anything does change** — any write to your data, a picture or an output whose file is no longer on disk, or a different model catalogue. The check is deliberately blunt, so it can only ever work the plan out more often than needed, never hand back one that has gone stale.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { catalogueSchema } from "../../catalog/schema.js";
|
|
4
|
+
import { fingerprint } from "../../kernel/runner/work.js";
|
|
4
5
|
import { getRevisionView, readyOutput, withEarlierJoins } from "../revisions/view.js";
|
|
5
6
|
import { outputPath } from "../storage/layout.js";
|
|
6
7
|
import { referencedAssetsAvailable, retainedNarrationPieces } from "./narration-history.js";
|
|
@@ -51,7 +52,62 @@ export function workLlm(db, workId, choice, label) {
|
|
|
51
52
|
...call,
|
|
52
53
|
});
|
|
53
54
|
}
|
|
55
|
+
// Ten places ask for the plan, and each one used to derive it from scratch: the article read
|
|
56
|
+
// back off disk, every recipe rebuilt from the narration up. At twelve images that happened a
|
|
57
|
+
// few dozen times over a run; at 240 it happened tens of thousands of times and the server
|
|
58
|
+
// spent its whole time planning instead of answering.
|
|
59
|
+
//
|
|
60
|
+
// The plan is kept and handed back while nothing in the database has changed, which SQLite
|
|
61
|
+
// counts for us. That is a blunt test on purpose: a write anywhere - another project, another
|
|
62
|
+
// revision - throws the plan away and it is derived again. It can never hand back a plan from
|
|
63
|
+
// after a write it has not seen, which is the only direction that would matter, because a
|
|
64
|
+
// stale plan would start the wrong work.
|
|
65
|
+
// Per database, never shared between them: two of them (the app and a mirror, or two tests)
|
|
66
|
+
// can hold the same project under the same id, and one's plan is not the other's.
|
|
67
|
+
const kept = new WeakMap();
|
|
68
|
+
const changeCount = z.object({ changes: z.number() });
|
|
69
|
+
function writesSoFar(deps) {
|
|
70
|
+
return changeCount.parse(deps.db.prepare("SELECT total_changes() AS changes").get()).changes;
|
|
71
|
+
}
|
|
72
|
+
// Two catalogues that differ give different plans, so the catalogue belongs in the key. Its
|
|
73
|
+
// date and shape identify it without hashing the whole of it on every call.
|
|
74
|
+
function catalogueMark(catalogue) {
|
|
75
|
+
return [
|
|
76
|
+
catalogue.schemaVersion,
|
|
77
|
+
catalogue.updatedAt,
|
|
78
|
+
catalogue.llm.length,
|
|
79
|
+
catalogue.image?.length ?? 0,
|
|
80
|
+
Object.keys(catalogue.providers).length,
|
|
81
|
+
].join("/");
|
|
82
|
+
}
|
|
83
|
+
// What the plan was derived from, beyond the database: whether each output and piece is
|
|
84
|
+
// selected and whether its file is still on disk. A file deleted by hand is no write at all,
|
|
85
|
+
// so `total_changes()` would never notice it, and the plan would go on reusing work whose
|
|
86
|
+
// output is gone. Walking a few hundred rows is nothing beside deriving the plan again.
|
|
87
|
+
function viewMark(view) {
|
|
88
|
+
const rows = [String(view.articleMarkdown?.length ?? -1)];
|
|
89
|
+
for (const row of view.outputs)
|
|
90
|
+
rows.push(`o${row.recordId}:${row.selected ? 1 : 0}${row.available ? 1 : 0}:${row.fingerprint}`);
|
|
91
|
+
for (const row of view.pieces)
|
|
92
|
+
rows.push(`p${row.recordId}:${row.selected ? 1 : 0}${row.available ? 1 : 0}:${row.fingerprint}`);
|
|
93
|
+
return fingerprint(rows.join("\n"));
|
|
94
|
+
}
|
|
54
95
|
export function executionPlan(deps, view, catalogue) {
|
|
96
|
+
const key = `${view.revision.projectId}/${view.revision.id}/${catalogueMark(catalogue)}/${viewMark(view)}`;
|
|
97
|
+
const changes = writesSoFar(deps);
|
|
98
|
+
const forDb = kept.get(deps.db) ?? new Map();
|
|
99
|
+
kept.set(deps.db, forDb);
|
|
100
|
+
const held = forDb.get(key);
|
|
101
|
+
if (held !== undefined && held.changes === changes)
|
|
102
|
+
return held.plan;
|
|
103
|
+
const plan = derivePlan(deps, view, catalogue);
|
|
104
|
+
// A cache, not a store: a handful of revisions is all a run needs at once.
|
|
105
|
+
if (forDb.size > 8)
|
|
106
|
+
forDb.clear();
|
|
107
|
+
forDb.set(key, { changes, plan });
|
|
108
|
+
return plan;
|
|
109
|
+
}
|
|
110
|
+
function derivePlan(deps, view, catalogue) {
|
|
55
111
|
const textOutput = (role) => {
|
|
56
112
|
const row = readyOutput(view, { role });
|
|
57
113
|
return row === undefined
|