@claudexor/daemon 3.12.2 → 3.12.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.
package/dist/index.d.ts CHANGED
@@ -26,6 +26,7 @@ export * from "./quota-projection.js";
26
26
  export * from "./quota-poll-lanes.js";
27
27
  export { quotaPacerFileStore } from "./quota-poll-pacer.js";
28
28
  export * from "./credential-unusable-ledger.js";
29
+ export * from "./model-substitution-ledger.js";
29
30
  export * from "./project-partitions.js";
30
31
  export * from "./model-operations.js";
31
32
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC"}
package/dist/index.js CHANGED
@@ -26,6 +26,7 @@ export * from "./quota-projection.js";
26
26
  export * from "./quota-poll-lanes.js";
27
27
  export { quotaPacerFileStore } from "./quota-poll-pacer.js";
28
28
  export * from "./credential-unusable-ledger.js";
29
+ export * from "./model-substitution-ledger.js";
29
30
  export * from "./project-partitions.js";
30
31
  export * from "./model-operations.js";
31
32
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,47 @@
1
+ import type { ModelSubstitutionObservation } from "@claudexor/schema";
2
+ /**
3
+ * The daemon's bounded, self-expiring memory of typed model-substitution
4
+ * observations: "this account answered a model operation's request for model M
5
+ * with another model".
6
+ *
7
+ * The vendor state behind it is per account, lasts tens of minutes and is
8
+ * invisible in the quota meter, while the pool's choice is deterministic by
9
+ * headroom — without this memory the caller's next operation lands on the same
10
+ * account. A live observation only ORDERS the pool for that requested model
11
+ * (INV-135); it never excludes a row, never touches a pin or a preferred
12
+ * account, and the engine still performs one generation per operation
13
+ * (INV-014).
14
+ *
15
+ * Deliberately IN-MEMORY, like the `CredentialUnusableLedger` beside it: a
16
+ * restart forgets every mark, so each account rediscovers its own episode at
17
+ * the cost of one operation. A result that arrives after its subject was
18
+ * cleared records a fresh mark, because an observation carries no credential
19
+ * generation; the cost is ordering, never exclusion.
20
+ *
21
+ * Clearing contract:
22
+ * 1. self-expiry — every row is stamped here with the one retention above;
23
+ * 2. NO success-clear: inside an episode the same account still serves the
24
+ * requested model now and then, which would erase the mark within seconds;
25
+ * 3. a credential-generation change voids the verdicts about the changed
26
+ * generation, at the unusable ledger's call sites: a login/logout clears the
27
+ * WHOLE ledger (`noteCredentialChange`), a control-API profile mutation
28
+ * clears PER SUBJECT (`clearSubject`). A secret mutation names no subject
29
+ * here — model operations admit managed-login rows only.
30
+ */
31
+ export declare class ModelSubstitutionLedger {
32
+ private readonly now;
33
+ private rows;
34
+ constructor(now?: () => Date);
35
+ /** Validate and stamp, newest-wins per (subject, requested model). */
36
+ record(value: Omit<ModelSubstitutionObservation, "observed_at" | "expires_at">): void;
37
+ /** Every un-expired observation (the read side of account resolution). */
38
+ live(): readonly ModelSubstitutionObservation[];
39
+ /** Credential generation changed wholesale (login/logout): every verdict
40
+ * about the old generation is void. */
41
+ noteCredentialChange(): void;
42
+ /** ONE account's credential changed (a control-API profile mutation): only
43
+ * ITS verdicts are void, across every requested model. */
44
+ clearSubject(harnessId: string, profileId: string): void;
45
+ private prune;
46
+ }
47
+ //# sourceMappingURL=model-substitution-ledger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-substitution-ledger.d.ts","sourceRoot":"","sources":["../src/model-substitution-ledger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAC;AAWtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,uBAAuB;IAGtB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAFhC,OAAO,CAAC,IAAI,CAAmD;IAE/D,YAA6B,GAAG,GAAE,MAAM,IAAuB,EAAI;IAEnE,sEAAsE;IACtE,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,4BAA4B,EAAE,aAAa,GAAG,YAAY,CAAC,GAAG,IAAI,CAgBpF;IAED,0EAA0E;IAC1E,IAAI,IAAI,SAAS,4BAA4B,EAAE,CAG9C;IAED;2CACuC;IACvC,oBAAoB,IAAI,IAAI,CAE3B;IAED;8DAC0D;IAC1D,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAIvD;IAED,OAAO,CAAC,KAAK;CAMd"}
@@ -0,0 +1,89 @@
1
+ import { ModelSubstitutionObservation as ModelSubstitutionObservationSchema } from "@claudexor/schema";
2
+ /** Observation retention, not a vendor reset time; a false mark costs only ordering. */
3
+ // The requested model is what ranks; what was served instead travels on the
4
+ // result, where the caller reads it. Keeping a second copy here would be a
5
+ // field no reader consults.
6
+ const TTL_MS = 30 * 60_000;
7
+ /** Bounded memory: the ledger holds evidence, not history. */
8
+ const MAX_ROWS = 64;
9
+ /**
10
+ * The daemon's bounded, self-expiring memory of typed model-substitution
11
+ * observations: "this account answered a model operation's request for model M
12
+ * with another model".
13
+ *
14
+ * The vendor state behind it is per account, lasts tens of minutes and is
15
+ * invisible in the quota meter, while the pool's choice is deterministic by
16
+ * headroom — without this memory the caller's next operation lands on the same
17
+ * account. A live observation only ORDERS the pool for that requested model
18
+ * (INV-135); it never excludes a row, never touches a pin or a preferred
19
+ * account, and the engine still performs one generation per operation
20
+ * (INV-014).
21
+ *
22
+ * Deliberately IN-MEMORY, like the `CredentialUnusableLedger` beside it: a
23
+ * restart forgets every mark, so each account rediscovers its own episode at
24
+ * the cost of one operation. A result that arrives after its subject was
25
+ * cleared records a fresh mark, because an observation carries no credential
26
+ * generation; the cost is ordering, never exclusion.
27
+ *
28
+ * Clearing contract:
29
+ * 1. self-expiry — every row is stamped here with the one retention above;
30
+ * 2. NO success-clear: inside an episode the same account still serves the
31
+ * requested model now and then, which would erase the mark within seconds;
32
+ * 3. a credential-generation change voids the verdicts about the changed
33
+ * generation, at the unusable ledger's call sites: a login/logout clears the
34
+ * WHOLE ledger (`noteCredentialChange`), a control-API profile mutation
35
+ * clears PER SUBJECT (`clearSubject`). A secret mutation names no subject
36
+ * here — model operations admit managed-login rows only.
37
+ */
38
+ export class ModelSubstitutionLedger {
39
+ now;
40
+ rows = new Map();
41
+ constructor(now = () => new Date()) {
42
+ this.now = now;
43
+ }
44
+ /** Validate and stamp, newest-wins per (subject, requested model). */
45
+ record(value) {
46
+ const at = this.now().getTime();
47
+ const obs = ModelSubstitutionObservationSchema.parse({
48
+ ...value,
49
+ observed_at: new Date(at).toISOString(),
50
+ expires_at: new Date(at + TTL_MS).toISOString(),
51
+ });
52
+ this.prune();
53
+ if (this.rows.size >= MAX_ROWS && !this.rows.has(key(obs))) {
54
+ // Bounded: drop the earliest-expiring row rather than refusing evidence.
55
+ const earliest = [...this.rows.entries()].reduce((a, b) => Date.parse(a[1].expires_at) <= Date.parse(b[1].expires_at) ? a : b);
56
+ this.rows.delete(earliest[0]);
57
+ }
58
+ this.rows.set(key(obs), obs);
59
+ }
60
+ /** Every un-expired observation (the read side of account resolution). */
61
+ live() {
62
+ this.prune();
63
+ return [...this.rows.values()];
64
+ }
65
+ /** Credential generation changed wholesale (login/logout): every verdict
66
+ * about the old generation is void. */
67
+ noteCredentialChange() {
68
+ this.rows.clear();
69
+ }
70
+ /** ONE account's credential changed (a control-API profile mutation): only
71
+ * ITS verdicts are void, across every requested model. */
72
+ clearSubject(harnessId, profileId) {
73
+ for (const [k, obs] of this.rows) {
74
+ if (obs.harness_id === harnessId && obs.profile_id === profileId)
75
+ this.rows.delete(k);
76
+ }
77
+ }
78
+ prune() {
79
+ const now = this.now().getTime();
80
+ for (const [k, obs] of this.rows) {
81
+ if (Date.parse(obs.expires_at) <= now)
82
+ this.rows.delete(k);
83
+ }
84
+ }
85
+ }
86
+ function key(obs) {
87
+ return [obs.harness_id, obs.profile_id, obs.requested_model].join("\0");
88
+ }
89
+ //# sourceMappingURL=model-substitution-ledger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-substitution-ledger.js","sourceRoot":"","sources":["../src/model-substitution-ledger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,IAAI,kCAAkC,EAAE,MAAM,mBAAmB,CAAC;AAEvG,wFAAwF;AACxF,4EAA4E;AAC5E,2EAA2E;AAC3E,4BAA4B;AAC5B,MAAM,MAAM,GA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daemon",
3
- "version": "3.12.2",
3
+ "version": "3.12.5",
4
4
  "license": "MIT",
5
5
  "description": "Managed local daemon: Unix-socket JSON-RPC, token auth, task queue. Runner injected (no second scheduler).",
6
6
  "type": "module",
@@ -17,10 +17,10 @@
17
17
  ],
18
18
  "dependencies": {
19
19
  "yaml": "^2.8.2",
20
- "@claudexor/core": "3.12.2",
21
- "@claudexor/journal": "3.12.2",
22
- "@claudexor/util": "3.12.2",
23
- "@claudexor/schema": "3.12.2"
20
+ "@claudexor/core": "3.12.5",
21
+ "@claudexor/journal": "3.12.5",
22
+ "@claudexor/schema": "3.12.5",
23
+ "@claudexor/util": "3.12.5"
24
24
  },
25
25
  "repository": {
26
26
  "type": "git",