copilotz 1.0.0-rc.30 → 1.0.0-rc.31
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/CHANGELOG.md +10 -1
- package/README.md +7 -4
- package/package.json +1 -1
- package/plugins/compute/computers/program/version.d.ts +1 -1
- package/plugins/compute/computers/program/version.js +1 -1
- package/plugins/compute/computers/resources/downloads.js +1 -1
- package/plugins/work/boards/actions/create-card.js +0 -2
- package/runtime/define.d.ts +5 -0
- package/runtime/owner.js +71 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
##
|
|
1
|
+
## 1.0.0-rc.31 — 2026-11-08
|
|
2
|
+
|
|
3
|
+
- **A write the rules refuse in a transaction no longer holds up every write.** Refused before it
|
|
4
|
+
reached its transaction, it left the transaction open, holding the store's writer: the Action's
|
|
5
|
+
failure and every other write in the app waited 30 s, until it was rolled back as idle. Now it
|
|
6
|
+
ends its transaction at once, as an op that fails in one does: it rolls back, and its later ops
|
|
7
|
+
fail ("The transaction is closed."), even when the error is caught. Code that caught a failed op
|
|
8
|
+
and wrote on used to commit what came after it. A transaction with no op for 5 s (30 s before)
|
|
9
|
+
rolls back, and `copilotz.transaction.duration` measures how long each one held the writer.
|
|
10
|
+
- **Boards** no longer read a new card back inside its transaction: one round trip less per card.
|
|
2
11
|
|
|
3
12
|
## 1.0.0-rc.30 — 2026-11-08
|
|
4
13
|
|
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ bun add copilotz # Bun
|
|
|
22
22
|
deno add jsr:@copilotz/copilotz # Deno (or `deno add npm:copilotz`)
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
On Deno, name it `copilotz` in `deno.json` (`"copilotz": "jsr:@copilotz/copilotz@^1.0.0-rc.
|
|
25
|
+
On Deno, name it `copilotz` in `deno.json` (`"copilotz": "jsr:@copilotz/copilotz@^1.0.0-rc.31"`),
|
|
26
26
|
and the imports below are the same everywhere. Some pieces need a package of their own, installed
|
|
27
27
|
beside it: `esbuild` to bundle the page's code on Node (`bundle`), `@electric-sql/pglite` for
|
|
28
28
|
PostgreSQL in the process, and `@types/react` for the front ends' types.
|
|
@@ -631,7 +631,7 @@ and an app serves it from there by default:
|
|
|
631
631
|
import { computerDownloads } from "copilotz/plugins/compute/downloads";
|
|
632
632
|
|
|
633
633
|
plugins: [...plugins, await computerDownloads()], // this Copilotz's release
|
|
634
|
-
plugins: [...plugins, await computerDownloads({ dir: "dist/computer/1.0.0-rc.
|
|
634
|
+
plugins: [...plugins, await computerDownloads({ dir: "dist/computer/1.0.0-rc.31" })], // its own: /computer/download/
|
|
635
635
|
plugins: [...plugins, await computerDownloads({ url: "https://downloads.example.com/computer/" })], // or elsewhere
|
|
636
636
|
```
|
|
637
637
|
|
|
@@ -1125,7 +1125,8 @@ add: each plugin instruments itself.
|
|
|
1125
1125
|
to `createRuntime({ metrics })` (and to remote executors); plugin code records with `ctx.metrics`.
|
|
1126
1126
|
Recorded:
|
|
1127
1127
|
- the runtime: `copilotz.job.duration` (by kind, name, outcome), `copilotz.op.duration` and
|
|
1128
|
-
`copilotz.op.roundtrip`, `copilotz.commit.duration`, `copilotz.
|
|
1128
|
+
`copilotz.op.roundtrip`, `copilotz.commit.duration`, `copilotz.transaction.duration` (how long
|
|
1129
|
+
each transaction held open kept the writer, by outcome), `copilotz.events`,
|
|
1129
1130
|
`copilotz.processor.lag`, `copilotz.executors`, `copilotz.cache.reads`;
|
|
1130
1131
|
- model calls, by OpenTelemetry's GenAI conventions: `gen_ai.client.operation.duration`,
|
|
1131
1132
|
`gen_ai.client.token.usage`, and `copilotz.llm.time_to_first_token`;
|
|
@@ -1734,7 +1735,9 @@ Copilotz runs on Node (first), Deno and Bun, and is built for Cloudflare Workers
|
|
|
1734
1735
|
is the record already kept, so sending twice is safe.
|
|
1735
1736
|
- **One writer per store:** each write auto-commits as one short transaction, and
|
|
1736
1737
|
`ctx.transaction(tx => …)` makes several writes and their events atomic. Slow I/O, such as model
|
|
1737
|
-
calls, never holds the writer.
|
|
1738
|
+
calls, never holds the writer. An op in a transaction that fails, a write the rules refuse
|
|
1739
|
+
included, ends it: it rolls back, and its later ops fail, even when the error is caught. One with
|
|
1740
|
+
no op for 5 seconds rolls back too.
|
|
1738
1741
|
- **Stream-first:** committed events and live frames go to subscribers immediately, and observed
|
|
1739
1742
|
Views run again as soon as what they read commits.
|
|
1740
1743
|
- **Who acts:** an outside call may bind an actor (`runtime.call(action, input, { actor })`, and
|
package/package.json
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** The computer program's version, as `computer.info` and `--version` say it, and its builds are named. */
|
|
2
|
-
export declare const VERSION = "1.0.0-rc.
|
|
2
|
+
export declare const VERSION = "1.0.0-rc.31";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** The computer program's version, as `computer.info` and `--version` say it, and its builds are named. */
|
|
2
|
-
export const VERSION = "1.0.0-rc.
|
|
2
|
+
export const VERSION = "1.0.0-rc.31";
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* ```ts
|
|
16
16
|
* plugins: [...plugins, await computerDownloads()]
|
|
17
|
-
* plugins: [...plugins, await computerDownloads({ dir: "dist/computer/1.0.0-rc.
|
|
17
|
+
* plugins: [...plugins, await computerDownloads({ dir: "dist/computer/1.0.0-rc.31" })]
|
|
18
18
|
* plugins: [...plugins, await computerDownloads({ url: "https://downloads.example.com/computer/" })]
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
@@ -69,8 +69,6 @@ export const createCardAction = defineAction({
|
|
|
69
69
|
by: keyOf(ctx.actor),
|
|
70
70
|
at,
|
|
71
71
|
});
|
|
72
|
-
// Read back before the commit: an insert the rules refuse fails here, closing the commit.
|
|
73
|
-
await tx.db.collection("card").findOne({ _id: card });
|
|
74
72
|
return { column, order, board };
|
|
75
73
|
}).catch(said());
|
|
76
74
|
return {
|
package/runtime/define.d.ts
CHANGED
|
@@ -35,6 +35,11 @@ export type Graph = {
|
|
|
35
35
|
* are sent with the next op or the commit, so an error from one surfaces
|
|
36
36
|
* there (it still aborts the whole transaction). Work made only of them is
|
|
37
37
|
* one call, which a store may run as a single statement.
|
|
38
|
+
*
|
|
39
|
+
* An op that fails, a write the rules refuse included, ends the transaction:
|
|
40
|
+
* it rolls back, and its later ops fail ("The transaction is closed."), even
|
|
41
|
+
* when the error is caught. It holds the store's writer, so keep slow work out
|
|
42
|
+
* of it: one with no op for 5 seconds rolls back too.
|
|
38
43
|
*/
|
|
39
44
|
export type TransactionScope = {
|
|
40
45
|
db: {
|
package/runtime/owner.js
CHANGED
|
@@ -28,8 +28,12 @@ import { canonical, checked, compile, events, fingerprint, invalid, json, merge,
|
|
|
28
28
|
import { decode, DISPATCH, encode, failure, lines, OP, raise, RUN, } from "./wire.js";
|
|
29
29
|
const SYSTEM = "sys.";
|
|
30
30
|
const WRITES = ["insert", "update", "replace", "delete"];
|
|
31
|
-
/**
|
|
32
|
-
|
|
31
|
+
/**
|
|
32
|
+
* A held transaction with no op for this long is rolled back (its executor
|
|
33
|
+
* stuck, or gone unnoticed). Short: it holds the store's writer, the app's
|
|
34
|
+
* only one, and every other write waits for it.
|
|
35
|
+
*/
|
|
36
|
+
const HOLD_IDLE_MS = 5_000;
|
|
33
37
|
/** An idle owner saves Processor cursors this long after their last advance. */
|
|
34
38
|
const CURSOR_FLUSH_MS = 200;
|
|
35
39
|
const DAY = 86_400_000;
|
|
@@ -111,6 +115,10 @@ export async function createOwner(options) {
|
|
|
111
115
|
unit: "ms",
|
|
112
116
|
description: "Commits to the store",
|
|
113
117
|
}),
|
|
118
|
+
transactions: metrics.histogram("copilotz.transaction.duration", {
|
|
119
|
+
unit: "ms",
|
|
120
|
+
description: "Transactions executors held open: how long each held the store's writer",
|
|
121
|
+
}),
|
|
114
122
|
events: metrics.counter("copilotz.events", { description: "Events committed" }),
|
|
115
123
|
lag: metrics.gauge("copilotz.processor.lag", {
|
|
116
124
|
unit: "{event}",
|
|
@@ -829,10 +837,33 @@ export async function createOwner(options) {
|
|
|
829
837
|
};
|
|
830
838
|
const held = new Map();
|
|
831
839
|
const heldBy = new Map();
|
|
840
|
+
/**
|
|
841
|
+
* A running job's transactions that ended under it, not by its own `end`: an
|
|
842
|
+
* op in one failed or was refused, or it sat idle. They stay closed to it,
|
|
843
|
+
* so its next op can't begin another by the same id, without what was
|
|
844
|
+
* rolled back.
|
|
845
|
+
*/
|
|
846
|
+
const endedBy = new Map();
|
|
847
|
+
const ended = (job, id) => {
|
|
848
|
+
if (!pinned.has(job))
|
|
849
|
+
return;
|
|
850
|
+
if (!endedBy.has(job))
|
|
851
|
+
endedBy.set(job, new Set());
|
|
852
|
+
endedBy.get(job).add(id);
|
|
853
|
+
};
|
|
854
|
+
/** Ends a job's transaction under it, a request in it refused: rolled back, closed to it. */
|
|
855
|
+
const refuse = async (job, id) => {
|
|
856
|
+
ended(job, id);
|
|
857
|
+
const transaction = held.get(id);
|
|
858
|
+
if (transaction?.job !== job)
|
|
859
|
+
return;
|
|
860
|
+
await transaction.send({ tx: id, ops: [], end: "abort" }).catch(() => { });
|
|
861
|
+
};
|
|
832
862
|
const hold = (id, job) => {
|
|
833
863
|
const inbox = [];
|
|
834
864
|
let wake;
|
|
835
865
|
let closed = false;
|
|
866
|
+
let idle = false;
|
|
836
867
|
let ending;
|
|
837
868
|
let timer;
|
|
838
869
|
const send = (request) => {
|
|
@@ -842,7 +873,10 @@ export async function createOwner(options) {
|
|
|
842
873
|
if (request.end)
|
|
843
874
|
closed = true;
|
|
844
875
|
else {
|
|
845
|
-
timer = setTimeout(() =>
|
|
876
|
+
timer = setTimeout(() => {
|
|
877
|
+
idle = true;
|
|
878
|
+
send({ tx: id, ops: [], end: "abort" }).catch(() => { });
|
|
879
|
+
}, HOLD_IDLE_MS);
|
|
846
880
|
}
|
|
847
881
|
const reply = Promise.withResolvers();
|
|
848
882
|
inbox.push({ request, reply });
|
|
@@ -855,7 +889,14 @@ export async function createOwner(options) {
|
|
|
855
889
|
return inbox.shift();
|
|
856
890
|
};
|
|
857
891
|
const later = { ops: [] };
|
|
892
|
+
// How long it held the store's writer: from when the store began it to its commit or rollback.
|
|
893
|
+
let began;
|
|
894
|
+
const measured = (outcome) => {
|
|
895
|
+
if (began !== undefined)
|
|
896
|
+
measure.transactions.record(performance.now() - began, { outcome });
|
|
897
|
+
};
|
|
858
898
|
commit(async (tx, seen) => {
|
|
899
|
+
began = performance.now();
|
|
859
900
|
for (;;) {
|
|
860
901
|
const { request, reply } = await next();
|
|
861
902
|
let value;
|
|
@@ -882,8 +923,15 @@ export async function createOwner(options) {
|
|
|
882
923
|
throw aborted;
|
|
883
924
|
return;
|
|
884
925
|
}
|
|
885
|
-
}, true, later).then(() =>
|
|
926
|
+
}, true, later).then(() => {
|
|
927
|
+
measured("commit");
|
|
928
|
+
ending.reply.resolve(ending.value);
|
|
929
|
+
}, (error) => {
|
|
886
930
|
closed = true;
|
|
931
|
+
const outcome = error !== aborted ? "error" : idle ? "idle" : "abort";
|
|
932
|
+
measured(outcome);
|
|
933
|
+
if (outcome !== "abort")
|
|
934
|
+
ended(job, id);
|
|
887
935
|
for (const { reply } of inbox.splice(0))
|
|
888
936
|
reply.reject(error);
|
|
889
937
|
if (error === aborted)
|
|
@@ -928,11 +976,22 @@ export async function createOwner(options) {
|
|
|
928
976
|
}
|
|
929
977
|
return disconnect(first.actor);
|
|
930
978
|
}
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
979
|
+
let ops, keep;
|
|
980
|
+
try {
|
|
981
|
+
const lowered = request.ops.map((op) => timers.lower(op, request.actor));
|
|
982
|
+
lowered.forEach(known);
|
|
983
|
+
const guarded = await guard(lowered, request.actor);
|
|
984
|
+
keep = guarded.keep;
|
|
985
|
+
ops = await label(guarded.ops, request.actor, job);
|
|
986
|
+
}
|
|
987
|
+
catch (error) {
|
|
988
|
+
// Refused before it reaches its transaction (by the rules, say), a request ends it, as a
|
|
989
|
+
// failed op in it does: else the transaction would keep the store's writer, and every
|
|
990
|
+
// other write would wait, until it sat idle long enough.
|
|
991
|
+
if ("tx" in request)
|
|
992
|
+
await refuse(job, request.tx);
|
|
993
|
+
throw error;
|
|
994
|
+
}
|
|
936
995
|
const saw = (op, value) => notice(job, request.actor, op, value);
|
|
937
996
|
if (!("tx" in request)) {
|
|
938
997
|
const [first, ...rest] = ops;
|
|
@@ -955,6 +1014,8 @@ export async function createOwner(options) {
|
|
|
955
1014
|
if (!transaction) {
|
|
956
1015
|
if (request.end === "abort")
|
|
957
1016
|
return Promise.resolve(undefined);
|
|
1017
|
+
if (endedBy.get(job)?.has(request.tx))
|
|
1018
|
+
throw invalid("The transaction is closed.");
|
|
958
1019
|
transaction = hold(request.tx, job);
|
|
959
1020
|
}
|
|
960
1021
|
return transaction.send({ ...request, ops, keep, saw });
|
|
@@ -1306,6 +1367,7 @@ export async function createOwner(options) {
|
|
|
1306
1367
|
held.get(id)?.send({ tx: id, ops: [], end: "abort" }).catch(() => { });
|
|
1307
1368
|
}
|
|
1308
1369
|
heldBy.delete(handle.operationId);
|
|
1370
|
+
endedBy.delete(handle.operationId);
|
|
1309
1371
|
labelled.delete(handle.operationId);
|
|
1310
1372
|
pinned.delete(handle.operationId);
|
|
1311
1373
|
}
|