@camstack/system 1.2.475 → 1.2.477
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/{agent-https-BsqT0qni.js → agent-https-DkXBXEvz.js} +1 -1
- package/dist/{agent-https-wA8gGLc1.mjs → agent-https-vpf_D97z.mjs} +1 -1
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/dist/builtins/alerts/alerts.addon.js +1 -1
- package/dist/builtins/alerts/alerts.addon.mjs +1 -1
- package/dist/builtins/autotrack/index.js +1 -1
- package/dist/builtins/autotrack/index.mjs +1 -1
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
- package/dist/builtins/calendars/calendars.addon.js +1 -1
- package/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/dist/builtins/camera-grid/index.js +1 -1
- package/dist/builtins/camera-grid/index.mjs +1 -1
- package/dist/builtins/composer/composer-live-set.d.ts +9 -1
- package/dist/builtins/composer/composer-runtime-factory.d.ts +2 -1
- package/dist/builtins/composer/composer.addon.js +581 -15
- package/dist/builtins/composer/composer.addon.mjs +581 -15
- package/dist/builtins/composer/composer.d.ts +14 -1
- package/dist/builtins/composer/composition-runtime.d.ts +5 -0
- package/dist/builtins/composer/composition-target.d.ts +6 -0
- package/dist/builtins/composer/field-record.d.ts +7 -0
- package/dist/builtins/composer/owned-fields-target.d.ts +9 -0
- package/dist/builtins/composer/pulse-seed-resolve.d.ts +59 -0
- package/dist/builtins/composer/pulse-seed.d.ts +75 -0
- package/dist/builtins/console-logging/index.js +1 -1
- package/dist/builtins/console-logging/index.mjs +1 -1
- package/dist/builtins/core-blocks/block-supervisor.d.ts +19 -1
- package/dist/builtins/core-blocks/composition-api.d.ts +7 -1
- package/dist/builtins/core-blocks/core-blocks.addon.js +108 -10
- package/dist/builtins/core-blocks/core-blocks.addon.mjs +108 -10
- package/dist/builtins/device-history/device-history.addon.js +63 -953
- package/dist/builtins/device-history/device-history.addon.mjs +2 -892
- package/dist/builtins/device-manager/device-manager.addon.js +1 -1
- package/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
- package/dist/builtins/hub-forwarder/index.js +1 -1
- package/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/dist/builtins/keychain/index.js +3 -3
- package/dist/builtins/keychain/index.mjs +3 -3
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/dist/builtins/local-auth/local-auth.addon.js +2 -2
- package/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
- package/dist/builtins/local-network/local-network.addon.js +2 -2
- package/dist/builtins/local-network/local-network.addon.mjs +2 -2
- package/dist/builtins/loki-logging/index.js +1 -1
- package/dist/builtins/loki-logging/index.mjs +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/dist/builtins/platform-probe/index.js +1 -1
- package/dist/builtins/platform-probe/index.mjs +1 -1
- package/dist/builtins/record-entries/index.js +1 -1
- package/dist/builtins/record-entries/index.mjs +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/dist/builtins/snapshot/index.js +1 -1
- package/dist/builtins/snapshot/index.mjs +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/dist/builtins/sqlite-storage/index.js +1 -1
- package/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +2 -2
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +2 -2
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/dist/builtins/system-config/system-config.addon.js +3 -3
- package/dist/builtins/system-config/system-config.addon.mjs +3 -3
- package/dist/builtins/winston-logging/index.js +1 -1
- package/dist/builtins/winston-logging/index.mjs +1 -1
- package/dist/{composition-sources-CiFkyAcf.mjs → composition-sources-B5nK7pHt.mjs} +1 -1
- package/dist/{composition-sources-DeUSUid6.js → composition-sources-BNOP9mFp.js} +1 -1
- package/dist/{constants-3Wj5OyEk.js → constants-D4VigrMM.js} +1 -1
- package/dist/{constants-DZJAkne8.mjs → constants-jbhoFV7w.mjs} +1 -1
- package/dist/{device-ca-DiV5xcMz.mjs → device-ca-CvBZeyVX.mjs} +1 -1
- package/dist/{device-ca-ftrfVdc0.js → device-ca-DhyQeXsa.js} +1 -1
- package/dist/{dist-DygMs3Qc.mjs → dist-B_V9r61Z.mjs} +21 -2
- package/dist/{dist-BtDdPdZ7.js → dist-CNU7cdFf.js} +21 -2
- package/dist/file-host-worker.js +1 -1
- package/dist/file-host-worker.mjs +1 -1
- package/dist/{hub-mdns-ciao-Bc9PnWu3.mjs → hub-mdns-ciao-BuUg0gpI.mjs} +2 -2
- package/dist/{hub-mdns-ciao-B1VcdfT1.js → hub-mdns-ciao-DFidf52M.js} +2 -2
- package/dist/index.js +7 -7
- package/dist/index.mjs +7 -7
- package/dist/{restore-archive-TDkQfmLO.js → restore-archive-BtCheeWu.js} +1 -1
- package/dist/{restore-archive-D_Pwryre.mjs → restore-archive-CDo4Zlmx.mjs} +1 -1
- package/dist/retention-1QA8e4o0.js +1024 -0
- package/dist/retention-lPgwLane.mjs +893 -0
- package/dist/{wal-maintenance-D3UwIKX5.js → wal-maintenance-B7xBeIFi.js} +0 -0
- package/dist/{wal-maintenance-rLv4uOmp.mjs → wal-maintenance-DItlr0Yu.mjs} +0 -0
- package/package.json +1 -1
|
@@ -19,7 +19,11 @@
|
|
|
19
19
|
* filter in `composer.addon.ts` stays load-bearing. Its fields are CLAIMED on
|
|
20
20
|
* the hub under the block id (`OwnedFieldsTarget`), and released through the
|
|
21
21
|
* `ClaimGate` — two applies must agree, seeded at boot from the claims index —
|
|
22
|
-
* when the block
|
|
22
|
+
* when the block merely vanished from one snapshot. An operator delete
|
|
23
|
+
* (`retiredBlockIds`) or an edit that drops a cap releases those claims on
|
|
24
|
+
* THIS apply, after the old runtime has quiesced and before any replacement
|
|
25
|
+
* claims; a release that does not land is logged with `tags: { deviceId }` and
|
|
26
|
+
* returned on the apply. Its own replaced
|
|
23
27
|
* fields are read in the NATIVE view (rule 6). Its target row gone on two
|
|
24
28
|
* agreeing index reads fails the block by name and ungrafts what it added —
|
|
25
29
|
* whether the loss was seen on `device.unregistered` or on a later plan; its
|
|
@@ -49,6 +53,7 @@ import { type ComposerDeclare, type ComposerDevicePorts } from "./composed-devic
|
|
|
49
53
|
import { type PersistedComposedRow } from "./composition-declarations.js";
|
|
50
54
|
import type { CompositionEventEmitter, DeadlineTimer } from "./composition-runtime.js";
|
|
51
55
|
import { type ComposerClaimsApi, type ComposerGraftPorts, type DescribeTarget } from "./existing-target.js";
|
|
56
|
+
import { type ReadPulseHistory } from "./pulse-seed-resolve.js";
|
|
52
57
|
import type { SourceBindingsChangeReason, SourceTracker } from "./source-tracker.js";
|
|
53
58
|
export type { ComposerDerivedSpec } from "./composer-plan.js";
|
|
54
59
|
export type { ComposerDeclareResult, ComposerDevicePorts } from "./composed-device-set.js";
|
|
@@ -80,6 +85,11 @@ export interface ComposerDeps {
|
|
|
80
85
|
readonly events: CompositionEventEmitter;
|
|
81
86
|
/** Effective target state, read before an existing-target runtime owns any field. */
|
|
82
87
|
readonly readExistingTargetCap: (deviceId: number, capName: string) => Promise<Readonly<Record<string, unknown>> | null>;
|
|
88
|
+
/**
|
|
89
|
+
* Raw history of a source field, for a pulse override's start seed (D938).
|
|
90
|
+
* Absent (tests that predate the seed) leaves the boot slice as the initial.
|
|
91
|
+
*/
|
|
92
|
+
readonly readPulseHistory?: ReadPulseHistory;
|
|
83
93
|
/** ONE `getBindings` per target description read (rule 1). */
|
|
84
94
|
readonly describeTarget: DescribeTarget;
|
|
85
95
|
/** `GraftHost` (Task 10): a method-serving native for each ADDED cap. Absent, nothing is grafted. */
|
|
@@ -139,6 +149,9 @@ export declare class Composer {
|
|
|
139
149
|
private syncTracker;
|
|
140
150
|
/** Rule 3: release what no live customization wants, once two applies agree (`wantedClaims`). */
|
|
141
151
|
private reconcileClaims;
|
|
152
|
+
/** Confirmed releases, awaited. A failure is the string the hub gave; the gate retries it later. */
|
|
153
|
+
private releaseConfirmed;
|
|
154
|
+
/** Null when the hub confirmed the release (or held nothing of ours). */
|
|
142
155
|
private release;
|
|
143
156
|
/**
|
|
144
157
|
* Rule 5: a customization whose target row is gone — the tracker's two
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
import { type CapabilityLookup, type CompositionEventPlan, type CompositionFieldPlan, type CompositionFieldRead, type CompositionFieldState, type IScopedLogger, type SourceReader } from "@camstack/types";
|
|
55
55
|
import type { ComposedWriteTarget, CompositionEventEmitter, DeadlineTimer } from "./composition-target.js";
|
|
56
56
|
import { type ReleasedField } from "./field-record.js";
|
|
57
|
+
import type { PulseFieldSeed } from "./pulse-seed.js";
|
|
57
58
|
export type { ReleasedField } from "./field-record.js";
|
|
58
59
|
export type { ComposedWriteTarget, CompositionEventEmitter, DeadlineTimer, TargetAsyncFailure, WriteOk, WriteOutcome, WriteRefused } from "./composition-target.js";
|
|
59
60
|
export interface CompositionRuntimeDeps {
|
|
@@ -65,6 +66,8 @@ export interface CompositionRuntimeDeps {
|
|
|
65
66
|
readonly lookupCap: CapabilityLookup;
|
|
66
67
|
/** Effective target slices captured before an existing-target runtime takes ownership. */
|
|
67
68
|
readonly initialByCap?: ReadonlyMap<string, Readonly<Record<string, unknown>> | null>;
|
|
69
|
+
/** Pulse start seed (D938). Absent keeps `initialByCap`. `hold` publishes nothing. */
|
|
70
|
+
readonly pulseSeeds?: ReadonlyMap<string, PulseFieldSeed>;
|
|
68
71
|
readonly read: SourceReader;
|
|
69
72
|
/**
|
|
70
73
|
* Whether `read` is of this composition's OWN output (an added cap on its
|
|
@@ -115,6 +118,8 @@ export declare class CompositionRuntime {
|
|
|
115
118
|
disable(reason: string): void;
|
|
116
119
|
/** Terminal: no write, no evaluation and no timer after this. */
|
|
117
120
|
stop(): void;
|
|
121
|
+
/** `stop`, then wait until the target has sent nothing further. */
|
|
122
|
+
quiesce(): Promise<void>;
|
|
118
123
|
state(): CompositionRuntimeState;
|
|
119
124
|
/**
|
|
120
125
|
* The target's enqueued write of `cap` did not land: the cap is write-pending
|
|
@@ -44,6 +44,12 @@ export interface ComposedWriteTarget {
|
|
|
44
44
|
* existing targets.
|
|
45
45
|
*/
|
|
46
46
|
withhold?(cap: string, fields: readonly string[]): WriteOutcome;
|
|
47
|
+
/**
|
|
48
|
+
* Drop writes not yet sent and resolve once the one in flight has settled.
|
|
49
|
+
* A stopped block calls this before its claims are released, so that claim
|
|
50
|
+
* cannot land afterwards.
|
|
51
|
+
*/
|
|
52
|
+
quiesce?(): Promise<void>;
|
|
47
53
|
}
|
|
48
54
|
export interface DeadlineTimer {
|
|
49
55
|
arm(at: number, fire: () => void): void;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* behaviour.
|
|
7
7
|
*/
|
|
8
8
|
import { type CapabilityLookup, type CompositionFieldItem, type CompositionFieldPlan, type CompositionFieldState, type ExpressionValue, type FieldOutcome, type StatefulExpressionMemory } from "@camstack/types";
|
|
9
|
+
import type { PulseFieldSeed } from "./pulse-seed.js";
|
|
9
10
|
export declare const NO_FIELDS: ReadonlySet<string>;
|
|
10
11
|
export interface FieldRecord {
|
|
11
12
|
readonly plan: CompositionFieldPlan;
|
|
@@ -19,9 +20,15 @@ export interface FieldRecord {
|
|
|
19
20
|
readonly expressionMemory: StatefulExpressionMemory;
|
|
20
21
|
/** Last finite state value already represented by a derived event. */
|
|
21
22
|
readonly eventHighWater: number | null;
|
|
23
|
+
/**
|
|
24
|
+
* A pulse timestamp whose start seed could not be read (D49, D938). A null
|
|
25
|
+
* result is not published, so a failed read is not "no ring".
|
|
26
|
+
*/
|
|
27
|
+
readonly pulseHold: boolean;
|
|
22
28
|
}
|
|
23
29
|
export declare function fieldKey(plan: CompositionFieldPlan): string;
|
|
24
30
|
export declare function createFieldRecord(plan: CompositionFieldPlan, byCap: ReadonlyMap<string, Readonly<Record<string, unknown>> | null> | undefined, lookupCap: CapabilityLookup): FieldRecord;
|
|
31
|
+
export declare function fieldRecords(fields: readonly CompositionFieldPlan[], byCap: ReadonlyMap<string, Readonly<Record<string, unknown>> | null> | undefined, lookupCap: CapabilityLookup, pulseSeeds: ReadonlyMap<string, PulseFieldSeed> | undefined): ReadonlyMap<string, FieldRecord>;
|
|
25
32
|
export declare function currentOutput(record: FieldRecord): unknown;
|
|
26
33
|
/** The top-level field a record writes: an item leaf writes its whole array. */
|
|
27
34
|
export declare function topLevelField(plan: CompositionFieldPlan): string;
|
|
@@ -64,11 +64,20 @@ export declare class OwnedFieldsTarget implements ComposedWriteTarget {
|
|
|
64
64
|
private listeners;
|
|
65
65
|
/** Per cap, bumped by every `withhold`: a claim that settles under another epoch claimed a stale field set and does not land (I-2). */
|
|
66
66
|
private epoch;
|
|
67
|
+
/** Set by `quiesce`: nothing further is sent. */
|
|
68
|
+
private closed;
|
|
69
|
+
private idle;
|
|
70
|
+
private markIdle;
|
|
67
71
|
constructor(deps: OwnedFieldsTargetDeps);
|
|
68
72
|
seed(cap: string, slice: SlicePatch): WriteOutcome;
|
|
69
73
|
patch(cap: string, patch: SlicePatch): WriteOutcome;
|
|
70
74
|
/** `device-status` belongs to the native device; availability lives in the block report only. */
|
|
71
75
|
setAvailable(_available: boolean): void;
|
|
76
|
+
/**
|
|
77
|
+
* The block has stopped. Writes still queued are dropped; the call in flight
|
|
78
|
+
* is allowed to finish, and then nothing else is sent.
|
|
79
|
+
*/
|
|
80
|
+
quiesce(): Promise<void>;
|
|
72
81
|
onAsyncFailure(listener: AsyncFailureListener): void;
|
|
73
82
|
withhold(cap: string, fields: readonly string[]): WriteOutcome;
|
|
74
83
|
private claimableFields;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gather a pulse override's start seed (D938). The stored expression is not
|
|
3
|
+
* changed. A failed read holds the field: no seed, and a claimed stamp is
|
|
4
|
+
* not cleared (D49).
|
|
5
|
+
*/
|
|
6
|
+
import { type CapabilityLookup, type ClaimsListing, type CompositionFieldPlan, type CompositionSourceRef, type IScopedLogger } from "@camstack/types";
|
|
7
|
+
import type { ExistingTargetSeedRead } from "./existing-target.js";
|
|
8
|
+
import { type PulseFieldSeed, type PulseHistoryPoint } from "./pulse-seed.js";
|
|
9
|
+
import type { SourceResolution } from "./source-readings.js";
|
|
10
|
+
export type { PulseFieldSeed } from "./pulse-seed.js";
|
|
11
|
+
export interface PulseHistorySeries {
|
|
12
|
+
readonly beforeOn: boolean | null;
|
|
13
|
+
readonly points: readonly PulseHistoryPoint[];
|
|
14
|
+
}
|
|
15
|
+
export type PulseHistoryAnswer = {
|
|
16
|
+
readonly kind: "unread";
|
|
17
|
+
readonly error: string;
|
|
18
|
+
} | {
|
|
19
|
+
readonly kind: "series";
|
|
20
|
+
readonly series: PulseHistorySeries;
|
|
21
|
+
};
|
|
22
|
+
export type ReadPulseHistory = (deviceId: number, cap: string, fieldPath: string, fromMs: number, toMs: number) => Promise<PulseHistoryAnswer>;
|
|
23
|
+
export interface PulseClaimListing {
|
|
24
|
+
listClaims(input: {
|
|
25
|
+
readonly ownerPrefix?: string;
|
|
26
|
+
}): Promise<ClaimsListing>;
|
|
27
|
+
}
|
|
28
|
+
export interface PulseSourceLookup {
|
|
29
|
+
resolve(ref: CompositionSourceRef, reset: boolean): Promise<SourceResolution>;
|
|
30
|
+
}
|
|
31
|
+
export interface ResolvePulseSeedsInput {
|
|
32
|
+
readonly blockId: string;
|
|
33
|
+
readonly deviceId: number;
|
|
34
|
+
readonly fields: readonly CompositionFieldPlan[];
|
|
35
|
+
readonly targetSeed: ExistingTargetSeedRead;
|
|
36
|
+
readonly lookupCap: CapabilityLookup;
|
|
37
|
+
readonly claims: PulseClaimListing;
|
|
38
|
+
readonly sources: PulseSourceLookup;
|
|
39
|
+
readonly readCap: (deviceId: number, capName: string) => Promise<Readonly<Record<string, unknown>> | null>;
|
|
40
|
+
readonly readPulseHistory: ReadPulseHistory;
|
|
41
|
+
readonly now: () => number;
|
|
42
|
+
readonly logger: IScopedLogger;
|
|
43
|
+
}
|
|
44
|
+
export declare function historySeriesKey(cap: string, fieldPath: string): string;
|
|
45
|
+
export declare function resolvePulseSeeds(input: ResolvePulseSeedsInput): Promise<ReadonlyMap<string, PulseFieldSeed>>;
|
|
46
|
+
export interface PulseHistoryQueryPoint {
|
|
47
|
+
readonly t: number;
|
|
48
|
+
readonly last: number | null;
|
|
49
|
+
}
|
|
50
|
+
export interface PulseHistoryQueryBefore {
|
|
51
|
+
readonly value: number | null;
|
|
52
|
+
}
|
|
53
|
+
export interface PulseHistoryQuerySeries {
|
|
54
|
+
readonly scope: string;
|
|
55
|
+
readonly before: PulseHistoryQueryBefore | null;
|
|
56
|
+
readonly points: readonly PulseHistoryQueryPoint[];
|
|
57
|
+
}
|
|
58
|
+
/** Raw boolean points of the device-level series (`scope` empty). 1 is on. */
|
|
59
|
+
export declare function pulseHistoryFromQuery(series: readonly PulseHistoryQuerySeries[]): PulseHistorySeries;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What `lastPressedAt` is at the start of a pulse override (D938).
|
|
3
|
+
*
|
|
4
|
+
* The stored formula stays `latest(rose(...))` — the seed is not an argument
|
|
5
|
+
* of `rose` or `latest`, so compile/decode stay a round trip (D936). A stamp
|
|
6
|
+
* this block already claimed is kept. Anything else comes from the source,
|
|
7
|
+
* and a read that failed is not a seed and not "no ring" (D49).
|
|
8
|
+
*/
|
|
9
|
+
export interface PulseHistoryPoint {
|
|
10
|
+
readonly t: number;
|
|
11
|
+
readonly on: boolean;
|
|
12
|
+
}
|
|
13
|
+
export type PulseHistoryRead = {
|
|
14
|
+
readonly kind: "unread";
|
|
15
|
+
} | {
|
|
16
|
+
readonly kind: "absent";
|
|
17
|
+
} | {
|
|
18
|
+
readonly kind: "series";
|
|
19
|
+
readonly beforeOn: boolean | null;
|
|
20
|
+
readonly points: readonly PulseHistoryPoint[];
|
|
21
|
+
};
|
|
22
|
+
export type PulseSourceLevel = {
|
|
23
|
+
readonly kind: "unread";
|
|
24
|
+
} | {
|
|
25
|
+
readonly kind: "off";
|
|
26
|
+
readonly changedAt: number | null;
|
|
27
|
+
} | {
|
|
28
|
+
readonly kind: "on";
|
|
29
|
+
readonly changedAt: number | null;
|
|
30
|
+
};
|
|
31
|
+
/** What this block already wrote. `none` means it holds no claim. */
|
|
32
|
+
export type OwnedPulse = {
|
|
33
|
+
readonly kind: "none";
|
|
34
|
+
} | {
|
|
35
|
+
readonly kind: "never";
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: "stamp";
|
|
38
|
+
readonly at: number;
|
|
39
|
+
readonly count: number;
|
|
40
|
+
};
|
|
41
|
+
export interface PulseSeedFacts {
|
|
42
|
+
readonly owned: OwnedPulse;
|
|
43
|
+
/** The target's native `lastPressedAt`. Compared only with a changed-at bound. */
|
|
44
|
+
readonly nativeStamp: number | null;
|
|
45
|
+
readonly history: PulseHistoryRead;
|
|
46
|
+
readonly level: PulseSourceLevel;
|
|
47
|
+
}
|
|
48
|
+
export type PulseStampDecision = {
|
|
49
|
+
readonly kind: "keep";
|
|
50
|
+
} | {
|
|
51
|
+
readonly kind: "hold";
|
|
52
|
+
readonly reason: string;
|
|
53
|
+
} | {
|
|
54
|
+
readonly kind: "none";
|
|
55
|
+
readonly count: number;
|
|
56
|
+
} | {
|
|
57
|
+
readonly kind: "stamp";
|
|
58
|
+
readonly at: number;
|
|
59
|
+
readonly count: number;
|
|
60
|
+
readonly via: "history" | "changed-at-bound";
|
|
61
|
+
};
|
|
62
|
+
/** What one field's record is seeded with. `keep` leaves the boot slice alone. */
|
|
63
|
+
export type PulseFieldSeed = {
|
|
64
|
+
readonly kind: "keep";
|
|
65
|
+
} | {
|
|
66
|
+
readonly kind: "hold";
|
|
67
|
+
} | {
|
|
68
|
+
readonly kind: "value";
|
|
69
|
+
readonly value: number | null;
|
|
70
|
+
};
|
|
71
|
+
/** The last false→true in time order. A series that opens already on is not a transition. */
|
|
72
|
+
export declare function lastOffToOn(points: readonly PulseHistoryPoint[], beforeOn: boolean | null): number | null;
|
|
73
|
+
export declare function decidePulseSeed(facts: PulseSeedFacts): PulseStampDecision;
|
|
74
|
+
/** One failed source blocks "no ring". A rise from another source still stands. */
|
|
75
|
+
export declare function mergePulseDecisions(decisions: readonly PulseStampDecision[]): PulseStampDecision;
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-CNU7cdFf.js");
|
|
7
7
|
const require_formatter = require("../../formatter-DqAKDlvN.js");
|
|
8
8
|
//#region src/builtins/console-logging/console-destination.ts
|
|
9
9
|
var LEVEL_RANK = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ln as logDestinationCapability, ti as BaseAddon } from "../../dist-
|
|
1
|
+
import { Ln as logDestinationCapability, ti as BaseAddon } from "../../dist-B_V9r61Z.mjs";
|
|
2
2
|
import { t as formatLogLine } from "../../formatter-B7qW8bPJ.mjs";
|
|
3
3
|
//#region src/builtins/console-logging/console-destination.ts
|
|
4
4
|
var LEVEL_RANK = {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* status the operator can see, with the reason attached. A block that is
|
|
20
20
|
* silently absent is the failure mode this whole feature has to avoid.
|
|
21
21
|
*/
|
|
22
|
-
import { type ComposerApplyInput, type ComposerApplyResult, type ComposerUnreadableBlock, type CoreBlock, type IScopedLogger } from "@camstack/types";
|
|
22
|
+
import { type ComposerApplyInput, type ComposerApplyResult, type ComposerUnreadableBlock, type CoreBlock, type IScopedLogger, type UnreleasedClaim } from "@camstack/types";
|
|
23
23
|
/** The runner lifecycle states `$process.list` reports. `stopping`/`stopped`
|
|
24
24
|
* are transient states of a runner on its way out and are treated as absent. */
|
|
25
25
|
export type BlockRunnerState = "starting" | "running" | "stopping" | "stopped" | "crashed" | "failed";
|
|
@@ -107,6 +107,10 @@ export declare class BlockSupervisor {
|
|
|
107
107
|
private emptyAppliesOwed;
|
|
108
108
|
/** Consecutive applies that could not reach the composer: warned once per run. */
|
|
109
109
|
private failedApplies;
|
|
110
|
+
/** Composition ids the operator deleted. Passed until their claims are released. */
|
|
111
|
+
private retiredBlockIds;
|
|
112
|
+
/** What the last composition apply said about claim releases. */
|
|
113
|
+
private releaseReport;
|
|
110
114
|
constructor(deps: BlockSupervisorDeps);
|
|
111
115
|
/** Start the reconcile timer. The first pass runs immediately. */
|
|
112
116
|
start(intervalMs: number): void;
|
|
@@ -128,6 +132,17 @@ export declare class BlockSupervisor {
|
|
|
128
132
|
* timer tick could stop a runner the tick had just decided was healthy and
|
|
129
133
|
* then never re-launch it.
|
|
130
134
|
*/
|
|
135
|
+
/**
|
|
136
|
+
* The block row is already gone. The next apply names it retired so its
|
|
137
|
+
* claims are released before this resolves. A release that does not land is
|
|
138
|
+
* returned; the id stays retired so the following pass tries again.
|
|
139
|
+
*/
|
|
140
|
+
retireComposition(blockId: string): Promise<readonly UnreleasedClaim[]>;
|
|
141
|
+
/**
|
|
142
|
+
* One apply, awaited. Used when an edit replaced a block's caps: the
|
|
143
|
+
* composer releases what the new plan dropped before this resolves.
|
|
144
|
+
*/
|
|
145
|
+
convergeForClaims(): Promise<readonly UnreleasedClaim[]>;
|
|
131
146
|
restart(blockId: string): Promise<void>;
|
|
132
147
|
private runRestart;
|
|
133
148
|
private runPass;
|
|
@@ -139,6 +154,9 @@ export declare class BlockSupervisor {
|
|
|
139
154
|
* pass of this same converge is the retry — no timer of its own (D3).
|
|
140
155
|
*/
|
|
141
156
|
private convergeCompositions;
|
|
157
|
+
private claimsOf;
|
|
158
|
+
/** Remember which retired ids still hold a claim. An apply that did not act keeps every id. */
|
|
159
|
+
private noteRelease;
|
|
142
160
|
/** Compile, write the package, spawn. Each failure is reported ON the block
|
|
143
161
|
* — the author asked for this to run, so they are owed the reason it does
|
|
144
162
|
* not. */
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* server derives it (`customizationBlockName`), refuses one the client sends,
|
|
13
13
|
* and never lets it move to another device. One per device, by block id (S2).
|
|
14
14
|
*/
|
|
15
|
-
import { type CapabilityDefinition, type CapabilityLookup, type CompositionBlockPatch, type CompositionBlockState, type CompositionSourceRef, type CoreBlock, type ICoreBlocksProvider, type IScopedLogger } from "@camstack/types";
|
|
15
|
+
import { type CapabilityDefinition, type CapabilityLookup, type CompositionBlockPatch, type CompositionBlockState, type CompositionSourceRef, type CoreBlock, type ICoreBlocksProvider, type IScopedLogger, type UnreleasedClaim } from "@camstack/types";
|
|
16
16
|
import type { NamedCompositionInput } from "./core-block-store.js";
|
|
17
17
|
import type { CompositionDescriptions } from "./composition-sources.js";
|
|
18
18
|
export interface CompositionStoreView {
|
|
@@ -30,6 +30,12 @@ export interface CompositionApiDeps {
|
|
|
30
30
|
readonly lookupCap: CapabilityLookup;
|
|
31
31
|
readonly composerStates: (blockIds: readonly string[]) => Promise<readonly CompositionBlockState[]>;
|
|
32
32
|
readonly convergeSoon: () => void;
|
|
33
|
+
/**
|
|
34
|
+
* One composer apply, awaited. An edit that replaces caps does not return
|
|
35
|
+
* until the caps it dropped have been released, or the release has failed
|
|
36
|
+
* and is in the list.
|
|
37
|
+
*/
|
|
38
|
+
readonly convergeForClaims: () => Promise<readonly UnreleasedClaim[]>;
|
|
33
39
|
readonly logger: IScopedLogger;
|
|
34
40
|
/** Every capability definition — the listing is derived from them, never from the registry's live state. */
|
|
35
41
|
readonly capabilityDefinitions: readonly CapabilityDefinition[];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
3
|
-
const require_dist = require("../../dist-
|
|
3
|
+
const require_dist = require("../../dist-CNU7cdFf.js");
|
|
4
4
|
const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
|
|
5
|
-
const require_composition_sources = require("../../composition-sources-
|
|
5
|
+
const require_composition_sources = require("../../composition-sources-BNOP9mFp.js");
|
|
6
6
|
const require_prefix_range = require("../../prefix-range-D_KueXbQ.js");
|
|
7
7
|
const require_prefix_walk = require("../../prefix-walk-Dv6MLZlM.js");
|
|
8
8
|
let zod = require("zod");
|
|
@@ -246,6 +246,13 @@ var BlockSupervisor = class {
|
|
|
246
246
|
emptyAppliesOwed = 2;
|
|
247
247
|
/** Consecutive applies that could not reach the composer: warned once per run. */
|
|
248
248
|
failedApplies = 0;
|
|
249
|
+
/** Composition ids the operator deleted. Passed until their claims are released. */
|
|
250
|
+
retiredBlockIds = /* @__PURE__ */ new Set();
|
|
251
|
+
/** What the last composition apply said about claim releases. */
|
|
252
|
+
releaseReport = {
|
|
253
|
+
error: null,
|
|
254
|
+
unreleased: []
|
|
255
|
+
};
|
|
249
256
|
constructor(deps) {
|
|
250
257
|
this.deps = deps;
|
|
251
258
|
}
|
|
@@ -281,6 +288,26 @@ var BlockSupervisor = class {
|
|
|
281
288
|
* timer tick could stop a runner the tick had just decided was healthy and
|
|
282
289
|
* then never re-launch it.
|
|
283
290
|
*/
|
|
291
|
+
/**
|
|
292
|
+
* The block row is already gone. The next apply names it retired so its
|
|
293
|
+
* claims are released before this resolves. A release that does not land is
|
|
294
|
+
* returned; the id stays retired so the following pass tries again.
|
|
295
|
+
*/
|
|
296
|
+
retireComposition(blockId) {
|
|
297
|
+
this.retiredBlockIds = new Set([...this.retiredBlockIds, blockId]);
|
|
298
|
+
return this.converge().then(() => this.claimsOf(blockId));
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* One apply, awaited. Used when an edit replaced a block's caps: the
|
|
302
|
+
* composer releases what the new plan dropped before this resolves.
|
|
303
|
+
*/
|
|
304
|
+
convergeForClaims() {
|
|
305
|
+
if (this.deps.composer === null) return Promise.reject(/* @__PURE__ */ new Error("core-blocks: no composer is available — a replaced claim cannot be released"));
|
|
306
|
+
return this.converge().then(() => {
|
|
307
|
+
if (this.releaseReport.error !== null) throw new Error(`core-blocks: a replaced claim was not released — ${this.releaseReport.error}`);
|
|
308
|
+
return this.releaseReport.unreleased;
|
|
309
|
+
});
|
|
310
|
+
}
|
|
284
311
|
restart(blockId) {
|
|
285
312
|
const block = this.deps.store.get(blockId);
|
|
286
313
|
if (block !== null && require_dist.coreBlockSourceKind(block) === "composition") {
|
|
@@ -369,9 +396,13 @@ var BlockSupervisor = class {
|
|
|
369
396
|
});
|
|
370
397
|
const unreadable = this.deps.store.unreadableCompositions();
|
|
371
398
|
const nothingToSay = compositions.length === 0 && unreadable.length === 0;
|
|
372
|
-
if (nothingToSay && this.emptyAppliesOwed === 0) return;
|
|
399
|
+
if (nothingToSay && this.emptyAppliesOwed === 0 && this.retiredBlockIds.size === 0) return;
|
|
373
400
|
const composer = this.deps.composer;
|
|
374
401
|
if (composer === null) {
|
|
402
|
+
if (this.retiredBlockIds.size > 0) this.releaseReport = {
|
|
403
|
+
error: "no composer is available on this node — claims cannot be released",
|
|
404
|
+
unreleased: []
|
|
405
|
+
};
|
|
375
406
|
for (const { block } of compositions) await this.report(block.id, "failed", "no composer is available on this node — a composition cannot run here");
|
|
376
407
|
return;
|
|
377
408
|
}
|
|
@@ -394,7 +425,8 @@ var BlockSupervisor = class {
|
|
|
394
425
|
composition
|
|
395
426
|
})),
|
|
396
427
|
restartBlockIds: [...restart],
|
|
397
|
-
unreadableBlocks: [...unreadable]
|
|
428
|
+
unreadableBlocks: [...unreadable],
|
|
429
|
+
retiredBlockIds: [...this.retiredBlockIds]
|
|
398
430
|
});
|
|
399
431
|
if (this.failedApplies > 0) {
|
|
400
432
|
this.deps.logger.info("the composer answered again", { meta: { failedApplies: this.failedApplies } });
|
|
@@ -402,6 +434,7 @@ var BlockSupervisor = class {
|
|
|
402
434
|
}
|
|
403
435
|
this.pendingCompositionRestarts = new Set([...this.pendingCompositionRestarts].filter((id) => !restart.has(id)));
|
|
404
436
|
this.emptyAppliesOwed = !nothingToSay || !result.acted ? 2 : Math.max(0, this.emptyAppliesOwed - 1);
|
|
437
|
+
this.noteRelease(result);
|
|
405
438
|
const verdicts = new Map(result.blocks.map((v) => [v.blockId, v]));
|
|
406
439
|
for (const { block } of compositions) {
|
|
407
440
|
const verdict = verdicts.get(block.id);
|
|
@@ -409,13 +442,39 @@ var BlockSupervisor = class {
|
|
|
409
442
|
else await this.report(block.id, verdict.status, verdict.reason);
|
|
410
443
|
}
|
|
411
444
|
} catch (err) {
|
|
445
|
+
const error = require_dist.errMsg(err);
|
|
446
|
+
this.releaseReport = {
|
|
447
|
+
error,
|
|
448
|
+
unreleased: []
|
|
449
|
+
};
|
|
412
450
|
this.failedApplies += 1;
|
|
413
451
|
if (this.failedApplies === 1) this.deps.logger.warn("the composer could not be reached — compositions keep their last status", { meta: {
|
|
414
|
-
error
|
|
452
|
+
error,
|
|
415
453
|
compositions: compositions.length
|
|
416
454
|
} });
|
|
417
|
-
for (const { block } of compositions) if (block.status === "stopped" && block.enabled) await this.report(block.id, "starting", `the composer is not reachable yet: ${
|
|
455
|
+
for (const { block } of compositions) if (block.status === "stopped" && block.enabled) await this.report(block.id, "starting", `the composer is not reachable yet: ${error}`);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
claimsOf(blockId) {
|
|
459
|
+
if (this.releaseReport.error !== null) throw new Error(`core-blocks: claims of "${blockId}" were not released — ${this.releaseReport.error}`);
|
|
460
|
+
return this.releaseReport.unreleased.filter((claim) => claim.owner === blockId);
|
|
461
|
+
}
|
|
462
|
+
/** Remember which retired ids still hold a claim. An apply that did not act keeps every id. */
|
|
463
|
+
noteRelease(result) {
|
|
464
|
+
const unreleased = result.unreleasedClaims ?? [];
|
|
465
|
+
if (!result.acted) {
|
|
466
|
+
this.releaseReport = {
|
|
467
|
+
error: "the composer did not apply — claims stay until it does",
|
|
468
|
+
unreleased
|
|
469
|
+
};
|
|
470
|
+
return;
|
|
418
471
|
}
|
|
472
|
+
this.releaseReport = {
|
|
473
|
+
error: null,
|
|
474
|
+
unreleased
|
|
475
|
+
};
|
|
476
|
+
const failed = new Set(unreleased.map((claim) => claim.owner));
|
|
477
|
+
this.retiredBlockIds = new Set([...this.retiredBlockIds].filter((id) => failed.has(id)));
|
|
419
478
|
}
|
|
420
479
|
/** Compile, write the package, spawn. Each failure is reported ON the block
|
|
421
480
|
* — the author asked for this to run, so they are owed the reason it does
|
|
@@ -2082,7 +2141,21 @@ function buildCompositionApi(deps) {
|
|
|
2082
2141
|
blockId,
|
|
2083
2142
|
by: caller.userId
|
|
2084
2143
|
} });
|
|
2085
|
-
|
|
2144
|
+
if (block.composition !== void 0) {
|
|
2145
|
+
const unreleased = (await deps.convergeForClaims()).filter((claim) => claim.owner === blockId);
|
|
2146
|
+
if (unreleased.length > 0) {
|
|
2147
|
+
for (const claim of unreleased) deps.logger.error("composition saved but a replaced claim was not released", {
|
|
2148
|
+
tags: { deviceId: claim.deviceId },
|
|
2149
|
+
meta: {
|
|
2150
|
+
blockId,
|
|
2151
|
+
cap: claim.capName,
|
|
2152
|
+
error: claim.error
|
|
2153
|
+
}
|
|
2154
|
+
});
|
|
2155
|
+
const detail = unreleased.map((claim) => `${claim.capName} on device ${claim.deviceId}: ${claim.error}`).join("; ");
|
|
2156
|
+
throw new Error(`core-blocks: "${blockId}" was saved but a replaced claim was not released — ${detail}`);
|
|
2157
|
+
}
|
|
2158
|
+
} else deps.convergeSoon();
|
|
2086
2159
|
return { block: updated };
|
|
2087
2160
|
}),
|
|
2088
2161
|
getComposition: async ({ blockId }) => {
|
|
@@ -2458,9 +2531,30 @@ var CoreBlocksAddon = class extends require_dist.BaseAddon {
|
|
|
2458
2531
|
return { block: updated };
|
|
2459
2532
|
},
|
|
2460
2533
|
delete: async ({ blockId }) => {
|
|
2534
|
+
const existing = this.requireStore().get(blockId);
|
|
2535
|
+
const composition = existing !== null && require_dist.coreBlockComposition(existing) !== null;
|
|
2461
2536
|
await this.requireStore().delete(blockId);
|
|
2462
2537
|
await this.requirePrefs().delete(blockId);
|
|
2463
|
-
this.
|
|
2538
|
+
if (composition && this.supervisor === null) {
|
|
2539
|
+
this.ctx.logger.error("composition deleted but no supervisor can release its claims", { meta: { blockId } });
|
|
2540
|
+
throw new Error(`core-blocks: "${blockId}" was deleted but no supervisor runs here — its claims were not released`);
|
|
2541
|
+
}
|
|
2542
|
+
if (composition && this.supervisor !== null) {
|
|
2543
|
+
const unreleased = await this.supervisor.retireComposition(blockId);
|
|
2544
|
+
if (unreleased.length > 0) {
|
|
2545
|
+
for (const claim of unreleased) this.ctx.logger.error("composition deleted but its claim was not released", {
|
|
2546
|
+
tags: { deviceId: claim.deviceId },
|
|
2547
|
+
meta: {
|
|
2548
|
+
blockId,
|
|
2549
|
+
cap: claim.capName,
|
|
2550
|
+
owner: claim.owner,
|
|
2551
|
+
error: claim.error
|
|
2552
|
+
}
|
|
2553
|
+
});
|
|
2554
|
+
const detail = unreleased.map((claim) => `${claim.capName} on device ${claim.deviceId}: ${claim.error}`).join("; ");
|
|
2555
|
+
throw new Error(`core-blocks: "${blockId}" was deleted but its claims were not released — ${detail}`);
|
|
2556
|
+
}
|
|
2557
|
+
} else this.convergeSoon();
|
|
2464
2558
|
return { success: true };
|
|
2465
2559
|
},
|
|
2466
2560
|
setEnabled: async ({ blockId, enabled }) => {
|
|
@@ -2469,9 +2563,9 @@ var CoreBlocksAddon = class extends require_dist.BaseAddon {
|
|
|
2469
2563
|
return { block: updated };
|
|
2470
2564
|
},
|
|
2471
2565
|
/**
|
|
2472
|
-
* Awaited,
|
|
2566
|
+
* Awaited, like a composition delete.
|
|
2473
2567
|
*
|
|
2474
|
-
* `create`/`update` deliberately do not wait — the write is already
|
|
2568
|
+
* `create`/`update` of a code block deliberately do not wait — the write is already
|
|
2475
2569
|
* durable and converging forks a process. A restart has no durable half:
|
|
2476
2570
|
* the whole thing IS the converge, so returning before it ran would hand
|
|
2477
2571
|
* the operator the old status and read as "nothing happened".
|
|
@@ -2552,6 +2646,10 @@ var CoreBlocksAddon = class extends require_dist.BaseAddon {
|
|
|
2552
2646
|
lookupCap: require_dist.buildCapabilityLookup(require_dist.ALL_CAPABILITY_DEFINITIONS),
|
|
2553
2647
|
composerStates: async (blockIds) => (await requireApi().composer.getStates.query({ blockIds: [...blockIds] })).states,
|
|
2554
2648
|
convergeSoon: () => this.convergeSoon(),
|
|
2649
|
+
convergeForClaims: () => {
|
|
2650
|
+
if (this.supervisor === null) return Promise.reject(/* @__PURE__ */ new Error("core-blocks: no block supervisor runs on this node — claims cannot be released"));
|
|
2651
|
+
return this.supervisor.convergeForClaims();
|
|
2652
|
+
},
|
|
2555
2653
|
logger: this.ctx.logger.child("compositions"),
|
|
2556
2654
|
capabilityDefinitions: require_dist.ALL_CAPABILITY_DEFINITIONS
|
|
2557
2655
|
});
|