@plurnk/plurnk-service 1.10.0 → 1.11.0
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/.env.defaults +41 -17
- package/INSTALL.md +1 -1
- package/README.md +1 -1
- package/SPEC.md +487 -233
- package/digest-sql/curation/curation.sql +1 -0
- package/dist/Paths.d.ts +3 -3
- package/dist/Paths.d.ts.map +1 -1
- package/dist/Paths.js +9 -9
- package/dist/Paths.js.map +1 -1
- package/dist/build-info.json +1 -1
- package/dist/content/edit-collision.js +3 -3
- package/dist/content/edit-collision.js.map +1 -1
- package/dist/content/edit-receipt.d.ts +6 -5
- package/dist/content/edit-receipt.d.ts.map +1 -1
- package/dist/content/edit-receipt.js +13 -2
- package/dist/content/edit-receipt.js.map +1 -1
- package/dist/content/index.d.ts +2 -2
- package/dist/content/index.d.ts.map +1 -1
- package/dist/content/index.js +1 -1
- package/dist/content/index.js.map +1 -1
- package/dist/content/line-anchors.d.ts +2 -0
- package/dist/content/line-anchors.d.ts.map +1 -1
- package/dist/content/line-anchors.js +2 -0
- package/dist/content/line-anchors.js.map +1 -1
- package/dist/content/matcher.d.ts.map +1 -1
- package/dist/content/matcher.js +3 -2
- package/dist/content/matcher.js.map +1 -1
- package/dist/content/read-projector.js +3 -3
- package/dist/content/read-projector.js.map +1 -1
- package/dist/core/BudgetReadout.d.ts +6 -1
- package/dist/core/BudgetReadout.d.ts.map +1 -1
- package/dist/core/BudgetReadout.js +38 -2
- package/dist/core/BudgetReadout.js.map +1 -1
- package/dist/core/CapabilityPolicies.d.ts +15 -0
- package/dist/core/CapabilityPolicies.d.ts.map +1 -0
- package/dist/core/CapabilityPolicies.js +60 -0
- package/dist/core/CapabilityPolicies.js.map +1 -0
- package/dist/core/CapabilityResolver.d.ts +24 -0
- package/dist/core/CapabilityResolver.d.ts.map +1 -0
- package/dist/core/CapabilityResolver.js +180 -0
- package/dist/core/CapabilityResolver.js.map +1 -0
- package/dist/core/ChannelWrite.d.ts +4 -3
- package/dist/core/ChannelWrite.d.ts.map +1 -1
- package/dist/core/CoreSchemeServices.d.ts +1 -1
- package/dist/core/CoreSchemeServices.d.ts.map +1 -1
- package/dist/core/CoreSchemeServices.js +1 -1
- package/dist/core/CoreSchemeServices.js.map +1 -1
- package/dist/core/Dispatcher.d.ts +3 -1
- package/dist/core/Dispatcher.d.ts.map +1 -1
- package/dist/core/Dispatcher.js +148 -160
- package/dist/core/Dispatcher.js.map +1 -1
- package/dist/core/DurableStatement.d.ts.map +1 -1
- package/dist/core/DurableStatement.js +19 -15
- package/dist/core/DurableStatement.js.map +1 -1
- package/dist/core/Engine.d.ts +6 -4
- package/dist/core/Engine.d.ts.map +1 -1
- package/dist/core/Engine.js +18 -7
- package/dist/core/Engine.js.map +1 -1
- package/dist/core/Engine.sql +30 -25
- package/dist/core/ExecutorRegistry.d.ts +3 -3
- package/dist/core/ExecutorRegistry.d.ts.map +1 -1
- package/dist/core/ExecutorRegistry.js +10 -6
- package/dist/core/ExecutorRegistry.js.map +1 -1
- package/dist/core/GitBranch.d.ts +4 -1
- package/dist/core/GitBranch.d.ts.map +1 -1
- package/dist/core/GitBranch.js +12 -2
- package/dist/core/GitBranch.js.map +1 -1
- package/dist/core/LogEntryProjection.d.ts +1 -0
- package/dist/core/LogEntryProjection.d.ts.map +1 -1
- package/dist/core/LogEntryProjection.js +12 -4
- package/dist/core/LogEntryProjection.js.map +1 -1
- package/dist/core/LoopPolicyReader.d.ts +7 -0
- package/dist/core/LoopPolicyReader.d.ts.map +1 -0
- package/dist/core/LoopPolicyReader.js +33 -0
- package/dist/core/LoopPolicyReader.js.map +1 -0
- package/dist/core/ModelCall.d.ts +1 -0
- package/dist/core/ModelCall.d.ts.map +1 -1
- package/dist/core/ModelCall.js +3 -0
- package/dist/core/ModelCall.js.map +1 -1
- package/dist/core/NoticeChannel.d.ts +2 -2
- package/dist/core/NoticeChannel.d.ts.map +1 -1
- package/dist/core/NoticeChannel.js +18 -9
- package/dist/core/NoticeChannel.js.map +1 -1
- package/dist/core/OperatorConfig.d.ts.map +1 -1
- package/dist/core/OperatorConfig.js +4 -0
- package/dist/core/OperatorConfig.js.map +1 -1
- package/dist/core/OverflowTurn.d.ts.map +1 -1
- package/dist/core/OverflowTurn.js +4 -3
- package/dist/core/OverflowTurn.js.map +1 -1
- package/dist/core/Owner.js +5 -5
- package/dist/core/Owner.js.map +1 -1
- package/dist/core/PacketBuilder.d.ts +2 -2
- package/dist/core/PacketBuilder.d.ts.map +1 -1
- package/dist/core/PacketBuilder.js +53 -35
- package/dist/core/PacketBuilder.js.map +1 -1
- package/dist/core/ProblemLog.d.ts.map +1 -1
- package/dist/core/ProblemLog.js +1 -0
- package/dist/core/ProblemLog.js.map +1 -1
- package/dist/core/ProposalLifecycle.d.ts.map +1 -1
- package/dist/core/ProposalLifecycle.js +16 -13
- package/dist/core/ProposalLifecycle.js.map +1 -1
- package/dist/core/ReasoningEvent.d.ts +1 -0
- package/dist/core/ReasoningEvent.d.ts.map +1 -1
- package/dist/core/ResourceMutations.d.ts +5 -4
- package/dist/core/ResourceMutations.d.ts.map +1 -1
- package/dist/core/ResourceMutations.js +71 -48
- package/dist/core/ResourceMutations.js.map +1 -1
- package/dist/core/SchemeRegistry.d.ts +6 -3
- package/dist/core/SchemeRegistry.d.ts.map +1 -1
- package/dist/core/SchemeRegistry.js +14 -17
- package/dist/core/SchemeRegistry.js.map +1 -1
- package/dist/core/ServiceTeardown.d.ts +1 -1
- package/dist/core/ServiceTeardown.d.ts.map +1 -1
- package/dist/core/ServiceTeardown.js +4 -8
- package/dist/core/ServiceTeardown.js.map +1 -1
- package/dist/core/StrikeRail.js +1 -1
- package/dist/core/StrikeRail.js.map +1 -1
- package/dist/core/ToolResources.d.ts +2 -2
- package/dist/core/ToolResources.d.ts.map +1 -1
- package/dist/core/ToolResources.js +18 -8
- package/dist/core/ToolResources.js.map +1 -1
- package/dist/core/TurnOps.d.ts.map +1 -1
- package/dist/core/TurnOps.js +22 -8
- package/dist/core/TurnOps.js.map +1 -1
- package/dist/core/TurnRunner.d.ts +7 -3
- package/dist/core/TurnRunner.d.ts.map +1 -1
- package/dist/core/TurnRunner.js +315 -71
- package/dist/core/TurnRunner.js.map +1 -1
- package/dist/core/WorkerControlAddress.d.ts.map +1 -1
- package/dist/core/WorkerControlAddress.js +1 -2
- package/dist/core/WorkerControlAddress.js.map +1 -1
- package/dist/core/WorkerName.d.ts +2 -0
- package/dist/core/WorkerName.d.ts.map +1 -1
- package/dist/core/WorkerName.js +3 -2
- package/dist/core/WorkerName.js.map +1 -1
- package/dist/core/WorkerName.sql +2 -1
- package/dist/core/caps/DbProjectionCaps.d.ts +2 -1
- package/dist/core/caps/DbProjectionCaps.d.ts.map +1 -1
- package/dist/core/caps/DbProjectionCaps.js +12 -1
- package/dist/core/caps/DbProjectionCaps.js.map +1 -1
- package/dist/core/file-materialization.d.ts +22 -0
- package/dist/core/file-materialization.d.ts.map +1 -0
- package/dist/core/file-materialization.js +77 -0
- package/dist/core/file-materialization.js.map +1 -0
- package/dist/core/fork.d.ts +2 -1
- package/dist/core/fork.d.ts.map +1 -1
- package/dist/core/fork.js +13 -4
- package/dist/core/fork.js.map +1 -1
- package/dist/core/fork.sql +27 -11
- package/dist/core/git-membership.d.ts +25 -14
- package/dist/core/git-membership.d.ts.map +1 -1
- package/dist/core/git-membership.js +260 -164
- package/dist/core/git-membership.js.map +1 -1
- package/dist/core/git-state.d.ts +2 -0
- package/dist/core/git-state.d.ts.map +1 -1
- package/dist/core/git-state.js +27 -1
- package/dist/core/git-state.js.map +1 -1
- package/dist/core/operation-target-groups.d.ts.map +1 -1
- package/dist/core/operation-target-groups.js +8 -7
- package/dist/core/operation-target-groups.js.map +1 -1
- package/dist/core/owner.sql +7 -10
- package/dist/core/packet-wire.d.ts +10 -0
- package/dist/core/packet-wire.d.ts.map +1 -1
- package/dist/core/packet-wire.js +78 -29
- package/dist/core/packet-wire.js.map +1 -1
- package/dist/core/scheme-types.d.ts +2 -2
- package/dist/core/scheme-types.d.ts.map +1 -1
- package/dist/core/scheme-types.js +1 -1
- package/dist/core/scheme-types.js.map +1 -1
- package/dist/core/types.d.ts +3 -2
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/core/worker-settings.d.ts +4 -3
- package/dist/core/worker-settings.d.ts.map +1 -1
- package/dist/core/worker-settings.js +40 -19
- package/dist/core/worker-settings.js.map +1 -1
- package/dist/core/workspace-settings.d.ts +3 -1
- package/dist/core/workspace-settings.d.ts.map +1 -1
- package/dist/core/workspace-settings.js +6 -2
- package/dist/core/workspace-settings.js.map +1 -1
- package/dist/digest/Digest.d.ts.map +1 -1
- package/dist/digest/Digest.js +93 -26
- package/dist/digest/Digest.js.map +1 -1
- package/dist/digest/digest.sql +13 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/schemes/Exec.d.ts +3 -5
- package/dist/schemes/Exec.d.ts.map +1 -1
- package/dist/schemes/Exec.js +98 -94
- package/dist/schemes/Exec.js.map +1 -1
- package/dist/schemes/ExecOutputScheme.d.ts.map +1 -1
- package/dist/schemes/ExecOutputScheme.js +24 -6
- package/dist/schemes/ExecOutputScheme.js.map +1 -1
- package/dist/schemes/ExecScheduler.d.ts +15 -0
- package/dist/schemes/ExecScheduler.d.ts.map +1 -0
- package/dist/schemes/ExecScheduler.js +95 -0
- package/dist/schemes/ExecScheduler.js.map +1 -0
- package/dist/schemes/File.d.ts.map +1 -1
- package/dist/schemes/File.js +16 -15
- package/dist/schemes/File.js.map +1 -1
- package/dist/schemes/Log.d.ts +6 -4
- package/dist/schemes/Log.d.ts.map +1 -1
- package/dist/schemes/Log.js +131 -38
- package/dist/schemes/Log.js.map +1 -1
- package/dist/schemes/Log.sql +23 -18
- package/dist/schemes/QuestionTool.d.ts +17 -4
- package/dist/schemes/QuestionTool.d.ts.map +1 -1
- package/dist/schemes/QuestionTool.js +2 -4
- package/dist/schemes/QuestionTool.js.map +1 -1
- package/dist/schemes/Worker.d.ts.map +1 -1
- package/dist/schemes/Worker.js +20 -20
- package/dist/schemes/Worker.js.map +1 -1
- package/dist/schemes/_entry-chunk.js +1 -1
- package/dist/schemes/_entry-chunk.js.map +1 -1
- package/dist/schemes/_entry-crud.sql +18 -17
- package/dist/schemes/_entry-find.d.ts.map +1 -1
- package/dist/schemes/_entry-find.js +7 -9
- package/dist/schemes/_entry-find.js.map +1 -1
- package/dist/schemes/_entry-graph.js +12 -12
- package/dist/schemes/_entry-graph.js.map +1 -1
- package/dist/schemes/_entry-graph.sql +5 -5
- package/dist/schemes/_entry-ops.d.ts.map +1 -1
- package/dist/schemes/_entry-ops.js +3 -3
- package/dist/schemes/_entry-ops.js.map +1 -1
- package/dist/schemes/_entry-semantic.js +1 -1
- package/dist/schemes/_entry-semantic.js.map +1 -1
- package/dist/server/BranchBatches.d.ts +3 -3
- package/dist/server/BranchBatches.d.ts.map +1 -1
- package/dist/server/BranchBatches.js +9 -2
- package/dist/server/BranchBatches.js.map +1 -1
- package/dist/server/Daemon.d.ts +12 -41
- package/dist/server/Daemon.d.ts.map +1 -1
- package/dist/server/Daemon.js +59 -93
- package/dist/server/Daemon.js.map +1 -1
- package/dist/server/DaemonModule.d.ts +10 -1
- package/dist/server/DaemonModule.d.ts.map +1 -1
- package/dist/server/DrainSupervisor.d.ts +6 -5
- package/dist/server/DrainSupervisor.d.ts.map +1 -1
- package/dist/server/DrainSupervisor.js +14 -11
- package/dist/server/DrainSupervisor.js.map +1 -1
- package/dist/server/Functionality.d.ts +2 -2
- package/dist/server/Functionality.d.ts.map +1 -1
- package/dist/server/Functionality.js +8 -5
- package/dist/server/Functionality.js.map +1 -1
- package/dist/server/FunctionalityManager.d.ts +13 -1
- package/dist/server/FunctionalityManager.d.ts.map +1 -1
- package/dist/server/FunctionalityManager.js +82 -17
- package/dist/server/FunctionalityManager.js.map +1 -1
- package/dist/server/MembersFunctionality.d.ts +56 -0
- package/dist/server/MembersFunctionality.d.ts.map +1 -0
- package/dist/server/MembersFunctionality.js +350 -0
- package/dist/server/MembersFunctionality.js.map +1 -0
- package/dist/server/SkillsFunctionality.d.ts +12 -1
- package/dist/server/SkillsFunctionality.d.ts.map +1 -1
- package/dist/server/SkillsFunctionality.js +6 -1
- package/dist/server/SkillsFunctionality.js.map +1 -1
- package/dist/server/client-input.d.ts +5 -8
- package/dist/server/client-input.d.ts.map +1 -1
- package/dist/server/client-input.js +49 -108
- package/dist/server/client-input.js.map +1 -1
- package/dist/server/dispatch-as-plurnk.d.ts.map +1 -1
- package/dist/server/dispatch-as-plurnk.js +3 -0
- package/dist/server/dispatch-as-plurnk.js.map +1 -1
- package/dist/server/drain.sql +4 -4
- package/dist/server/envelope.d.ts +1 -1
- package/dist/server/envelope.d.ts.map +1 -1
- package/dist/server/envelope.js +11 -10
- package/dist/server/envelope.js.map +1 -1
- package/dist/server/envelope.sql +1 -1
- package/dist/server/loopDocs.d.ts.map +1 -1
- package/dist/server/loopDocs.js +12 -5
- package/dist/server/loopDocs.js.map +1 -1
- package/dist/server/seam-proposal-list.sql +2 -2
- package/dist/server/worker-capabilities.sql +9 -0
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +16 -21
- package/dist/service.js.map +1 -1
- package/migrations/001_schema.sql +217 -64
- package/package.json +30 -32
- package/dist/core/LoopFlagsReader.d.ts +0 -7
- package/dist/core/LoopFlagsReader.d.ts.map +0 -1
- package/dist/core/LoopFlagsReader.js +0 -33
- package/dist/core/LoopFlagsReader.js.map +0 -1
- package/dist/core/resolveForLoop.d.ts +0 -5
- package/dist/core/resolveForLoop.d.ts.map +0 -1
- package/dist/core/resolveForLoop.js +0 -12
- package/dist/core/resolveForLoop.js.map +0 -1
|
@@ -65,6 +65,9 @@ CREATE TABLE IF NOT EXISTS workers (
|
|
|
65
65
|
-- validated at the client-input boundary (closed known-key set; unknown keys
|
|
66
66
|
-- never persist).
|
|
67
67
|
settings TEXT NOT NULL DEFAULT '{}' CHECK (json_valid(settings)),
|
|
68
|
+
-- Parent-derived capability ceiling, copied by value at child creation.
|
|
69
|
+
-- Root workers have the unrestricted empty policy.
|
|
70
|
+
capability_bound TEXT NOT NULL DEFAULT '{}' CHECK (json_valid(capability_bound)),
|
|
68
71
|
-- {§env-delta-log-pull}: monotonic observation progress, not a private world snapshot.
|
|
69
72
|
-- Creation captures the workspace high-water; a fork instead copies its
|
|
70
73
|
-- parent's cursor and records the closed event boundary of its snapshot.
|
|
@@ -224,10 +227,8 @@ BEGIN
|
|
|
224
227
|
END;
|
|
225
228
|
|
|
226
229
|
-- loops
|
|
227
|
-
--
|
|
228
|
-
--
|
|
229
|
-
-- keys read as their defaults. SchemeRegistry.resolveForLoop gates schemes
|
|
230
|
-
-- by manifest affinity (excludedInAsk / requiresWeb / requiresInteraction).
|
|
230
|
+
-- policy: complete immutable per-loop capability attenuation and proposal
|
|
231
|
+
-- disposition ({§loop-policy-effective-read}).
|
|
231
232
|
CREATE TABLE IF NOT EXISTS loops (
|
|
232
233
|
id INTEGER NOT NULL PRIMARY KEY,
|
|
233
234
|
version INTEGER NOT NULL DEFAULT 0 CHECK (version >= 0),
|
|
@@ -238,7 +239,7 @@ CREATE TABLE IF NOT EXISTS loops (
|
|
|
238
239
|
-- {§prompt-causal-source}: canonical actor address for the initial prompt;
|
|
239
240
|
-- NULL means the owning worker itself.
|
|
240
241
|
prompt_source TEXT CHECK (prompt_source IS NULL OR length(prompt_source) > 0),
|
|
241
|
-
|
|
242
|
+
policy TEXT NOT NULL DEFAULT '{"capabilities":{},"proposals":"review"}' CHECK (json_valid(policy)),
|
|
242
243
|
-- {§worker-model-selection}: immutable loop snapshots of the resolved model route and the
|
|
243
244
|
-- effective spawn route (was provider_spec/child_provider_spec JSON).
|
|
244
245
|
model_route_id INTEGER REFERENCES model_routes(id),
|
|
@@ -338,11 +339,18 @@ BEGIN
|
|
|
338
339
|
FROM workers w
|
|
339
340
|
WHERE w.id = NEW.worker_id
|
|
340
341
|
AND w.parent_worker_id IS NOT NULL
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
342
|
+
-- A loop whose only turns are client-driven operation turns is not the parent's
|
|
343
|
+
-- business (#323). A loop that never got a turn at all — a spawn refused before it
|
|
344
|
+
-- ran, e.g. a branch batch failing git-preflight — is, or the parent waits on a
|
|
345
|
+
-- ghost that vanished from Active Child Workers without a word (#385).
|
|
346
|
+
AND (
|
|
347
|
+
NOT EXISTS (SELECT 1 FROM turns t WHERE t.loop_id = NEW.id)
|
|
348
|
+
OR EXISTS (
|
|
349
|
+
SELECT 1
|
|
350
|
+
FROM turns t
|
|
351
|
+
WHERE t.loop_id = NEW.id
|
|
352
|
+
AND NOT (t.producer = '_plurnk' AND t.kind = 'operation')
|
|
353
|
+
)
|
|
346
354
|
);
|
|
347
355
|
END;
|
|
348
356
|
|
|
@@ -872,7 +880,7 @@ BEGIN
|
|
|
872
880
|
END;
|
|
873
881
|
|
|
874
882
|
-- symbol_defs
|
|
875
|
-
--
|
|
883
|
+
-- &graph NODES ({§relation-indexed-dialects}). Code symbol definitions, populated
|
|
876
884
|
-- once per content-addressed derivation from mimetypes'
|
|
877
885
|
-- `symbols` channel. Qualified path = container ? container || '.' || name : name.
|
|
878
886
|
CREATE TABLE IF NOT EXISTS symbol_defs (
|
|
@@ -889,9 +897,9 @@ CREATE TABLE IF NOT EXISTS symbol_defs (
|
|
|
889
897
|
CREATE INDEX IF NOT EXISTS symbol_defs_name ON symbol_defs (name);
|
|
890
898
|
|
|
891
899
|
-- symbol_refs
|
|
892
|
-
--
|
|
900
|
+
-- &graph EDGES ({§relation-indexed-dialects}), from mimetypes' `references` channel.
|
|
893
901
|
-- name = edge TARGET; container = the SOURCE def's full qualified path (the
|
|
894
|
-
--
|
|
902
|
+
-- &> join key; module-level → NULL); kind ∈ import|call|instantiate|inherit|
|
|
895
903
|
-- type|use (frozen, edge metadata only — traversal is kind-agnostic).
|
|
896
904
|
CREATE TABLE IF NOT EXISTS symbol_refs (
|
|
897
905
|
id INTEGER NOT NULL PRIMARY KEY,
|
|
@@ -942,8 +950,9 @@ CREATE TABLE IF NOT EXISTS derivation_embeddings (
|
|
|
942
950
|
-- status⊥state: status is the HTTP outcome, state is where in the
|
|
943
951
|
-- lifecycle the entry sits. Most rows write 'resolved' directly;
|
|
944
952
|
-- proposing schemes transition 'proposed' → resolved/failed/cancelled.
|
|
945
|
-
--
|
|
946
|
-
--
|
|
953
|
+
-- initial_folded is the immutable visibility with which the event entered the
|
|
954
|
+
-- log. Current model-facing membership and folded intervals belong to
|
|
955
|
+
-- log_entry_projections below; curation never rewrites or removes this event.
|
|
947
956
|
CREATE TABLE IF NOT EXISTS log_entries (
|
|
948
957
|
id INTEGER NOT NULL PRIMARY KEY,
|
|
949
958
|
version INTEGER NOT NULL DEFAULT 0 CHECK (version >= 0),
|
|
@@ -954,8 +963,9 @@ CREATE TABLE IF NOT EXISTS log_entries (
|
|
|
954
963
|
sequence INTEGER NOT NULL CHECK (sequence >= 1),
|
|
955
964
|
at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
|
|
956
965
|
origin TEXT NOT NULL CHECK (origin IN ('model', 'client', '_plurnk', 'plugin')),
|
|
957
|
-
-- {§env-delta-attribution}: a worker://
|
|
958
|
-
-- NULL = the owning worker
|
|
966
|
+
-- {§env-delta-attribution}: a causal worker:// identity, log:/// operation
|
|
967
|
+
-- address, or stable subsystem token ('file'); NULL = the owning worker
|
|
968
|
+
-- itself, rendered without causal attribution.
|
|
959
969
|
source TEXT,
|
|
960
970
|
-- Engine-owned occurrence identity. Source rows are stamped NULL→id by the
|
|
961
971
|
-- journal trigger; observer and fork copies carry it at insertion.
|
|
@@ -1015,8 +1025,8 @@ CREATE TABLE IF NOT EXISTS log_entries (
|
|
|
1015
1025
|
outcome TEXT,
|
|
1016
1026
|
attrs TEXT NOT NULL DEFAULT '{}' CHECK (json_valid(attrs)),
|
|
1017
1027
|
|
|
1018
|
-
|
|
1019
|
-
CHECK (json_valid(
|
|
1028
|
+
initial_folded TEXT NOT NULL DEFAULT '[]'
|
|
1029
|
+
CHECK (json_valid(initial_folded) AND json_type(initial_folded) = 'array'),
|
|
1020
1030
|
|
|
1021
1031
|
CHECK (
|
|
1022
1032
|
(op IS NULL) = COALESCE(
|
|
@@ -1045,6 +1055,52 @@ CREATE UNIQUE INDEX IF NOT EXISTS log_entries_worker_ambient_event
|
|
|
1045
1055
|
ON log_entries (worker_id, ambient_event_id)
|
|
1046
1056
|
WHERE ambient_event_id IS NOT NULL;
|
|
1047
1057
|
|
|
1058
|
+
-- {§log-history-projection} — log_entries is append-only execution evidence;
|
|
1059
|
+
-- this one-to-one row is the current model-facing projection of that evidence.
|
|
1060
|
+
-- KILL is a terminal active→inactive transition. OPEN/FOLD mutate only folded
|
|
1061
|
+
-- intervals while active. The initial state is created in the same statement as
|
|
1062
|
+
-- its event so no durable row can exist without one projection state.
|
|
1063
|
+
CREATE TABLE IF NOT EXISTS log_entry_projections (
|
|
1064
|
+
log_entry_id INTEGER NOT NULL PRIMARY KEY,
|
|
1065
|
+
active INTEGER NOT NULL DEFAULT 1 CHECK (active IN (0, 1)),
|
|
1066
|
+
folded TEXT NOT NULL DEFAULT '[]'
|
|
1067
|
+
CHECK (json_valid(folded) AND json_type(folded) = 'array'),
|
|
1068
|
+
FOREIGN KEY (log_entry_id) REFERENCES log_entries(id) ON DELETE CASCADE
|
|
1069
|
+
) STRICT, WITHOUT ROWID;
|
|
1070
|
+
|
|
1071
|
+
-- The ordinary operation surface reads this view. Forensic and lifecycle
|
|
1072
|
+
-- machinery names log_entries directly and therefore retains complete history.
|
|
1073
|
+
CREATE VIEW IF NOT EXISTS active_log_entries AS
|
|
1074
|
+
SELECT le.*, projection.folded
|
|
1075
|
+
FROM log_entries le
|
|
1076
|
+
JOIN log_entry_projections projection ON projection.log_entry_id = le.id
|
|
1077
|
+
WHERE projection.active = 1;
|
|
1078
|
+
|
|
1079
|
+
CREATE TRIGGER IF NOT EXISTS log_entries_initialize_projection
|
|
1080
|
+
AFTER INSERT ON log_entries
|
|
1081
|
+
BEGIN
|
|
1082
|
+
INSERT INTO log_entry_projections (log_entry_id, active, folded)
|
|
1083
|
+
VALUES (NEW.id, 1, NEW.initial_folded);
|
|
1084
|
+
END;
|
|
1085
|
+
|
|
1086
|
+
-- Individual execution events are append-only. Containing-history teardown is
|
|
1087
|
+
-- the one removal owner: a cascading delete has already removed at least one
|
|
1088
|
+
-- ancestor in the workspace→worker→loop→turn chain. A direct row delete while
|
|
1089
|
+
-- that complete owner chain remains would fabricate chronology and is rejected.
|
|
1090
|
+
CREATE TRIGGER IF NOT EXISTS log_entries_delete_with_owner_only
|
|
1091
|
+
BEFORE DELETE ON log_entries
|
|
1092
|
+
WHEN EXISTS (
|
|
1093
|
+
SELECT 1
|
|
1094
|
+
FROM turns
|
|
1095
|
+
JOIN loops ON loops.id = turns.loop_id
|
|
1096
|
+
JOIN workers ON workers.id = loops.worker_id
|
|
1097
|
+
JOIN workspaces ON workspaces.id = workers.workspace_id
|
|
1098
|
+
WHERE turns.id = OLD.turn_id
|
|
1099
|
+
)
|
|
1100
|
+
BEGIN
|
|
1101
|
+
SELECT RAISE(ABORT, 'log entries can only be removed with their containing history');
|
|
1102
|
+
END;
|
|
1103
|
+
|
|
1048
1104
|
-- A log row belongs to one exact worker/loop/turn chain. Its writer is either
|
|
1049
1105
|
-- that turn's producer or `_plurnk` observing the turn. Primitive absence,
|
|
1050
1106
|
-- enum, and foreign-key failures remain owned by their column constraints.
|
|
@@ -1091,8 +1147,8 @@ END;
|
|
|
1091
1147
|
-- A folded interval is an inclusive [start,end] pair. Ranges are positive,
|
|
1092
1148
|
-- sorted, disjoint, and non-adjacent; -1 is the final open-ended endpoint.
|
|
1093
1149
|
-- Canonical intervals make visibility equality and curation effects exact.
|
|
1094
|
-
CREATE TRIGGER IF NOT EXISTS
|
|
1095
|
-
BEFORE INSERT ON
|
|
1150
|
+
CREATE TRIGGER IF NOT EXISTS log_entry_projections_folded_valid_insert
|
|
1151
|
+
BEFORE INSERT ON log_entry_projections
|
|
1096
1152
|
WHEN EXISTS (
|
|
1097
1153
|
SELECT 1
|
|
1098
1154
|
FROM json_each(NEW.folded) range
|
|
@@ -1116,11 +1172,11 @@ WHEN EXISTS (
|
|
|
1116
1172
|
)
|
|
1117
1173
|
)
|
|
1118
1174
|
BEGIN
|
|
1119
|
-
SELECT RAISE(ABORT, 'log entry folded ranges are invalid');
|
|
1175
|
+
SELECT RAISE(ABORT, 'log entry projection folded ranges are invalid');
|
|
1120
1176
|
END;
|
|
1121
1177
|
|
|
1122
|
-
CREATE TRIGGER IF NOT EXISTS
|
|
1123
|
-
BEFORE UPDATE OF folded ON
|
|
1178
|
+
CREATE TRIGGER IF NOT EXISTS log_entry_projections_folded_valid_update
|
|
1179
|
+
BEFORE UPDATE OF folded ON log_entry_projections
|
|
1124
1180
|
WHEN EXISTS (
|
|
1125
1181
|
SELECT 1
|
|
1126
1182
|
FROM json_each(NEW.folded) range
|
|
@@ -1144,7 +1200,21 @@ WHEN EXISTS (
|
|
|
1144
1200
|
)
|
|
1145
1201
|
)
|
|
1146
1202
|
BEGIN
|
|
1147
|
-
SELECT RAISE(ABORT, 'log entry folded ranges are invalid');
|
|
1203
|
+
SELECT RAISE(ABORT, 'log entry projection folded ranges are invalid');
|
|
1204
|
+
END;
|
|
1205
|
+
|
|
1206
|
+
CREATE TRIGGER IF NOT EXISTS log_entry_projections_kill_terminal
|
|
1207
|
+
BEFORE UPDATE OF active ON log_entry_projections
|
|
1208
|
+
WHEN OLD.active = 0 AND NEW.active != 0
|
|
1209
|
+
BEGIN
|
|
1210
|
+
SELECT RAISE(ABORT, 'a killed log entry cannot re-enter the active projection');
|
|
1211
|
+
END;
|
|
1212
|
+
|
|
1213
|
+
CREATE TRIGGER IF NOT EXISTS log_entry_projections_delete_with_event_only
|
|
1214
|
+
BEFORE DELETE ON log_entry_projections
|
|
1215
|
+
WHEN EXISTS (SELECT 1 FROM log_entries WHERE id = OLD.log_entry_id)
|
|
1216
|
+
BEGIN
|
|
1217
|
+
SELECT RAISE(ABORT, 'a durable log event must retain its projection');
|
|
1148
1218
|
END;
|
|
1149
1219
|
|
|
1150
1220
|
CREATE TRIGGER IF NOT EXISTS log_entries_model_call_valid
|
|
@@ -1170,7 +1240,8 @@ BEGIN
|
|
|
1170
1240
|
END;
|
|
1171
1241
|
|
|
1172
1242
|
-- {§log-item-tags} — log classification plus OPEN/FOLD selection and mutation.
|
|
1173
|
-
--
|
|
1243
|
+
-- A containing-history teardown cascades its classifications; log KILL leaves
|
|
1244
|
+
-- both the event and its forensic classifications intact.
|
|
1174
1245
|
CREATE TABLE IF NOT EXISTS log_tags (
|
|
1175
1246
|
log_entry_id INTEGER NOT NULL,
|
|
1176
1247
|
tag TEXT NOT NULL,
|
|
@@ -1336,13 +1407,15 @@ BEGIN
|
|
|
1336
1407
|
);
|
|
1337
1408
|
END;
|
|
1338
1409
|
|
|
1339
|
-
-- Successful OPEN/FOLD rows are durable curation events even though
|
|
1340
|
-
-- ordinary packet projection is suppressed
|
|
1341
|
-
--
|
|
1342
|
-
--
|
|
1410
|
+
-- Successful OPEN/FOLD/log-KILL rows are durable curation events even though
|
|
1411
|
+
-- their ordinary packet projection is suppressed. Preserve the exact selected
|
|
1412
|
+
-- set and each target's before/after projection so a broad selector never
|
|
1413
|
+
-- collapses into the lossy fact `matched: N`.
|
|
1343
1414
|
CREATE TABLE IF NOT EXISTS log_curation_effects (
|
|
1344
1415
|
operation_log_entry_id INTEGER NOT NULL,
|
|
1345
1416
|
target_log_entry_id INTEGER NOT NULL,
|
|
1417
|
+
active_before INTEGER NOT NULL CHECK (active_before IN (0, 1)),
|
|
1418
|
+
active_after INTEGER NOT NULL CHECK (active_after IN (0, 1)),
|
|
1346
1419
|
folded_before TEXT NOT NULL
|
|
1347
1420
|
CHECK (json_valid(folded_before) AND json_type(folded_before) = 'array'),
|
|
1348
1421
|
folded_after TEXT NOT NULL
|
|
@@ -1360,9 +1433,30 @@ CREATE TABLE IF NOT EXISTS log_curation_effects (
|
|
|
1360
1433
|
CREATE INDEX IF NOT EXISTS log_curation_effects_target
|
|
1361
1434
|
ON log_curation_effects (target_log_entry_id);
|
|
1362
1435
|
|
|
1436
|
+
-- Curation effects are append-only execution evidence. They may disappear
|
|
1437
|
+
-- only when either referenced event is already being removed with its
|
|
1438
|
+
-- containing history; direct mutation while both events survive is forbidden.
|
|
1439
|
+
CREATE TRIGGER IF NOT EXISTS log_curation_effects_immutable
|
|
1440
|
+
BEFORE UPDATE ON log_curation_effects
|
|
1441
|
+
BEGIN
|
|
1442
|
+
SELECT RAISE(ABORT, 'log curation effects are immutable execution evidence');
|
|
1443
|
+
END;
|
|
1444
|
+
|
|
1445
|
+
CREATE TRIGGER IF NOT EXISTS log_curation_effects_delete_with_history_only
|
|
1446
|
+
BEFORE DELETE ON log_curation_effects
|
|
1447
|
+
WHEN EXISTS (
|
|
1448
|
+
SELECT 1 FROM log_entries WHERE id = OLD.operation_log_entry_id
|
|
1449
|
+
)
|
|
1450
|
+
AND EXISTS (
|
|
1451
|
+
SELECT 1 FROM log_entries WHERE id = OLD.target_log_entry_id
|
|
1452
|
+
)
|
|
1453
|
+
BEGIN
|
|
1454
|
+
SELECT RAISE(ABORT, 'log curation effects can only be removed with their containing history');
|
|
1455
|
+
END;
|
|
1456
|
+
|
|
1363
1457
|
-- Make an invalid curation record structurally unavailable: the event must be
|
|
1364
|
-
-- one successful OPEN/FOLD row, both rows must belong to the same
|
|
1365
|
-
--
|
|
1458
|
+
-- one successful OPEN/FOLD/log-KILL row, both rows must belong to the same
|
|
1459
|
+
-- worker, and its state transition and exact tag deltas must match that op.
|
|
1366
1460
|
CREATE TRIGGER IF NOT EXISTS log_curation_effects_valid
|
|
1367
1461
|
BEFORE INSERT ON log_curation_effects
|
|
1368
1462
|
BEGIN
|
|
@@ -1372,10 +1466,31 @@ BEGIN
|
|
|
1372
1466
|
FROM log_entries operation
|
|
1373
1467
|
JOIN log_entries target ON target.id = NEW.target_log_entry_id
|
|
1374
1468
|
WHERE operation.id = NEW.operation_log_entry_id
|
|
1375
|
-
AND operation.op IN ('OPEN', 'FOLD')
|
|
1469
|
+
AND operation.op IN ('OPEN', 'FOLD', 'KILL')
|
|
1376
1470
|
AND operation.status_rx < 400
|
|
1377
1471
|
AND operation.worker_id = target.worker_id
|
|
1378
1472
|
)
|
|
1473
|
+
OR NOT EXISTS (
|
|
1474
|
+
SELECT 1
|
|
1475
|
+
FROM log_entries operation
|
|
1476
|
+
WHERE operation.id = NEW.operation_log_entry_id
|
|
1477
|
+
AND (
|
|
1478
|
+
(
|
|
1479
|
+
operation.op IN ('OPEN', 'FOLD')
|
|
1480
|
+
AND NEW.active_before = 1
|
|
1481
|
+
AND NEW.active_after = 1
|
|
1482
|
+
)
|
|
1483
|
+
OR (
|
|
1484
|
+
operation.op = 'KILL'
|
|
1485
|
+
AND operation.scheme = 'log'
|
|
1486
|
+
AND NEW.active_before = 1
|
|
1487
|
+
AND NEW.active_after = 0
|
|
1488
|
+
AND json(NEW.folded_before) = json(NEW.folded_after)
|
|
1489
|
+
AND json_array_length(NEW.tags_added) = 0
|
|
1490
|
+
AND json_array_length(NEW.tags_removed) = 0
|
|
1491
|
+
)
|
|
1492
|
+
)
|
|
1493
|
+
)
|
|
1379
1494
|
OR EXISTS (
|
|
1380
1495
|
SELECT 1
|
|
1381
1496
|
FROM (
|
|
@@ -1450,27 +1565,29 @@ BEGIN
|
|
|
1450
1565
|
END;
|
|
1451
1566
|
|
|
1452
1567
|
-- The dispatcher binds an exact, transient curation plan into attrs on the
|
|
1453
|
-
-- successful OPEN/FOLD row. No other row may carry that
|
|
1568
|
+
-- successful OPEN/FOLD/log-KILL row. No other row may carry that payload.
|
|
1454
1569
|
CREATE TRIGGER IF NOT EXISTS log_entries_curation_payload_valid
|
|
1455
1570
|
BEFORE INSERT ON log_entries
|
|
1456
1571
|
WHEN json_type(NEW.attrs, '$.__plurnk_curation') IS NOT NULL
|
|
1457
1572
|
AND NOT (
|
|
1458
|
-
NEW.op IN ('OPEN', 'FOLD')
|
|
1573
|
+
NEW.op IN ('OPEN', 'FOLD', 'KILL')
|
|
1459
1574
|
AND NEW.status_rx < 400
|
|
1575
|
+
AND (NEW.op != 'KILL' OR NEW.scheme = 'log')
|
|
1460
1576
|
AND json_type(NEW.attrs, '$.__plurnk_curation') = 'object'
|
|
1461
1577
|
)
|
|
1462
1578
|
BEGIN
|
|
1463
|
-
SELECT RAISE(ABORT, 'private log curation payload requires a successful
|
|
1579
|
+
SELECT RAISE(ABORT, 'private log curation payload requires a successful log curation row');
|
|
1464
1580
|
END;
|
|
1465
1581
|
|
|
1466
1582
|
-- One outer INSERT owns the whole landed curation event: exact selected rows,
|
|
1467
|
-
-- their before/after
|
|
1468
|
-
--
|
|
1469
|
-
--
|
|
1583
|
+
-- their before/after projection and tag deltas, and the resulting current
|
|
1584
|
+
-- state. Trigger failure rolls the operation row and all effects back together.
|
|
1585
|
+
-- The private plan is erased before INSERT returns.
|
|
1470
1586
|
CREATE TRIGGER IF NOT EXISTS log_entries_apply_curation
|
|
1471
1587
|
AFTER INSERT ON log_entries
|
|
1472
|
-
WHEN NEW.op IN ('OPEN', 'FOLD')
|
|
1588
|
+
WHEN NEW.op IN ('OPEN', 'FOLD', 'KILL')
|
|
1473
1589
|
AND NEW.status_rx < 400
|
|
1590
|
+
AND (NEW.op != 'KILL' OR NEW.scheme = 'log')
|
|
1474
1591
|
AND json_type(NEW.attrs, '$.__plurnk_curation') = 'object'
|
|
1475
1592
|
BEGIN
|
|
1476
1593
|
SELECT CASE WHEN
|
|
@@ -1484,20 +1601,24 @@ BEGIN
|
|
|
1484
1601
|
WHERE selected.type != 'object'
|
|
1485
1602
|
OR COALESCE(json_type(selected.value, '$.id'), '') != 'integer'
|
|
1486
1603
|
OR json_extract(selected.value, '$.id') <= 0
|
|
1487
|
-
OR COALESCE(json_type(selected.value, '$.
|
|
1488
|
-
OR
|
|
1604
|
+
OR COALESCE(json_type(selected.value, '$.activeBefore'), '') != 'integer'
|
|
1605
|
+
OR json_extract(selected.value, '$.activeBefore') NOT IN (0, 1)
|
|
1606
|
+
OR COALESCE(json_type(selected.value, '$.activeAfter'), '') != 'integer'
|
|
1607
|
+
OR json_extract(selected.value, '$.activeAfter') NOT IN (0, 1)
|
|
1608
|
+
OR COALESCE(json_type(selected.value, '$.foldedBefore'), '') != 'array'
|
|
1609
|
+
OR COALESCE(json_type(selected.value, '$.foldedAfter'), '') != 'array'
|
|
1489
1610
|
OR EXISTS (
|
|
1490
1611
|
SELECT 1 FROM json_each(selected.value) field
|
|
1491
|
-
WHERE field.key NOT IN ('id', '
|
|
1612
|
+
WHERE field.key NOT IN ('id', 'activeBefore', 'activeAfter', 'foldedBefore', 'foldedAfter')
|
|
1492
1613
|
)
|
|
1493
1614
|
OR EXISTS (
|
|
1494
1615
|
SELECT 1
|
|
1495
1616
|
FROM (
|
|
1496
1617
|
SELECT 'before' AS side, range.key, range.value, range.type
|
|
1497
|
-
FROM json_each(json_extract(selected.value, '$.
|
|
1618
|
+
FROM json_each(json_extract(selected.value, '$.foldedBefore')) range
|
|
1498
1619
|
UNION ALL
|
|
1499
1620
|
SELECT 'after' AS side, range.key, range.value, range.type
|
|
1500
|
-
FROM json_each(json_extract(selected.value, '$.
|
|
1621
|
+
FROM json_each(json_extract(selected.value, '$.foldedAfter')) range
|
|
1501
1622
|
) range
|
|
1502
1623
|
WHERE range.type != 'array'
|
|
1503
1624
|
OR json_array_length(range.value) != 2
|
|
@@ -1512,8 +1633,8 @@ BEGIN
|
|
|
1512
1633
|
SELECT 1
|
|
1513
1634
|
FROM json_each(
|
|
1514
1635
|
CASE range.side
|
|
1515
|
-
WHEN 'before' THEN json_extract(selected.value, '$.
|
|
1516
|
-
ELSE json_extract(selected.value, '$.
|
|
1636
|
+
WHEN 'before' THEN json_extract(selected.value, '$.foldedBefore')
|
|
1637
|
+
ELSE json_extract(selected.value, '$.foldedAfter')
|
|
1517
1638
|
END
|
|
1518
1639
|
) previous
|
|
1519
1640
|
WHERE previous.key = range.key - 1
|
|
@@ -1534,10 +1655,28 @@ BEGIN
|
|
|
1534
1655
|
SELECT 1
|
|
1535
1656
|
FROM json_each(NEW.attrs, '$.__plurnk_curation.targets') selected
|
|
1536
1657
|
LEFT JOIN log_entries target ON target.id = json_extract(selected.value, '$.id')
|
|
1658
|
+
LEFT JOIN log_entry_projections projection ON projection.log_entry_id = target.id
|
|
1537
1659
|
WHERE target.id IS NULL
|
|
1660
|
+
OR projection.log_entry_id IS NULL
|
|
1538
1661
|
OR target.worker_id != NEW.worker_id
|
|
1539
1662
|
OR target.id = NEW.id
|
|
1540
|
-
OR
|
|
1663
|
+
OR projection.active != json_extract(selected.value, '$.activeBefore')
|
|
1664
|
+
OR json(projection.folded) != json(json_extract(selected.value, '$.foldedBefore'))
|
|
1665
|
+
OR (
|
|
1666
|
+
NEW.op IN ('OPEN', 'FOLD')
|
|
1667
|
+
AND NOT (
|
|
1668
|
+
json_extract(selected.value, '$.activeBefore') = 1
|
|
1669
|
+
AND json_extract(selected.value, '$.activeAfter') = 1
|
|
1670
|
+
)
|
|
1671
|
+
)
|
|
1672
|
+
OR (
|
|
1673
|
+
NEW.op = 'KILL'
|
|
1674
|
+
AND NOT (
|
|
1675
|
+
json_extract(selected.value, '$.activeBefore') = 1
|
|
1676
|
+
AND json_extract(selected.value, '$.activeAfter') = 0
|
|
1677
|
+
AND json(json_extract(selected.value, '$.foldedBefore')) = json(json_extract(selected.value, '$.foldedAfter'))
|
|
1678
|
+
)
|
|
1679
|
+
)
|
|
1541
1680
|
)
|
|
1542
1681
|
OR EXISTS (
|
|
1543
1682
|
SELECT 1
|
|
@@ -1588,6 +1727,8 @@ BEGIN
|
|
|
1588
1727
|
INSERT INTO log_curation_effects (
|
|
1589
1728
|
operation_log_entry_id,
|
|
1590
1729
|
target_log_entry_id,
|
|
1730
|
+
active_before,
|
|
1731
|
+
active_after,
|
|
1591
1732
|
folded_before,
|
|
1592
1733
|
folded_after,
|
|
1593
1734
|
tags_added,
|
|
@@ -1596,8 +1737,10 @@ BEGIN
|
|
|
1596
1737
|
SELECT
|
|
1597
1738
|
NEW.id,
|
|
1598
1739
|
target.id,
|
|
1599
|
-
json_extract(selected.value, '$.
|
|
1600
|
-
json_extract(selected.value, '$.
|
|
1740
|
+
json_extract(selected.value, '$.activeBefore'),
|
|
1741
|
+
json_extract(selected.value, '$.activeAfter'),
|
|
1742
|
+
json_extract(selected.value, '$.foldedBefore'),
|
|
1743
|
+
json_extract(selected.value, '$.foldedAfter'),
|
|
1601
1744
|
COALESCE((
|
|
1602
1745
|
SELECT json_group_array(ordered.tag)
|
|
1603
1746
|
FROM (
|
|
@@ -1625,13 +1768,18 @@ BEGIN
|
|
|
1625
1768
|
FROM json_each(NEW.attrs, '$.__plurnk_curation.targets') selected
|
|
1626
1769
|
JOIN log_entries target ON target.id = json_extract(selected.value, '$.id');
|
|
1627
1770
|
|
|
1628
|
-
UPDATE
|
|
1629
|
-
SET
|
|
1630
|
-
SELECT json_extract(selected.value, '$.
|
|
1771
|
+
UPDATE log_entry_projections
|
|
1772
|
+
SET active = (
|
|
1773
|
+
SELECT json_extract(selected.value, '$.activeAfter')
|
|
1631
1774
|
FROM json_each(NEW.attrs, '$.__plurnk_curation.targets') selected
|
|
1632
|
-
WHERE json_extract(selected.value, '$.id') =
|
|
1775
|
+
WHERE json_extract(selected.value, '$.id') = log_entry_projections.log_entry_id
|
|
1776
|
+
),
|
|
1777
|
+
folded = (
|
|
1778
|
+
SELECT json_extract(selected.value, '$.foldedAfter')
|
|
1779
|
+
FROM json_each(NEW.attrs, '$.__plurnk_curation.targets') selected
|
|
1780
|
+
WHERE json_extract(selected.value, '$.id') = log_entry_projections.log_entry_id
|
|
1633
1781
|
)
|
|
1634
|
-
WHERE
|
|
1782
|
+
WHERE log_entry_id IN (
|
|
1635
1783
|
SELECT json_extract(value, '$.id')
|
|
1636
1784
|
FROM json_each(NEW.attrs, '$.__plurnk_curation.targets')
|
|
1637
1785
|
);
|
|
@@ -1655,20 +1803,20 @@ BEGIN
|
|
|
1655
1803
|
WHERE id = NEW.id;
|
|
1656
1804
|
END;
|
|
1657
1805
|
|
|
1658
|
-
-- Column-scoped immutability: the original action's identity
|
|
1659
|
-
--
|
|
1660
|
-
--
|
|
1661
|
-
-- private-payload removal cannot exempt
|
|
1806
|
+
-- Column-scoped immutability: the original action's identity, target, and
|
|
1807
|
+
-- initial projection never change. Proposal lifecycle may mutate its outcome;
|
|
1808
|
+
-- curation state lives outside the event row. Keep attrs separate so the
|
|
1809
|
+
-- curation trigger's private-payload removal cannot exempt other columns.
|
|
1662
1810
|
CREATE TRIGGER IF NOT EXISTS log_entries_immutable_core
|
|
1663
1811
|
BEFORE UPDATE OF
|
|
1664
1812
|
worker_id, loop_id, turn_id, sequence, at, origin, source, inherited_history, model_call_id,
|
|
1665
1813
|
op, delimiter, signal,
|
|
1666
1814
|
scheme, username, password, hostname,
|
|
1667
1815
|
port, pathname, query, fragment,
|
|
1668
|
-
lineMarker, tx, mimetype_tx, mimetype_rx
|
|
1816
|
+
lineMarker, tx, mimetype_tx, mimetype_rx, initial_folded
|
|
1669
1817
|
ON log_entries
|
|
1670
1818
|
BEGIN
|
|
1671
|
-
SELECT RAISE(ABORT, 'log_entries core fields are immutable; only
|
|
1819
|
+
SELECT RAISE(ABORT, 'log_entries core fields are immutable; only lifecycle outcome and derived attachments may change');
|
|
1672
1820
|
END;
|
|
1673
1821
|
|
|
1674
1822
|
CREATE TRIGGER IF NOT EXISTS log_entries_immutable_attrs
|
|
@@ -2098,10 +2246,15 @@ END;
|
|
|
2098
2246
|
-- source. Composed at membership resolution; node:path.matchesGlob.
|
|
2099
2247
|
CREATE TABLE IF NOT EXISTS workspace_constraints (
|
|
2100
2248
|
workspace_id INTEGER NOT NULL,
|
|
2101
|
-
|
|
2249
|
+
-- include admits files git misses; exclude removes members — the members family's lexicon
|
|
2250
|
+
-- ({§members-projection}). An inclusion is a pattern scan; a creation record is one exact path.
|
|
2251
|
+
effect TEXT NOT NULL CHECK (effect IN ('include', 'exclude')),
|
|
2102
2252
|
glob TEXT NOT NULL,
|
|
2103
|
-
|
|
2104
|
-
|
|
2253
|
+
-- create: the exact record of a file Plurnk wrote ({§fs-create-record}); members: a
|
|
2254
|
+
-- human-authored definition projected by the members family; model: a definition the model
|
|
2255
|
+
-- proposed under the members scope — never admitted past the repository's ignore rules.
|
|
2256
|
+
source TEXT NOT NULL CHECK (source IN ('create', 'members', 'model')),
|
|
2257
|
+
CHECK (source IN ('members', 'model') OR effect = 'include'),
|
|
2105
2258
|
PRIMARY KEY (workspace_id, effect, glob),
|
|
2106
2259
|
FOREIGN KEY (workspace_id) REFERENCES workspaces(id) ON DELETE CASCADE
|
|
2107
2260
|
) STRICT, WITHOUT ROWID;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plurnk/plurnk-service",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"description": "Plurnk agent runtime — the server / engine / core. Implements the @plurnk/plurnk-contracts contract.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -87,43 +87,41 @@
|
|
|
87
87
|
"@opentelemetry/resources": "^2.10.0",
|
|
88
88
|
"@opentelemetry/sdk-metrics": "^2.10.0",
|
|
89
89
|
"@opentelemetry/sdk-trace-base": "^2.10.0",
|
|
90
|
-
"@plurnk/gbnf": "1.
|
|
91
|
-
"@plurnk/plurnk-a2a": "1.
|
|
92
|
-
"@plurnk/plurnk-agui": "1.
|
|
93
|
-
"@plurnk/plurnk-contracts": "1.
|
|
94
|
-
"@plurnk/plurnk-execs": "1.
|
|
95
|
-
"@plurnk/plurnk-execs-common": "1.
|
|
96
|
-
"@plurnk/plurnk-execs-
|
|
97
|
-
"@plurnk/plurnk-execs-
|
|
98
|
-
"@plurnk/plurnk-
|
|
99
|
-
"@plurnk/plurnk-
|
|
100
|
-
"@plurnk/plurnk-
|
|
101
|
-
"@plurnk/plurnk-
|
|
102
|
-
"@plurnk/plurnk-
|
|
103
|
-
"@plurnk/plurnk-mimetypes": "1.
|
|
104
|
-
"@plurnk/plurnk-mimetypes-application-
|
|
105
|
-
"@plurnk/plurnk-mimetypes-application-
|
|
106
|
-
"@plurnk/plurnk-mimetypes-
|
|
107
|
-
"@plurnk/plurnk-mimetypes-
|
|
108
|
-
"@plurnk/plurnk-mimetypes-
|
|
109
|
-
"@plurnk/plurnk-mimetypes-text-
|
|
110
|
-
"@plurnk/plurnk-mimetypes-text-
|
|
111
|
-
"@plurnk/plurnk-mimetypes-text-
|
|
112
|
-
"@plurnk/plurnk-mimetypes-text-
|
|
113
|
-
"@plurnk/plurnk-mimetypes-text-
|
|
114
|
-
"@plurnk/plurnk-
|
|
115
|
-
"@plurnk/plurnk-
|
|
116
|
-
"@plurnk/plurnk-
|
|
117
|
-
"@plurnk/plurnk-
|
|
118
|
-
"@plurnk/plurnk-schemes": "1.10.0",
|
|
119
|
-
"@plurnk/plurnk-schemes-http": "1.10.0",
|
|
90
|
+
"@plurnk/gbnf": "1.11.0",
|
|
91
|
+
"@plurnk/plurnk-a2a": "1.11.0",
|
|
92
|
+
"@plurnk/plurnk-agui": "1.11.0",
|
|
93
|
+
"@plurnk/plurnk-contracts": "1.11.0",
|
|
94
|
+
"@plurnk/plurnk-execs": "1.11.0",
|
|
95
|
+
"@plurnk/plurnk-execs-common": "1.11.0",
|
|
96
|
+
"@plurnk/plurnk-execs-jq": "1.11.0",
|
|
97
|
+
"@plurnk/plurnk-execs-sqlite": "1.11.0",
|
|
98
|
+
"@plurnk/plurnk-hooks": "1.11.0",
|
|
99
|
+
"@plurnk/plurnk-mcp": "1.11.0",
|
|
100
|
+
"@plurnk/plurnk-meta": "1.11.0",
|
|
101
|
+
"@plurnk/plurnk-mimetypes": "1.11.0",
|
|
102
|
+
"@plurnk/plurnk-mimetypes-application-ipynb": "1.11.0",
|
|
103
|
+
"@plurnk/plurnk-mimetypes-application-json": "1.11.0",
|
|
104
|
+
"@plurnk/plurnk-mimetypes-application-jsonl": "1.11.0",
|
|
105
|
+
"@plurnk/plurnk-mimetypes-application-xml": "1.11.0",
|
|
106
|
+
"@plurnk/plurnk-mimetypes-embeddings": "1.11.0",
|
|
107
|
+
"@plurnk/plurnk-mimetypes-text-csv": "1.11.0",
|
|
108
|
+
"@plurnk/plurnk-mimetypes-text-diff": "1.11.0",
|
|
109
|
+
"@plurnk/plurnk-mimetypes-text-dotenv": "1.11.0",
|
|
110
|
+
"@plurnk/plurnk-mimetypes-text-html": "1.11.0",
|
|
111
|
+
"@plurnk/plurnk-mimetypes-text-ini": "1.11.0",
|
|
112
|
+
"@plurnk/plurnk-mimetypes-text-markdown": "1.11.0",
|
|
113
|
+
"@plurnk/plurnk-mimetypes-text-plain": "1.11.0",
|
|
114
|
+
"@plurnk/plurnk-models": "1.11.0",
|
|
115
|
+
"@plurnk/plurnk-providers": "1.11.0",
|
|
116
|
+
"@plurnk/plurnk-schemes": "1.11.0",
|
|
117
|
+
"@plurnk/plurnk-schemes-http": "1.11.0",
|
|
120
118
|
"@possumtech/sqlrite": "^6.5.2",
|
|
121
119
|
"diff": "^9.0.0",
|
|
122
120
|
"yaml": "^2.9.0"
|
|
123
121
|
},
|
|
124
122
|
"devDependencies": {
|
|
125
123
|
"@opentelemetry/core": "^2.10.0",
|
|
126
|
-
"@plurnk/plurnk-mimetypes-tokenizers": "1.
|
|
124
|
+
"@plurnk/plurnk-mimetypes-tokenizers": "1.11.0",
|
|
127
125
|
"@types/diff": "^7.0.2"
|
|
128
126
|
},
|
|
129
127
|
"homepage": "https://github.com/plurnk/plurnk-service/tree/main/plurnk-core#readme",
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type LoopFlags } from "@plurnk/plurnk-contracts";
|
|
2
|
-
import type { Db } from "./Db.ts";
|
|
3
|
-
export default class LoopFlagsReader {
|
|
4
|
-
static parse(raw: string, loopId: number): LoopFlags;
|
|
5
|
-
static read(db: Db, loopId: number): Promise<LoopFlags>;
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=LoopFlagsReader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LoopFlagsReader.d.ts","sourceRoot":"","sources":["../../src/core/LoopFlagsReader.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,SAAS,EACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAIlC,MAAM,CAAC,OAAO,OAAO,eAAe;IAChC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,CAmBnD;IAED,OAAa,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAM5D;CACJ"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_LOOP_FLAGS, Validator, } from "@plurnk/plurnk-contracts";
|
|
2
|
-
// {§loop-flags-effective-read} — persistence may contain a partial object, but
|
|
3
|
-
// runtime policy is always the complete contracts-owned shape.
|
|
4
|
-
export default class LoopFlagsReader {
|
|
5
|
-
static parse(raw, loopId) {
|
|
6
|
-
let partial;
|
|
7
|
-
try {
|
|
8
|
-
partial = JSON.parse(raw);
|
|
9
|
-
}
|
|
10
|
-
catch (cause) {
|
|
11
|
-
throw new Error(`Loop ${loopId} has invalid persisted flags JSON.`, { cause });
|
|
12
|
-
}
|
|
13
|
-
if (partial === null || typeof partial !== "object" || Array.isArray(partial)) {
|
|
14
|
-
throw new Error(`Loop ${loopId} has invalid persisted flags.`, {
|
|
15
|
-
cause: new TypeError("Persisted loop flags must be a JSON object."),
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
try {
|
|
19
|
-
return Validator.assertLoopFlags({ ...DEFAULT_LOOP_FLAGS, ...partial });
|
|
20
|
-
}
|
|
21
|
-
catch (cause) {
|
|
22
|
-
throw new Error(`Loop ${loopId} has invalid persisted flags.`, { cause });
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
static async read(db, loopId) {
|
|
26
|
-
const row = await db.engine_get_loop_flags.get({ loop_id: loopId });
|
|
27
|
-
if (row === undefined) {
|
|
28
|
-
throw new Error(`Loop ${loopId} does not exist while reading its persisted flags.`);
|
|
29
|
-
}
|
|
30
|
-
return LoopFlagsReader.parse(row.flags, loopId);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=LoopFlagsReader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LoopFlagsReader.js","sourceRoot":"","sources":["../../src/core/LoopFlagsReader.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,kBAAkB,EAClB,SAAS,GAEZ,MAAM,0BAA0B,CAAC;AAGlC,+EAA+E;AAC/E,+DAA+D;AAC/D,MAAM,CAAC,OAAO,OAAO,eAAe;IAChC,MAAM,CAAC,KAAK,CAAC,GAAW,EAAE,MAAc;QACpC,IAAI,OAAgB,CAAC;QACrB,IAAI,CAAC;YACD,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,QAAQ,MAAM,oCAAoC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QACnF,CAAC;QAED,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5E,MAAM,IAAI,KAAK,CAAC,QAAQ,MAAM,+BAA+B,EAAE;gBAC3D,KAAK,EAAE,IAAI,SAAS,CAAC,6CAA6C,CAAC;aACtE,CAAC,CAAC;QACP,CAAC;QAED,IAAI,CAAC;YACD,OAAO,SAAS,CAAC,eAAe,CAAC,EAAE,GAAG,kBAAkB,EAAE,GAAG,OAAO,EAAe,CAAC,CAAC;QACzF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,QAAQ,MAAM,+BAA+B,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC9E,CAAC;IACL,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAM,EAAE,MAAc;QACpC,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,qBAAqB,CAAC,GAAG,CAAoB,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QACvF,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,QAAQ,MAAM,oDAAoD,CAAC,CAAC;QACxF,CAAC;QACD,OAAO,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC;CACJ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveForLoop.d.ts","sourceRoot":"","sources":["../../src/core/resolveForLoop.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,CAAC,OAAO,OAAO,cAAc;IAC/B,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,CAE1F;CACJ"}
|