@plurnk/plurnk-service 0.19.0 → 0.21.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/SPEC.md +56 -11
- package/bin/plurnk-service.ts +1 -0
- package/dist/core/Engine.d.ts +1 -1
- package/dist/core/Engine.js +5 -5
- package/dist/core/git-membership.js +2 -2
- package/dist/core/git-membership.js.map +1 -1
- package/dist/schemes/Log.js +1 -1
- package/dist/schemes/Plurnk.js +1 -1
- package/dist/schemes/_entry-find.d.ts.map +1 -1
- package/dist/schemes/_entry-find.js +10 -4
- package/dist/schemes/_entry-find.js.map +1 -1
- package/dist/schemes/_entry-manifest.d.ts.map +1 -1
- package/dist/schemes/_entry-manifest.js +34 -15
- package/dist/schemes/_entry-manifest.js.map +1 -1
- package/dist/schemes/_entry-semantic.d.ts +13 -0
- package/dist/schemes/_entry-semantic.d.ts.map +1 -0
- package/dist/schemes/_entry-semantic.js +67 -0
- package/dist/schemes/_entry-semantic.js.map +1 -0
- package/dist/schemes/cosine.d.ts +4 -0
- package/dist/schemes/cosine.d.ts.map +1 -0
- package/dist/schemes/cosine.js +9 -0
- package/dist/schemes/cosine.js.map +1 -0
- package/dist/server/envelope.d.ts +3 -0
- package/dist/server/envelope.d.ts.map +1 -1
- package/dist/server/envelope.js +20 -0
- package/dist/server/envelope.js.map +1 -1
- package/dist/server/logEntry.d.ts +2 -0
- package/dist/server/logEntry.d.ts.map +1 -1
- package/dist/server/logEntry.js +2 -0
- package/dist/server/logEntry.js.map +1 -1
- package/dist/server/methods/loop_cancel.d.ts.map +1 -1
- package/dist/server/methods/loop_cancel.js +5 -2
- package/dist/server/methods/loop_cancel.js.map +1 -1
- package/dist/server/methods/loop_run.d.ts.map +1 -1
- package/dist/server/methods/loop_run.js +6 -2
- package/dist/server/methods/loop_run.js.map +1 -1
- package/dist/server/methods/session_attach.d.ts.map +1 -1
- package/dist/server/methods/session_attach.js +3 -0
- package/dist/server/methods/session_attach.js.map +1 -1
- package/migrations/0000-00-00.01_schema.sql +29 -1
- package/package.json +12 -10
- package/requirements.md +9 -0
package/SPEC.md
CHANGED
|
@@ -50,9 +50,9 @@ Independent axes on entries and channels. Confusion across them is a recurring s
|
|
|
50
50
|
|
|
51
51
|
| Term | Meaning |
|
|
52
52
|
|---|---|
|
|
53
|
-
| **writer** | The identity authoring a write. One of `model \| client \|
|
|
53
|
+
| **writer** | The identity authoring a write. One of `model \| client \| plurnk \| plugin`. Carried on `ctx.writer` for schemes; engine enforces `manifest.writableBy`. |
|
|
54
54
|
| **origin** | Synonym for writer in log_entries (`log_entries.origin`). Historical naming; treat as equivalent. |
|
|
55
|
-
| **writable_by** | The set of writers a scheme accepts. Subset of `{model, client,
|
|
55
|
+
| **writable_by** | The set of writers a scheme accepts. Subset of `{model, client, plurnk, plugin}`. Engine rejects writes outside the set with 403; the rejection is logged as the action-entry (§7.1 action-entry-as-outcome). |
|
|
56
56
|
|
|
57
57
|
### §0.5 Engine rails
|
|
58
58
|
|
|
@@ -224,7 +224,7 @@ interface PlurnkSchemeContext {
|
|
|
224
224
|
readonly runId: number;
|
|
225
225
|
readonly loopId: number;
|
|
226
226
|
readonly turnId: number;
|
|
227
|
-
readonly writer: "model" | "client" | "
|
|
227
|
+
readonly writer: "model" | "client" | "plurnk" | "plugin";
|
|
228
228
|
readonly signal: AbortSignal | undefined;
|
|
229
229
|
readonly streamEventNotify?: StreamEventNotify;
|
|
230
230
|
readonly wakeRunNotify?: WakeRunNotify;
|
|
@@ -258,10 +258,11 @@ Per author contract. Manifest declares `kind: "mimetype"`; handler class declare
|
|
|
258
258
|
|
|
259
259
|
### §4.2 Methods
|
|
260
260
|
|
|
261
|
-
Author contract owned by plurnk-mimetypes. plurnk-service consumes
|
|
261
|
+
Author contract owned by plurnk-mimetypes. plurnk-service consumes ONE entry point:
|
|
262
262
|
|
|
263
|
-
- `Mimetypes.process(input)` — projection entry point; returns the structural projections
|
|
264
|
-
|
|
263
|
+
- `Mimetypes.process(input)` — the projection entry point; returns the structural projections (`deepJson` / `deepXml` / `symbols` / `references`) + extent (`totalLines`). {§4.2-process-entry-point}
|
|
264
|
+
|
|
265
|
+
**The daughter projects; the service queries.** `Mimetypes.query()` exists in the author contract, but plurnk-service does NOT consume it. The service owns **all** dialect matching — glob, regex, jsonpath, xpath, `@graph`, `~semantic` — resolved in-tree over those projections plus its own indexes (`symbol_defs`/`symbol_refs`, FTS5, vectors). mimetypes is mimetype-*literate* (content→structure); the service is dialect-*literate* (structure→matches). The pattern-matching DSL is plurnk's defining surface — the service's authority, never a daughter's.
|
|
265
266
|
|
|
266
267
|
Cross-cutting promises service relies on:
|
|
267
268
|
|
|
@@ -745,6 +746,8 @@ registry.register("loop.run", {
|
|
|
745
746
|
|
|
746
747
|
**Auto-envelope.** Clients calling a `requiresInit: true` method without first attaching get auto-created session → run → client loop. Records persist normally; auto-created ≠ auto-deleted. Cleanup is a future `session.delete` / `session.archive` endpoint. {§13.5-auto-envelope}
|
|
747
748
|
|
|
749
|
+
**Reserved run names.** `plurnk` is reserved for the runtime actor (§0.4). `session.attach` rejects it — case-insensitively, *before* the lookup-or-create — so a client can neither forge a `plurnk` run nor resume the runtime's, closing impersonation of `origin=plurnk`. The auto-namer never emits a reserved name. {§13.5-run-name-reserved}
|
|
750
|
+
|
|
748
751
|
**Loops (model-driven)**
|
|
749
752
|
|
|
750
753
|
| Method | Params | Result | Notes |
|
|
@@ -761,6 +764,8 @@ registry.register("loop.run", {
|
|
|
761
764
|
| `entry.read` | `target: string` | `{ status, entry }` | Read the full entry shape (channels + tags + metadata) at the given URI. {§13.5-entry-read} |
|
|
762
765
|
| `log.read` | `loopId?: number`, … | `{ entries: LogEntry[] }` | Read recent log entries from the attached session, optionally filtered by loop. {§13.5-log-read} |
|
|
763
766
|
|
|
767
|
+
**Log coordinate.** Every `LogEntry` — from `log.read` and the `log/entry` notification alike — carries `loop_seq`/`turn_seq`, the loop+turn ordinals, beside the `loop_id`/`turn_id` DB keys, so a client renders the logical coordinate (e.g. `01/02/03`) without resolving ids. {§13.5-log-coordinate}
|
|
768
|
+
|
|
764
769
|
**DSL operations (client-driven, mirror grammar)**
|
|
765
770
|
|
|
766
771
|
Per the **Speak in DSL, not plumbing** rule (AGENTS.md): `op.*` methods construct DSL statements internally and dispatch through `Engine.dispatch`. {§13.5-op-mirror} Param shapes are ergonomic (semantic names, not HEREDOC slots); semantics are the DSL's.
|
|
@@ -832,9 +837,9 @@ Server-initiated events on the same WebSocket.
|
|
|
832
837
|
| (daemon closes the client loop; session keeps)|
|
|
833
838
|
```
|
|
834
839
|
|
|
835
|
-
**
|
|
840
|
+
**The client's run.** A client connection is an actor (§14.8); its `op.*` write to its **own run** — `origin = "client"`, one loop per connection — and `log.read` reads that run. Disconnect closes the loop's status; rows persist. Multiple connections each get their own client run.
|
|
836
841
|
|
|
837
|
-
`loop.run`
|
|
842
|
+
`loop.run` and `inject` target the **model's run** — a separate run holding the conversation, `origin = "model"`. Both runs share the session's one filesystem (§14.8); the packet renders only the model's run, so the client's ops are structurally absent from it — no origin filter (§14.7-isolation). *Migration:* the daemon today opens both loops in the connection's one run (the conflation §14.8 corrects); the build gives the client and the model their separate runs.
|
|
838
843
|
|
|
839
844
|
### §13.8 Errors
|
|
840
845
|
|
|
@@ -953,9 +958,9 @@ Each entry: question, answer, rationale, migration path.
|
|
|
953
958
|
|
|
954
959
|
**Question.** The manifest (§15) is a live directory of what *exists*, re-derived each turn — but it carries *state*, not *events*. When a session entry changes out-of-band between turns — an exec stream grows, a sibling run edits a shared entry, a tracked file diverges on disk (§14.3) — the model's prior READ is now stale, and the manifest's new line count is a fact it must *diff against its own memory* to notice. The manifest also cannot say *who* changed it; with more than one actor in a session, provenance is load-bearing. What surfaces change — losslessly, attributably, without curating?
|
|
955
960
|
|
|
956
|
-
**Decision — a per-run delta of
|
|
961
|
+
**Decision — a per-run delta of plurnk-authored EDITs.** When a session entry changes out-of-band, the engine records it the way the model records its *own* edits: a `log_entries` row, op=`EDIT`, `origin=plurnk`, carrying the new `source` attribution (the cause). The body is exactly an EDIT's body — **the edited area as it looks now, line-numbered, with a couple lines of context** (the result-rendering all EDITs share, §14.6). The set is **exhaustive and unranked** — every change, no relevance order — but **not content-free**: showing the edited region of a change that *happened* is a faithful record, not the index regrowing. The engine may inform (the §14.3 EMI divergence is the precedent), never rank or select what the model retains; the one line it must never cross is *ranking*. Volume is the model's to manage by FOLD (and the grinder's under budget), not the engine's to manage by gutting the payload.
|
|
957
962
|
|
|
958
|
-
**Form — a log entry, `origin=
|
|
963
|
+
**Form — a log entry, `origin=plurnk`, the change translated to DSL.** A delta is a `log_entries` row: an **`EDIT`** ("an EDIT happened to X"), `origin=plurnk`, carrying the new **`source`** column — the cause. A log entry, not a transient frame section, because a run's timeline must be **self-contained** (a forked run carries everything it observed). `source` renders as `run="<id>"` / `run="file"` in the meta line, **omitted when the cause is the owning run itself**. It is a third attribution axis, distinct from `run_id` (whose log owns the row) and `origin` (the actor *type*).
|
|
959
964
|
|
|
960
965
|
**Passive — computed at build, never forces a turn.** A delta materializes only while a packet is being assembled, so a change has nowhere to land until something else has already started a turn — it cannot wake an idle model. "Inform, never override," as mechanism. Urgency that genuinely needs the model routes through the *voice* door (an inject), never the environment door promoting itself to a turn.
|
|
961
966
|
|
|
@@ -977,6 +982,46 @@ Each entry: question, answer, rationale, migration path.
|
|
|
977
982
|
|
|
978
983
|
**Migration path.** Changes what EDIT rows *show* (input → output); the op surface and EDIT's behaviour are unchanged. Tests asserting the input-heredoc render move to the resulting-span render.
|
|
979
984
|
|
|
985
|
+
### §14.7 The actor boundary: isolation by run, two doors, self-hosting
|
|
986
|
+
|
|
987
|
+
**Question.** A session holds many runs — model, client, plurnk (§0.1, §0.4) — over one shared manifest. What keeps one run's activity out of another's conversation; what are the *only* ways a run's work reaches another; and does the engine's own work obey the boundary or get a privileged back channel?
|
|
988
|
+
|
|
989
|
+
**Decision — isolation by run; the model is not privileged.** A packet renders exactly one run's log — the assembling run's — against the session's shared manifest (§15). A run cannot see another's log: isolation is *structural*, a consequence of "a run owns its log entries" (§0.1) and "one packet, one run," never an `origin` filter at render time. `origin` (§0.4) is **attribution** — the delta's provenance (§14.5) — never read to hide a row. {§14.7-isolation} {§14.7-origin-not-filter}
|
|
990
|
+
|
|
991
|
+
**Two doors, and only two.** A run's work reaches another run by exactly two channels, and a private log is reachable no other way:
|
|
992
|
+
- the **environment door** — a write to a *shared entry* surfaces to every run sharing it as a folded, attributed delta (§14.5). *State.*
|
|
993
|
+
- the **voice door** — an **inject** delivers a turn into a *specific* run's log; `btw` is the user's mid-loop inject. *Message.*
|
|
994
|
+
|
|
995
|
+
{§14.7-two-doors}
|
|
996
|
+
|
|
997
|
+
**Wild west — no mutual exclusion.** Runs share the manifest without locks. Coordination is cooperative (tags + the shared workspace convention) and softly fenced (the §14.3 `read-only` overlay, a session policy, bounds every run's writable surface uniformly — §14.8); a conflict *surfaces* as a delta rather than being prevented. Inform, never override. {§14.7-no-mutex}
|
|
998
|
+
|
|
999
|
+
**Passive wake.** An idle run wakes on exactly two events — a prompt injected into it (voice; user or system) or a stream-status transition it subscribes to (§5.6). A delta never wakes a run; it queues and drains at the next turn one of those produces (§14.5). {§14.7-passive-wake}
|
|
1000
|
+
|
|
1001
|
+
**Self-hosting — the runtime is an actor, not a back channel.** Runtime-initiated work (fs reconciliation §14.3, git auto-add) is an **ephemeral `plurnk` run** firing ordinary ops, seen by other runs through the environment door like any actor's — not a privileged engine pathway. The engine keeps only the irreducible kernel runs stand on (spawn, dispatch, packet assembly, the budget rails §14.4, the fs-watch); everything expressible as ops on session entries is a run doing ops, through the same `op.*` surface (§13.5) the service offers clients. Dogfooding is the architecture, not a test mode. {§14.7-self-hosting}
|
|
1002
|
+
|
|
1003
|
+
**Migration path.** Largely realized: `Engine.dispatch` is origin-agnostic; client ops run in a per-connection client loop (`_dispatchAsClient`); plurnk EDITs already carry `origin=plurnk`. What remains is *repatriation* — the inline plurnk dispatches (the §14.5 materialization, today bolted into the model's loop) move into ephemeral plurnk runs via a headless spawn primitive mirroring `_dispatchAsClient`. Once every mutation is a run-scoped action, SAVEPOINT-nested rollback (run → loop → turn → action) falls out uniformly.
|
|
1004
|
+
|
|
1005
|
+
### §14.8 The machine and its processes: session, run, fork
|
|
1006
|
+
|
|
1007
|
+
**Question.** §14.7 isolates runs and lets the runtime self-host, but it stands on an ownership model it never states: what does a *session* own versus a *run*; what is shared versus private; and what does a fork carry? Unstated, the downstream questions — which run `log.read` reads, what a fork copies, where a per-client view of the workspace would live — grow subtle, then metastasize. Drawn once, they vanish.
|
|
1008
|
+
|
|
1009
|
+
**Decision — the session is the world; a run is a log on it.** A **session** is the world: one shared filesystem — the `session`-scoped entries, surfaced as `plurnk://manifest.json` (§15) — under one membership overlay (§14.3). Exactly one filesystem and one overlay per session; neither is per-run. A **run** is a process whose entire private memory is its **log** (§0.1) — its loops, turns, and rows, each row carrying its own content, attribution (`origin`/`source`, §14.5), and fold-state (`indexed`). A run owns **no entries** and **no membership**; even its visibility is not a possession but a bit on its own rows. It is a *history over the shared world, not a world*.
|
|
1010
|
+
|
|
1011
|
+
**One filesystem.** The entries are the session's: `entries.session_id`, never a run. A write by any run is a write to the one filesystem every run reads; there is no per-run entry set. {§14.8-one-filesystem}
|
|
1012
|
+
|
|
1013
|
+
**One overlay.** Membership — `git ls-files ∪ add − ignore` with read-only (§14.3) — is the session's: `session_constraints.session_id`, never a run. It is workspace *curation*, and the workspace *is* the session; two runs are two conversations about one curated workspace and see the same one. Divergent membership is a different session, never a per-run overlay. {§14.8-one-overlay}
|
|
1014
|
+
|
|
1015
|
+
**A run is its log — and nothing beside.** The run-private state is the log and only the log. *What I am looking at* (OPEN/FOLD) is `log_entries.indexed`, a bit on the run's own rows, toggled by ordinary `log://` ops — not a second store, and never membership (§6.3). *What I last saw* needs no shadow either: a run learns its world moved through log entries (§14.5) — a sibling's write broadcast into its log, an out-of-band disk change detected against the entry's own content and broadcast the same way — never through a per-run snapshot the run cannot see. The log is the whole of a run's memory. {§14.8-run-is-its-log}
|
|
1016
|
+
|
|
1017
|
+
**Fork — copy the log, share the world.** A fork is a new run in the *same* session (`runs.parent_run_id`, §0.1), taken at a savepoint. It copies the **log** — the rows, their fold-state riding along — so the branch inherits everything the parent observed (§14.5 makes a run's timeline self-contained for exactly this) and diverges freely after. {§14.8-fork-copies-the-log} It shares the **world** — the one filesystem, the one overlay — live and uncopied, because the run never owned it. {§14.8-fork-shares-the-world}
|
|
1018
|
+
|
|
1019
|
+
**A session cannot be forked.** There is nothing to branch — a session *is* the shared ground. `runs` carries `parent_run_id`; `sessions` carries no parent. Parallel histories over one workspace are forks of its runs; a divergent workspace is a new session. {§14.8-no-fork-session}
|
|
1020
|
+
|
|
1021
|
+
**Rationale.** The model falls out of one correction: *a run is a history over a shared world, not a world.* Entries are the world (session); the log is the history (run); forking a history need not copy the world, and a run accumulates nothing the log does not already hold. The overlay's session home is forced the same way — it is the world's curation, and the world is shared; per-run it fragments the one manifest, forks the membership read-gate (the §14.3 security line), and duplicates what FOLD already does at the right level. Every "which run / what's copied / where's the per-client view" answers itself once the world/log line is drawn.
|
|
1022
|
+
|
|
1023
|
+
**Migration path.** Mostly stating what the schema already carries: `runs.parent_run_id` and the parentless `sessions` exist (§0.1); `session_constraints` is session-level (§14.3); §14.5 already makes a run's timeline self-contained, so a fork's log copy suffices. Additive: the savepoint/branch *operation* and `run.fork` over the wire. Two repatriations: §14.7's "read-only overlay scopes a run's writable surface" becomes a *session* policy bounding every run uniformly; and the §14.5 environment door sheds its per-run watermark — a run's only memory is its log, so drift is the broadcast (run-caused) and the build-time disk-vs-entry diff (ambient), both landing as log entries, never a per-run snapshot.
|
|
1024
|
+
|
|
980
1025
|
---
|
|
981
1026
|
|
|
982
1027
|
## §15 Packet shape
|
|
@@ -1004,7 +1049,7 @@ type Packet = {
|
|
|
1004
1049
|
};
|
|
1005
1050
|
```
|
|
1006
1051
|
|
|
1007
|
-
**Prompt as a first-class entry.** Each loop's prompt is written on loop start as a
|
|
1052
|
+
**Prompt as a first-class entry.** Each loop's prompt is written on loop start as a plurnk-origin `EDIT` against `plurnk://prompt/<loop_id>` (indexable, body channel, text/markdown). At render time the current loop's prompt body materializes into `packet.user.prompt`; the entry itself stays READ/FOLD-able like any other.
|
|
1008
1053
|
|
|
1009
1054
|
**The entry catalog.** `plurnk://manifest.json` is a real session entry the model READs to discover what's available — rewritten every turn as a live view of the full entry set. Built in the schemes layer (`_entry-manifest`) and materialized like any entry (the engine only orchestrates the per-turn write — the same pattern as git membership), so it's READable and queryable. Body is `application/json`: a flat, **complete, unranked** array — one item per entry across all schemes, every entry listed in no relevance order, each `{ path, channels: { <name>: { mimetype, tokens, lines } } }`. The model ranks and filters the catalog itself by querying it (task-aware); the catalog never ranks for it — the instant it did, it would be an index again. `tokens` is the provider's write-time count (budget depth), `lines` the content extent from `Mimetypes.process().totalLines`. The engine counts neither. It does not list itself. {§15-manifest-catalog}
|
|
1010
1055
|
|
package/bin/plurnk-service.ts
CHANGED
|
@@ -40,6 +40,7 @@ export default class Cli {
|
|
|
40
40
|
const db = await SqlRite.open({
|
|
41
41
|
path: dbPath,
|
|
42
42
|
dir: [resolve(Cli.#projectRoot, "migrations"), resolve(Cli.#projectRoot, "src")],
|
|
43
|
+
functions: [resolve(Cli.#projectRoot, "src/schemes/cosine.ts")],
|
|
43
44
|
});
|
|
44
45
|
return db as unknown as Db;
|
|
45
46
|
}
|
package/dist/core/Engine.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { Db } from "./Db.ts";
|
|
|
5
5
|
import type { LoopFlags } from "./scheme-types.ts";
|
|
6
6
|
import type ExecutorRegistry from "./ExecutorRegistry.ts";
|
|
7
7
|
import type { StreamEventNotify, TelemetryEventNotify, WakeRunNotify } from "./ChannelWrite.ts";
|
|
8
|
-
type Origin = "model" | "client" | "
|
|
8
|
+
type Origin = "model" | "client" | "plurnk" | "plugin";
|
|
9
9
|
type ChatMessage = {
|
|
10
10
|
role: "system" | "user" | "assistant";
|
|
11
11
|
content: string;
|
package/dist/core/Engine.js
CHANGED
|
@@ -478,7 +478,7 @@ class Engine {
|
|
|
478
478
|
};
|
|
479
479
|
await this.dispatch({
|
|
480
480
|
statement: promptStmt, sessionId, runId, loopId, turnId,
|
|
481
|
-
sequence: nextActionIndex, origin: "
|
|
481
|
+
sequence: nextActionIndex, origin: "plurnk", onDispatch,
|
|
482
482
|
});
|
|
483
483
|
nextActionIndex++;
|
|
484
484
|
}
|
|
@@ -491,7 +491,7 @@ class Engine {
|
|
|
491
491
|
// per-turn write. Does not list itself.
|
|
492
492
|
const systemCtx = {
|
|
493
493
|
db: this.#db, sessionId, runId, loopId, turnId,
|
|
494
|
-
writer: "
|
|
494
|
+
writer: "plurnk",
|
|
495
495
|
signal: this.#loopAborts.get(loopId)?.signal,
|
|
496
496
|
streamEventNotify: this.#streamEventNotify,
|
|
497
497
|
wakeRunNotify: this.#wakeRunNotify,
|
|
@@ -917,7 +917,7 @@ class Engine {
|
|
|
917
917
|
}
|
|
918
918
|
// §14.5 — at pre-turn build, reconcile each session entry against this run's
|
|
919
919
|
// watermark. First sight sets it silently; a content change materializes a
|
|
920
|
-
// delta-EDIT (origin=
|
|
920
|
+
// delta-EDIT (origin=plurnk, the §14.6 result span) at the next sequence and
|
|
921
921
|
// advances the mark. Excludes plurnk:// (manifest/prompt) and bare/file
|
|
922
922
|
// entries (scheme NULL — the EMI's territory). Returns the count so the
|
|
923
923
|
// caller advances nextActionIndex past the pre-seeded deltas.
|
|
@@ -943,7 +943,7 @@ class Engine {
|
|
|
943
943
|
const span = editedSpan(wm.content, r.content);
|
|
944
944
|
await this.#db.engine_insert_log_entry.get({
|
|
945
945
|
run_id: runId, loop_id: loopId, turn_id: turnId,
|
|
946
|
-
sequence: fromSequence + written, origin: "
|
|
946
|
+
sequence: fromSequence + written, origin: "plurnk", source: r.scheme === null ? "file" : null,
|
|
947
947
|
op: "EDIT", suffix: "", signal: null,
|
|
948
948
|
scheme: r.scheme, username: null, password: null, hostname: null, port: null,
|
|
949
949
|
pathname: r.pathname, params: null, fragment: null, lineMarker: null,
|
|
@@ -1195,7 +1195,7 @@ class Engine {
|
|
|
1195
1195
|
const ctx = {
|
|
1196
1196
|
db: this.#db, sessionId: sessionRow.session_id, runId, loopId,
|
|
1197
1197
|
turnId: 0, // no turn open at inject time; entries don't pin turnId
|
|
1198
|
-
writer: "
|
|
1198
|
+
writer: "plurnk",
|
|
1199
1199
|
signal: this.#loopAborts.get(loopId)?.signal,
|
|
1200
1200
|
streamEventNotify: this.#streamEventNotify,
|
|
1201
1201
|
wakeRunNotify: this.#wakeRunNotify,
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
// D4 — git present → ls-files membership. git absent → no fs-walk (this
|
|
14
14
|
// module no-ops on a non-git project_root, leaving headless / non-git
|
|
15
15
|
// sessions completely unaffected). The add/ignore/read-only constraint
|
|
16
|
-
// overlay (session_constraints)
|
|
17
|
-
//
|
|
16
|
+
// overlay (session_constraints) layers on top: resolveMembership applies
|
|
17
|
+
// `(ls-files ∪ add) − ignore`; read-only is enforced at the File edit gate.
|
|
18
18
|
// D5 — EMI is eager + exhaustive: every active member is re-read from disk at
|
|
19
19
|
// resolution time so a divergent member reflects current disk content.
|
|
20
20
|
//
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-membership.js","sourceRoot":"","sources":["../../src/core/git-membership.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,EAAE;AACF,yEAAyE;AACzE,2EAA2E;AAC3E,4EAA4E;AAC5E,4EAA4E;AAC5E,qFAAqF;AACrF,EAAE;AACF,2BAA2B;AAC3B,iEAAiE;AACjE,gFAAgF;AAChF,+BAA+B;AAC/B,0EAA0E;AAC1E,6EAA6E;AAC7E,8EAA8E;AAC9E,
|
|
1
|
+
{"version":3,"file":"git-membership.js","sourceRoot":"","sources":["../../src/core/git-membership.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,EAAE;AACF,yEAAyE;AACzE,2EAA2E;AAC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KAAK,MAAM,QAAQ,IAAI,OAAO,EAAE,CAAC;YAC7B,MAAM,aAAa,CAAC,kBAAkB,CAAC,QAAQ,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;QAChE,CAAC;IACL,CAAC"}
|
package/dist/schemes/Log.js
CHANGED
|
@@ -38,7 +38,7 @@ export default class Log {
|
|
|
38
38
|
defaultChannel: "",
|
|
39
39
|
category: "logging",
|
|
40
40
|
scope: "session",
|
|
41
|
-
writableBy: ["
|
|
41
|
+
writableBy: ["plurnk"], // engine-only writes; model & client read + open/fold
|
|
42
42
|
volatile: false,
|
|
43
43
|
modelVisible: true,
|
|
44
44
|
};
|
package/dist/schemes/Plurnk.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_entry-find.d.ts","sourceRoot":"","sources":["../../src/schemes/_entry-find.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE1F,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"_entry-find.d.ts","sourceRoot":"","sources":["../../src/schemes/_entry-find.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE1F,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAKnF,MAAM,WAAW,UAAU;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,CAAC,OAAO,OAAO,SAAS;;WAiCb,cAAc,CACvB,SAAS,EAAE,aAAa,GAAG,aAAa,GAAG,aAAa,EACxD,GAAG,EAAE,mBAAmB,EACxB,QAAQ,EAAE,cAAc,GACzB,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;WA6DtC,kBAAkB,CAAC,SAAS,EAAE,aAAa,EAAE,GAAG,EAAE,mBAAmB,EAAE,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC;CAMrI"}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
// <L> — results pagination: select results N..M from the matched list
|
|
14
14
|
import Matcher from "../content/matcher.js";
|
|
15
15
|
import EntryGraph from "./_entry-graph.js";
|
|
16
|
+
import EntrySemantic from "./_entry-semantic.js";
|
|
16
17
|
export default class EntryFind {
|
|
17
18
|
static #scopePathnameOf(statement) {
|
|
18
19
|
const path = statement.target;
|
|
@@ -60,10 +61,15 @@ export default class EntryFind {
|
|
|
60
61
|
// name). File sets storedScheme=null — bare rows.
|
|
61
62
|
const scheme = manifest.storedScheme === undefined ? manifest.name : manifest.storedScheme;
|
|
62
63
|
if (statement.body !== null && statement.body.dialect === "semantic") {
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
|
|
64
|
+
// ~query: embed the query text, FTS-narrow by its terms, cosine-rank the
|
|
65
|
+
// narrowed set, top-K. 501 when no embeddings handler is installed (the
|
|
66
|
+
// channel degrades to empty bytes). <L> carries K.
|
|
67
|
+
const { mimetypes } = ctx;
|
|
68
|
+
if (mimetypes === undefined)
|
|
69
|
+
return { status: 501, pathnames: [] };
|
|
70
|
+
if (statement.lineMarker === null)
|
|
71
|
+
return { status: 400, pathnames: [] }; // ~query needs a top-K, e.g. ~query<10>
|
|
72
|
+
return EntrySemantic.rankSemantic(ctx.db, ctx.sessionId, scheme, mimetypes, statement.body.raw, statement.lineMarker.first);
|
|
67
73
|
}
|
|
68
74
|
const scopePathname = EntryFind.#scopePathnameOf(statement);
|
|
69
75
|
const scopeGlob = scopePathname !== null && scopePathname.length > 0 ? `${scopePathname}*` : null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_entry-find.js","sourceRoot":"","sources":["../../src/schemes/_entry-find.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,sDAAsD;AACtD,EAAE;AACF,gFAAgF;AAChF,kFAAkF;AAClF,4EAA4E;AAC5E,iFAAiF;AACjF,yEAAyE;AACzE,6EAA6E;AAC7E,iFAAiF;AACjF,oEAAoE;AACpE,oEAAoE;AACpE,4EAA4E;AAK5E,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,UAAU,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"_entry-find.js","sourceRoot":"","sources":["../../src/schemes/_entry-find.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,sDAAsD;AACtD,EAAE;AACF,gFAAgF;AAChF,kFAAkF;AAClF,4EAA4E;AAC5E,iFAAiF;AACjF,yEAAyE;AACzE,6EAA6E;AAC7E,iFAAiF;AACjF,oEAAoE;AACpE,oEAAoE;AACpE,4EAA4E;AAK5E,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,UAAU,MAAM,mBAAmB,CAAC;AAC3C,OAAO,aAAa,MAAM,sBAAsB,CAAC;AASjD,MAAM,CAAC,OAAO,OAAO,SAAS;IAC1B,MAAM,CAAC,gBAAgB,CAAC,SAAwD;QAC5E,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC;QAC9B,IAAI,IAAI,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QAC/B,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK;YAAE,OAAO,IAAI,CAAC,QAAQ,CAAC;QAC9C,OAAO,IAAI,CAAC,GAAG,CAAC;IACpB,CAAC;IAED,MAAM,CAAC,SAAS,CAAI,KAAU,EAAE,MAA8C;QAC1E,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC;QAC3B,MAAM,EAAE,KAAK,EAAE,IA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GAAG,MAAM,SAAS,CAAC,cAAc,CAAC,SAAS,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;QACvE,IAAI,KAAK,CAAC,MAAM,KAAK,GAAG;YAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;QACtG,MAAM,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,QAAQ,CAAC,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC;QACtE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC;IACzF,CAAC;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_entry-manifest.d.ts","sourceRoot":"","sources":["../../src/schemes/_entry-manifest.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"_entry-manifest.d.ts","sourceRoot":"","sources":["../../src/schemes/_entry-manifest.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAWnE,MAAM,CAAC,OAAO,OAAO,aAAa;;WAOjB,iBAAiB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;CAwD5E"}
|
|
@@ -12,8 +12,10 @@
|
|
|
12
12
|
// Lives in the schemes/entry layer, not the engine: building a plurnk:// entry's
|
|
13
13
|
// content is the schemes' job; the engine only orchestrates the per-turn write
|
|
14
14
|
// (the same materialization pattern as git membership).
|
|
15
|
+
import { createHash } from "node:crypto";
|
|
15
16
|
import { MimetypeBinary } from "../content/index.js";
|
|
16
17
|
import EntryGraph from "./_entry-graph.js";
|
|
18
|
+
import EntrySemantic from "./_entry-semantic.js";
|
|
17
19
|
export default class EntryManifest {
|
|
18
20
|
static #MANIFEST_PATH = "plurnk://manifest.json";
|
|
19
21
|
static #toPath(scheme, pathname) {
|
|
@@ -42,28 +44,45 @@ export default class EntryManifest {
|
|
|
42
44
|
entry.seconds = r.seconds;
|
|
43
45
|
// Manifest-add is the engine-side point where the mimetypes handler
|
|
44
46
|
// legitimately fires (never at a scheme write, §4). For the body channel
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
//
|
|
47
|
+
// we re-derive every deep channel from ONE process() — the @graph symbol
|
|
48
|
+
// index (#186) and the ~semantic FTS + embedding — alongside the catalog's
|
|
49
|
+
// totalLines, but ONLY when the content changed since the last derivation
|
|
50
|
+
// (the deep_hash gate). An unchanged entry just gets totalLines; its
|
|
51
|
+
// symbol/FTS/embedding rows persist. A handler predating the references
|
|
52
|
+
// channel throws → fall back to metadata-only and clear the graph rows.
|
|
50
53
|
const isBody = r.channel === "body";
|
|
51
|
-
const wantGraph = isBody && r.content.length > 0 && !MimetypeBinary.isBinaryMimetype(r.mimetype);
|
|
52
54
|
let result;
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
await EntryGraph.populateFrom(db, sessionId, r.entry_id, result.symbols ?? [], result.references ?? []);
|
|
57
|
-
}
|
|
58
|
-
catch {
|
|
55
|
+
if (isBody) {
|
|
56
|
+
const hash = createHash("sha256").update(r.content).digest("hex");
|
|
57
|
+
if (hash === r.deep_hash) {
|
|
59
58
|
result = await mimetypes.process({ content: r.content, hint: r.mimetype }, { channels: [] });
|
|
60
|
-
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
const wantGraph = r.content.length > 0 && !MimetypeBinary.isBinaryMimetype(r.mimetype);
|
|
62
|
+
if (wantGraph) {
|
|
63
|
+
try {
|
|
64
|
+
result = await mimetypes.process({ content: r.content, hint: r.mimetype }, { channels: ["symbols", "references", "embedding"] });
|
|
65
|
+
await EntryGraph.populateFrom(db, sessionId, r.entry_id, result.symbols ?? [], result.references ?? []);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
result = await mimetypes.process({ content: r.content, hint: r.mimetype }, { channels: [] });
|
|
69
|
+
await EntryGraph.populateFrom(db, sessionId, r.entry_id, [], []);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
result = await mimetypes.process({ content: r.content, hint: r.mimetype }, { channels: [] });
|
|
74
|
+
await EntryGraph.populateFrom(db, sessionId, r.entry_id, [], []);
|
|
75
|
+
}
|
|
76
|
+
// The other two deep channels: re-index the body into entry_fts
|
|
77
|
+
// (~semantic's keyword half) and store the embedding vector + model
|
|
78
|
+
// (the vector half). Empty/binary/degraded → cleared, not stored.
|
|
79
|
+
await EntrySemantic.indexFts(db, r.entry_id, r.content);
|
|
80
|
+
await EntrySemantic.indexEmbedding(db, r.entry_id, result.embedding, result.embeddingModel);
|
|
81
|
+
await db.graph_set_deep_hash.run({ entry_id: r.entry_id, deep_hash: hash });
|
|
61
82
|
}
|
|
62
83
|
}
|
|
63
84
|
else {
|
|
64
85
|
result = await mimetypes.process({ content: r.content, hint: r.mimetype }, { channels: [] });
|
|
65
|
-
if (isBody)
|
|
66
|
-
await EntryGraph.populateFrom(db, sessionId, r.entry_id, [], []);
|
|
67
86
|
}
|
|
68
87
|
entry.channels[r.channel] = { mimetype: r.mimetype, tokens: tokenize(r.content), lines: result.totalLines };
|
|
69
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_entry-manifest.js","sourceRoot":"","sources":["../../src/schemes/_entry-manifest.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,iFAAiF;AACjF,0EAA0E;AAC1E,kDAAkD;AAClD,gFAAgF;AAChF,oFAAoF;AACpF,+EAA+E;AAC/E,gFAAgF;AAChF,6EAA6E;A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
|
|
3
|
+
export default class EntrySemantic {
|
|
4
|
+
static indexFts(db: Db, entryId: number, content: string): Promise<void>;
|
|
5
|
+
static cosine(a: Uint8Array, b: Uint8Array): number;
|
|
6
|
+
static indexEmbedding(db: Db, entryId: number, embedding: Uint8Array | undefined, model: string | undefined): Promise<void>;
|
|
7
|
+
static ftsQueryFor(text: string): string;
|
|
8
|
+
static rankSemantic(db: Db, sessionId: number, scheme: string | null, mimetypes: Mimetypes, queryText: string, k: number): Promise<{
|
|
9
|
+
status: number;
|
|
10
|
+
pathnames: string[];
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=_entry-semantic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_entry-semantic.d.ts","sourceRoot":"","sources":["../../src/schemes/_entry-semantic.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,EAAE,EAAc,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE1D,MAAM,CAAC,OAAO,OAAO,aAAa;WAGjB,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS9E,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,MAAM;WAYtC,cAAc,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAUjI,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;WAS3B,YAAY,CAAC,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;CAYpL"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// ~semantic (plurnk-service#186) — the FTS half. Re-indexes an entry's body
|
|
2
|
+
// content into entry_fts (the keyword/narrowing half of the fusion). The cosine
|
|
3
|
+
// rank over embedding vectors — the precise half — lands when the embedding
|
|
4
|
+
// channel does (a daughter projection, per the §4 boundary). Called from the
|
|
5
|
+
// gated manifest-add hook, so only when body content actually changed.
|
|
6
|
+
export default class EntrySemantic {
|
|
7
|
+
// Replace an entry's FTS row with its current body content (rowid = entryId).
|
|
8
|
+
// Empty content (binary member / cleared entry) → no FTS row (delete only).
|
|
9
|
+
static async indexFts(db, entryId, content) {
|
|
10
|
+
await db.fts_delete.run({ entry_id: entryId });
|
|
11
|
+
if (content.length > 0)
|
|
12
|
+
await db.fts_insert.run({ entry_id: entryId, content });
|
|
13
|
+
}
|
|
14
|
+
// Cosine similarity over two Float32 vectors stored as BLOBs — the SqlRite
|
|
15
|
+
// `cosine()` function delegates here (cosine.ts is the registration adapter).
|
|
16
|
+
// Alignment-proof: the BLOB Uint8Array may be an unaligned view, so copy the
|
|
17
|
+
// exact bytes to a fresh buffer before the Float32 view. A zero vector → 0.
|
|
18
|
+
static cosine(a, b) {
|
|
19
|
+
const x = new Float32Array(a.buffer.slice(a.byteOffset, a.byteOffset + a.byteLength));
|
|
20
|
+
const y = new Float32Array(b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength));
|
|
21
|
+
let dot = 0, nx = 0, ny = 0;
|
|
22
|
+
for (let i = 0; i < x.length; i++) {
|
|
23
|
+
dot += x[i] * y[i];
|
|
24
|
+
nx += x[i] * x[i];
|
|
25
|
+
ny += y[i] * y[i];
|
|
26
|
+
}
|
|
27
|
+
const denom = Math.sqrt(nx) * Math.sqrt(ny);
|
|
28
|
+
return denom === 0 ? 0 : dot / denom;
|
|
29
|
+
}
|
|
30
|
+
// Store an entry's embedding vector + the model that produced it, or clear the
|
|
31
|
+
// row (binary/empty entry, or a degraded `embeddingMissing` projection). Called
|
|
32
|
+
// from the gated manifest-add hook beside indexFts / the symbol index.
|
|
33
|
+
static async indexEmbedding(db, entryId, embedding, model) {
|
|
34
|
+
if (embedding !== undefined && model !== undefined) {
|
|
35
|
+
await db.embedding_set.run({ entry_id: entryId, vector: embedding, embedding_model: model });
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
await db.embedding_delete.run({ entry_id: entryId });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// Build the FTS5 narrow from a ~query: OR the alphanumeric terms (a broad cut —
|
|
42
|
+
// cosine does the precision). FTS5-syntax-safe (bare lowercased terms).
|
|
43
|
+
static ftsQueryFor(text) {
|
|
44
|
+
const terms = text.toLowerCase().match(/[a-z0-9]+/g);
|
|
45
|
+
if (terms === null)
|
|
46
|
+
return "";
|
|
47
|
+
return [...new Set(terms)].join(" OR ");
|
|
48
|
+
}
|
|
49
|
+
// The ~query dispatch: embed the query text through the SAME channel, FTS-narrow
|
|
50
|
+
// by its terms, cosine-rank the narrowed set, top-K. 501 when no embeddings
|
|
51
|
+
// handler is installed (the channel degrades to `embeddingMissing`).
|
|
52
|
+
static async rankSemantic(db, sessionId, scheme, mimetypes, queryText, k) {
|
|
53
|
+
const r = await mimetypes.process({ content: queryText, hint: "text/markdown" }, { channels: ["embedding"] });
|
|
54
|
+
// No embedder installed → the channel degrades to empty bytes (not undefined);
|
|
55
|
+
// an empty query vector can't rank, so surface 501 rather than a false 200.
|
|
56
|
+
if (r.embedding === undefined || r.embedding.byteLength === 0)
|
|
57
|
+
return { status: 501, pathnames: [] };
|
|
58
|
+
const ftsQuery = EntrySemantic.ftsQueryFor(queryText);
|
|
59
|
+
if (ftsQuery.length === 0)
|
|
60
|
+
return { status: 200, pathnames: [] };
|
|
61
|
+
const rows = await db.semantic_rank.all({
|
|
62
|
+
fts_query: ftsQuery, session_id: sessionId, scheme, query_vector: r.embedding, k,
|
|
63
|
+
});
|
|
64
|
+
return { status: 200, pathnames: rows.map((x) => x.pathname) };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=_entry-semantic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_entry-semantic.js","sourceRoot":"","sources":["../../src/schemes/_entry-semantic.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,gFAAgF;AAChF,4EAA4E;AAC5E,6EAA6E;AAC7E,uEAAuE;AAKvE,MAAM,CAAC,OAAO,OAAO,aAAa;IAC9B,8EAA8E;IAC9E,4EAA4E;IAC5E,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAM,EAAE,OAAe,EAAE,OAAe;QAC1D,MAAO,EAAE,CAAC,UAAyB,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;QAC/D,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;YAAE,MAAO,EAAE,CAAC,UAAyB,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IACpG,CAAC;IAED,2EAA2E;IAC3E,8EAA8E;IAC9E,6EAA6E;IAC7E,4EAA4E;IAC5E,MAAM,CAAC,MAAM,CAAC,CAAa,EAAE,CAAa;QACtC,MAAM,CAAC,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;QACtF,MAAM,CAAC,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC,CAA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AAC,CAAC,QAAQ,CAAC,EAAE,CAAC;IACnE,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cosine.d.ts","sourceRoot":"","sources":["../../src/schemes/cosine.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,aAAa,OAAO,CAAC;yBAClB,GAAG,UAAU,EAAE,GAAG,UAAU,KAAG,MAAM;AAArD,wBAAoF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// SqlRite function module (#186, ~semantic). The sqlrite contract requires a
|
|
2
|
+
// default-export handler and turns the filename into the SQL function name — so
|
|
3
|
+
// this is a thin registration adapter; the logic lives in EntrySemantic.cosine
|
|
4
|
+
// (OO). `deterministic` marks it a pure function so SQLite may optimize it. One
|
|
5
|
+
// of the few intentionally non-class modules (sqlrite's function convention).
|
|
6
|
+
import EntrySemantic from "./_entry-semantic.js";
|
|
7
|
+
export const deterministic = true;
|
|
8
|
+
export default (a, b) => EntrySemantic.cosine(a, b);
|
|
9
|
+
//# sourceMappingURL=cosine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cosine.js","sourceRoot":"","sources":["../../src/schemes/cosine.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,gFAAgF;AAChF,+EAA+E;AAC/E,gFAAgF;AAChF,8EAA8E;AAC9E,OAAO,aAAa,MAAM,sBAAsB,CAAC;AAEjD,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC;AAClC,eAAe,CAAC,CAAa,EAAE,CAAa,EAAU,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -21,10 +21,12 @@ export interface ClientEnvelope {
|
|
|
21
21
|
runId: number;
|
|
22
22
|
runName: string;
|
|
23
23
|
runPersona: string | null;
|
|
24
|
+
modelRunId: number | null;
|
|
24
25
|
clientLoopId: number | null;
|
|
25
26
|
}
|
|
26
27
|
export default class Envelope {
|
|
27
28
|
#private;
|
|
29
|
+
static readonly RESERVED_RUN_NAMES: ReadonlySet<string>;
|
|
28
30
|
static generateSessionName(): string;
|
|
29
31
|
static generateRunName(): string;
|
|
30
32
|
static createClientEnvelope(db: Db, opts?: {
|
|
@@ -39,6 +41,7 @@ export default class Envelope {
|
|
|
39
41
|
persona?: string | null;
|
|
40
42
|
}): Promise<ClientEnvelope>;
|
|
41
43
|
static ensureClientLoop(db: Db, runId: number): Promise<number>;
|
|
44
|
+
static ensureModelRun(db: Db, sessionId: number): Promise<number>;
|
|
42
45
|
static listRunsForSession(db: Db, sessionId: number): Promise<RunRow[]>;
|
|
43
46
|
static closeClientLoop(db: Db, loopId: number, status: 200 | 499): Promise<void>;
|
|
44
47
|
static listSessions(db: Db): Promise<SessionRow[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../src/server/envelope.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,EAAE,EAAc,MAAM,eAAe,CAAC;AAGpD,MAAM,WAAW,UAAU;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,MAAM;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACrB;
|
|
1
|
+
{"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../src/server/envelope.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,EAAE,EAAc,MAAM,eAAe,CAAC;AAGpD,MAAM,WAAW,UAAU;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EA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EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAO,GAAG,OAAO,CAAC,cAAc,CAAC;WAgB7I,gBAAgB,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WAUxD,cAAc,CAAC,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WAM1D,kBAAkB,CAAC,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;WAIhE,eAAe,CAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;WAIzE,YAAY,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;WAM3C,wBAAwB,CAAC,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;WAWvG,oBAAoB,CAAC,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAK/G"}
|
package/dist/server/envelope.js
CHANGED
|
@@ -7,6 +7,11 @@
|
|
|
7
7
|
// that run; the client loop closes on disconnect.
|
|
8
8
|
import GitMembership from "../core/git-membership.js";
|
|
9
9
|
export default class Envelope {
|
|
10
|
+
// Run names reserved for non-client actors: a client must not create OR
|
|
11
|
+
// attach to a run under a reserved name (origin-impersonation — `plurnk`
|
|
12
|
+
// is the runtime actor, §0.4/§14.7). Checked case-insensitively, before
|
|
13
|
+
// lookup, so a client can neither forge nor hijack one (SPEC §13.5).
|
|
14
|
+
static RESERVED_RUN_NAMES = new Set(["plurnk"]);
|
|
10
15
|
// Grammar 0.5.0 (#10): Session and Run carry user-renameable string names.
|
|
11
16
|
// Defaults are `session-{unixtime}` and `run-{unixtime}`; random suffix avoids
|
|
12
17
|
// collisions when two creations land in the same second.
|
|
@@ -40,6 +45,7 @@ export default class Envelope {
|
|
|
40
45
|
sessionId: session.id, sessionName: session.name,
|
|
41
46
|
projectRoot: session.project_root, sessionPersona: session.persona,
|
|
42
47
|
runId: run.id, runName: run.name, runPersona: run.persona,
|
|
48
|
+
modelRunId: null,
|
|
43
49
|
clientLoopId: null,
|
|
44
50
|
};
|
|
45
51
|
}
|
|
@@ -64,6 +70,9 @@ export default class Envelope {
|
|
|
64
70
|
return { id: existing.id, name: existing.name, persona: existing.persona };
|
|
65
71
|
}
|
|
66
72
|
if (opts.runName !== undefined) {
|
|
73
|
+
if (Envelope.RESERVED_RUN_NAMES.has(opts.runName.toLowerCase())) {
|
|
74
|
+
throw new Error(`run name "${opts.runName}" is reserved for a non-client actor`);
|
|
75
|
+
}
|
|
67
76
|
const existing = await db.envelope_get_run_by_name.get({ session_id: sessionId, name: opts.runName });
|
|
68
77
|
if (existing !== undefined)
|
|
69
78
|
return existing;
|
|
@@ -86,6 +95,7 @@ export default class Envelope {
|
|
|
86
95
|
sessionId: session.id, sessionName: session.name,
|
|
87
96
|
projectRoot: session.project_root, sessionPersona: session.persona,
|
|
88
97
|
runId: run.id, runName: run.name, runPersona: run.persona,
|
|
98
|
+
modelRunId: null,
|
|
89
99
|
clientLoopId: null,
|
|
90
100
|
};
|
|
91
101
|
}
|
|
@@ -98,6 +108,16 @@ export default class Envelope {
|
|
|
98
108
|
throw new Error("ensureClientLoop: loop insert returned no row");
|
|
99
109
|
return loop.id;
|
|
100
110
|
}
|
|
111
|
+
// Lazy model-run allocator (§13.7, §14.8 — the client writes to its own run).
|
|
112
|
+
// The model's conversation lives in its OWN run, distinct from the connection's
|
|
113
|
+
// (client) run, so the packet — rendered from the model's run — never carries
|
|
114
|
+
// the client's op.*. Created on the first loop.run; reused for the connection.
|
|
115
|
+
static async ensureModelRun(db, sessionId) {
|
|
116
|
+
const run = await db.envelope_insert_run.get({ session_id: sessionId, name: Envelope.#tsName("model"), persona: null });
|
|
117
|
+
if (run === undefined)
|
|
118
|
+
throw new Error("ensureModelRun: run insert returned no row");
|
|
119
|
+
return run.id;
|
|
120
|
+
}
|
|
101
121
|
static async listRunsForSession(db, sessionId) {
|
|
102
122
|
return await db.envelope_list_runs_for_session.all({ session_id: sessionId });
|
|
103
123
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envelope.js","sourceRoot":"","sources":["../../src/server/envelope.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,EAAE;AACF,6EAA6E;AAC7E,4EAA4E;AAC5E,0EAA0E;AAC1E,6EAA6E;AAC7E,kDAAkD;AAGlD,OAAO,aAAa,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"envelope.js","sourceRoot":"","sources":["../../src/server/envelope.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,EAAE;AACF,6EAA6E;AAC7E,4EAA4E;AAC5E,0EAA0E;AAC1E,6EAA6E;AAC7E,kDAAkD;AAGlD,OAAO,aAAa,MAAM,2BAA2B,CAAC;AAoCtD,MAAM,CAAC,OAAO,OAAO,QAAQ;IACzB,wEAAwE;IACxE,yEAAyE;IACzE,wEAAwE;IACxE,qEAAqE;IACrE,MAAM,CAAU,kBAAkB,GAAwB,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE9E,2EAA2E;IAC3E,+EAA+E;IAC/E,yDAAyD;IACzD,MAAM,CAAC,OAAO,CAAC,MAAc;QACzB,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;QACzC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,C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AC;IACpB,EAAE,EAAE,OAAO,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,EAAE,EAAE,OAAO,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,CAAC,OAAO,OAAO,QAAQ;;WAOZ,aAAa,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;CAiCxE"}
|
package/dist/server/logEntry.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logEntry.js","sourceRoot":"","sources":["../../src/server/logEntry.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,8DAA8D;AAC9D,yCAAyC;
|
|
1
|
+
{"version":3,"file":"logEntry.js","sourceRoot":"","sources":["../../src/server/logEntry.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,8DAA8D;AAC9D,yCAAyC;AAkCzC,MAAM,CAAC,OAAO,OAAO,QAAQ;IACzB,MAAM,CAAC,gBAAgB,CAAC,CAAU;QAC9B,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC;QAC/C,IAAI,OAAO,CAAC,KAAK,QAAQ;YAAE,OAAO,CAAC,CAAC;QACpC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,EAAM,EAAE,EAAU;QACzC,MAAM,GAAG,GAAG,MAAO,EAAE,CAAC,eAA8B,CAAC,GAAG,CAA0B,EAAE,EAAE,EAAE,CAAC,CAAC;QAC1F,IAAI,GAAG,KAAK,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,EAAE,YAAY,CAAC,CAAC;QAC1E,OAAO;YACH,EAAE,EAAE,GAAG,CAAC,EAAY;YACpB,MAAM,EAAE,GAA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ources":["../../../src/server/methods/loop_cancel.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAC;AAMvD,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACjC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"loop_cancel.d.ts","sourceRoot":"","sources":["../../../src/server/methods/loop_cancel.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAC;AAMvD,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACjC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;CAmBlD"}
|
|
@@ -15,8 +15,11 @@ export default class LoopCancelMethod {
|
|
|
15
15
|
throw new Error("loop.cancel requires an attached session");
|
|
16
16
|
const p = params;
|
|
17
17
|
const reason = (typeof p.reason === "string" && p.reason.length > 0) ? p.reason : "user_cancelled";
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
// §13.7/§14.8 — the model drain lives in the model's run, not the
|
|
19
|
+
// connection's client run. No model run yet → nothing to cancel.
|
|
20
|
+
const modelRunId = ctx.session.modelRunId;
|
|
21
|
+
const cancelled = modelRunId !== null && ctx.daemon.cancelDrain(modelRunId, reason);
|
|
22
|
+
return { cancelled, runId: modelRunId, reason };
|
|
20
23
|
},
|
|
21
24
|
description: "Abort the run's active drain. Returns {cancelled: true} if a drain was running; {cancelled: false} if the run was already idle. Cancelled loops close at status 499. Queued (but not yet claimed) loops remain enqueued; subsequent loop.run resumes the queue.",
|
|
22
25
|
params: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop_cancel.js","sourceRoot":"","sources":["../../../src/server/methods/loop_cancel.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,yEAAyE;AACzE,kEAAkE;AAClE,oEAAoE;AACpE,uBAAuB;AACvB,EAAE;AACF,uEAAuE;AACvE,qEAAqE;AACrE,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CAAC,CAAC,gBAAgB,CAAC;gBACnG,kEAAkE;gBAClE,iEAAiE;gBACjE,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC;gBAC1C,MAAM,SAAS,GAAG,UAAU,KAAK,IAAI,IAAI,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;gBACpF,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;YACpD,CAAC;YACD,WAAW,EAAE,iQAAiQ;YAC9Q,MAAM,EAAE;gBACJ,MAAM,EAAE,qFAAqF;aAChG;YACD,YAAY,EAAE,IAAI;SACrB,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop_run.d.ts","sourceRoot":"","sources":["../../../src/server/methods/loop_run.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"loop_run.d.ts","sourceRoot":"","sources":["../../../src/server/methods/loop_run.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAC;AAgCvD,MAAM,CAAC,OAAO,OAAO,aAAa;IAC9B,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;CAqHlD"}
|
|
@@ -5,6 +5,7 @@ import { readFile } from "node:fs/promises";
|
|
|
5
5
|
import { Paths } from "../../index.js";
|
|
6
6
|
import { parseAliasesFromEnv } from "@plurnk/plurnk-providers";
|
|
7
7
|
import ProviderInstantiate from "../../core/ProviderInstantiate.js";
|
|
8
|
+
import Envelope from "../envelope.js";
|
|
8
9
|
export default class LoopRunMethod {
|
|
9
10
|
static register(registry) {
|
|
10
11
|
registry.registerMethod("loop.run", {
|
|
@@ -53,14 +54,17 @@ export default class LoopRunMethod {
|
|
|
53
54
|
if (provider === null) {
|
|
54
55
|
return { status: 501, error: "no provider configured at the daemon and no alias override supplied" };
|
|
55
56
|
}
|
|
56
|
-
const { sessionId
|
|
57
|
+
const { sessionId } = ctx.session;
|
|
58
|
+
// §13.7/§14.8 — the model runs in its OWN run, distinct from the
|
|
59
|
+
// connection's client run, so the packet never carries client op.*.
|
|
60
|
+
const modelRunId = ctx.session.modelRunId ?? (ctx.session.modelRunId = await Envelope.ensureModelRun(ctx.db, sessionId));
|
|
57
61
|
const systemPrompt = await readFile(Paths.instructionsSystem, "utf8");
|
|
58
62
|
const persona = await readFile(Paths.defaultPersona, "utf8");
|
|
59
63
|
// Delegate to the daemon's unified inject surface. Active-drain
|
|
60
64
|
// → write prompt entry for next turn (returns immediately).
|
|
61
65
|
// Idle run → enqueue + start drain (await drain to completion).
|
|
62
66
|
const injected = await ctx.daemon.inject({
|
|
63
|
-
sessionId, runId, prompt: p.prompt,
|
|
67
|
+
sessionId, runId: modelRunId, prompt: p.prompt,
|
|
64
68
|
provider, persona, systemPrompt,
|
|
65
69
|
maxTurns, flags: p.flags, personaOverride: loopPersona,
|
|
66
70
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop_run.js","sourceRoot":"","sources":["../../../src/server/methods/loop_run.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,0EAA0E;AAC1E,qDAAqD;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,mBAAmB,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"loop_run.js","sourceRoot":"","sources":["../../../src/server/methods/loop_run.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,0EAA0E;AAC1E,qDAAqD;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,KAAK,EAAE,MA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BACvB,OAAO,EAAE,QAAQ,CAAC,OAAO;wBACzB,MAAM,EAAE,oBAAoB;wBAC5B,WAAW,EAAE,GAAG;wBAChB,WAAW,EAAE,KAAK;wBAClB,OAAO,EAAE,EAAE;qBACd,CAAC;gBACN,CAAC;gBAED,qBAAqB;gBACrB,0DAA0D;gBAC1D,oDAAoD;gBACpD,yDAAyD;gBACzD,yDAAyD;gBACzD,sDAAsD;gBACtD,4DAA4D;gBAC5D,uDAAuD;gBACvD,IAAI,QAAQ,CAAC,gBAAgB,KAAK,SAAS,EAAE,CAAC;oBAC1C,OAAO;wBACH,MAAM,EAAE,QAAQ,CAAC,MAAM;wBACvB,MAAM,EAAE,mBAAmB;wBAC3B,WAAW,EAAE,GAAG;wBAChB,WAAW,EAAE,KAAK;wBAClB,OAAO,EAAE,EAAE;qBACd,CAAC;gBACN,CAAC;gBACD,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,gBAAgB,CAAC;gBAC9C,OAAO;oBACH,MAAM,EAAE,KAAK,CAAC,MAAM;oBACpB,OAAO,EAAE,KAAK,CAAC,OAAO;oBACtB,WAAW,EAAE,KAAK,CAAC,WAAW;oBAC9B,WAAW,EAAE,KAAK,CAAC,WAAW;oBAC9B,KAAK,EAAE,KAAK,CAAC,KAAK;oBAClB,MAAM,EAAE,mBAAmB;iBAC9B,CAAC;YACN,CAAC;YACD,WAAW,EAAE,ygBAAygB;YACthB,MAAM,EAAE;gBACJ,MAAM,EAAE,mCAAmC;gBAC3C,QAAQ,EAAE,gEAAgE;gBAC1E,KAAK,EAAE,kFAAkF;gBACzF,KAAK,EAAE,0GAA0G;gBACjH,OAAO,EAAE,8FAA8F;aAC1G;YACD,YAAY,EAAE,IAAI;YAClB,WAAW,EAAE,IAAI;SACpB,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session_attach.d.ts","sourceRoot":"","sources":["../../../src/server/methods/session_attach.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAC;AAGvD,MAAM,CAAC,OAAO,OAAO,mBAAmB;IACpC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"session_attach.d.ts","sourceRoot":"","sources":["../../../src/server/methods/session_attach.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAC;AAGvD,MAAM,CAAC,OAAO,OAAO,mBAAmB;IACpC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;CAwClD"}
|
|
@@ -13,6 +13,9 @@ export default class SessionAttachMethod {
|
|
|
13
13
|
if (p.runName !== undefined && (typeof p.runName !== "string" || p.runName.length === 0)) {
|
|
14
14
|
throw new Error("session.attach: runName must be a non-empty string");
|
|
15
15
|
}
|
|
16
|
+
if (typeof p.runName === "string" && Envelope.RESERVED_RUN_NAMES.has(p.runName.toLowerCase())) {
|
|
17
|
+
throw new Error(`session.attach: runName "${p.runName}" is reserved`);
|
|
18
|
+
}
|
|
16
19
|
const persona = p.persona ?? null;
|
|
17
20
|
if (persona !== null && typeof persona !== "string") {
|
|
18
21
|
throw new Error("session.attach: persona must be a string or null");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session_attach.js","sourceRoot":"","sources":["../../../src/server/methods/session_attach.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAEtC,MAAM,CAAC,OAAO,OAAO,mBAAmB;IACpC,MAAM,CAAC,QAAQ,CAAC,QAAwB;QACpC,QAAQ,CAAC,cAAc,CAAC,gBAAgB,EAAE;YACtC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE;gBAC3B,MAAM,CAAC,GAAG,MAAmF,CAAC;gBAC9F,IAAI,OAAO,CAAC,CAAC,EAAE,KAAK,QAAQ,EAAE,CAAC;oBAC3B,MAAM,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,CAAC;gBACD,MAAM,OAAO,GAAG,CAAC,CAAC,OAAO,IAAI,IAAI,CAAC;gBAClC,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;oBAClD,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;gBACxE,CAAC;gBACD,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;gBAC/G,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;gBAC5B,OAAO;oBACH,EAAE,EAAE,QAAQ,CAAC,SAAS;oBACtB,IAAI,EAAE,QAAQ,CAAC,WAAW;oBAC1B,cAAc,EAAE,QAAQ,CAAC,cAAc;oBACvC,KAAK,EAAE,QAAQ,CAAC,KAAK;oBACrB,OAAO,EAAE,QAAQ,CAAC,OAAO;oBACzB,UAAU,EAAE,QAAQ,CAAC,UAAU;iBAClC,CAAC;YACN,CAAC;YACD,WAAW,EAAE,mTAAmT;YAChU,MAAM,EAAE;gBACJ,EAAE,EAAE,kCAAkC;gBACtC,KAAK,EAAE,oEAAoE;gBAC3E,OAAO,EAAE,8EAA8E;gBACvF,OAAO,EAAE,kFAAkF;aAC9F;SACJ,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -103,6 +103,11 @@ CREATE TABLE IF NOT EXISTS entries (
|
|
|
103
103
|
-- so entries == members); 'client'/'constraint' (model-created, add-glob) are not
|
|
104
104
|
-- git's to reclaim. NULL = not a file member (other schemes don't carry origin).
|
|
105
105
|
membership_origin TEXT CHECK (membership_origin IS NULL OR membership_origin IN ('git', 'client', 'constraint')),
|
|
106
|
+
-- @graph / ~semantic change-gate (#186): hash of the body content at the last
|
|
107
|
+
-- deep-channel derivation. The manifest-add pass re-derives symbols/refs (and
|
|
108
|
+
-- embeddings, later) ONLY when this differs from the current body hash — an
|
|
109
|
+
-- unchanged entry is skipped, never re-metadatafied every turn.
|
|
110
|
+
deep_hash TEXT,
|
|
106
111
|
CHECK ((scope = 'agent' AND session_id IS NULL)
|
|
107
112
|
OR (scope = 'session' AND session_id IS NOT NULL)),
|
|
108
113
|
FOREIGN KEY (session_id) REFERENCES sessions(id) ON DELETE CASCADE
|
|
@@ -171,6 +176,29 @@ CREATE TABLE IF NOT EXISTS symbol_refs (
|
|
|
171
176
|
CREATE INDEX IF NOT EXISTS symbol_refs_name ON symbol_refs (session_id, name);
|
|
172
177
|
CREATE INDEX IF NOT EXISTS symbol_refs_source ON symbol_refs (session_id, entry_id, container);
|
|
173
178
|
|
|
179
|
+
-- INIT: entry_fts (~semantic FTS half — plurnk-service#186)
|
|
180
|
+
-- Keyword/content index over entry body content; the FTS5 rowid IS entries.id.
|
|
181
|
+
-- The ~semantic dialect narrows candidates here (cheap, indexed) then cosine-ranks
|
|
182
|
+
-- the narrowed set over the embedding vectors — FTS does the scale-cut, cosine the
|
|
183
|
+
-- precise rank, so no ANN/extension is needed. Populated at the gated manifest-add
|
|
184
|
+
-- hook alongside symbol_defs/refs: re-indexed only when body content changes.
|
|
185
|
+
CREATE VIRTUAL TABLE IF NOT EXISTS entry_fts USING fts5(content);
|
|
186
|
+
|
|
187
|
+
-- INIT: entry_embeddings (~semantic vector half — plurnk-service#186)
|
|
188
|
+
-- One Float32 vector per entry (scalar-shaped), stored as a BLOB the cosine()
|
|
189
|
+
-- SqlRite function reads. Supplied by the mimetypes `embedding` projection at the
|
|
190
|
+
-- gated manifest-add hook (mimetypes#23); the fusion (semantic_rank) cosine-ranks
|
|
191
|
+
-- the FTS-narrowed candidates over these. CASCADE-deleted with the entry.
|
|
192
|
+
CREATE TABLE IF NOT EXISTS entry_embeddings (
|
|
193
|
+
entry_id INTEGER NOT NULL PRIMARY KEY,
|
|
194
|
+
vector BLOB NOT NULL,
|
|
195
|
+
-- The model id that produced this vector (mimetypes' `embeddingModel`, e.g.
|
|
196
|
+
-- "Xenova/all-MiniLM-L6-v2@751bff37"). Stored per row as the staleness detector:
|
|
197
|
+
-- a future model swap re-embeds rows whose model differs from the current one.
|
|
198
|
+
embedding_model TEXT NOT NULL,
|
|
199
|
+
FOREIGN KEY (entry_id) REFERENCES entries(id) ON DELETE CASCADE
|
|
200
|
+
) STRICT;
|
|
201
|
+
|
|
174
202
|
-- INIT: log_entries
|
|
175
203
|
-- Chronological event store. sequence is 1-based, scoped to the turn —
|
|
176
204
|
-- resets at each new turn. URI-bit columns are unprefixed (scheme,
|
|
@@ -188,7 +216,7 @@ CREATE TABLE IF NOT EXISTS log_entries (
|
|
|
188
216
|
turn_id INTEGER NOT NULL,
|
|
189
217
|
sequence INTEGER NOT NULL CHECK (sequence >= 1),
|
|
190
218
|
at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
|
|
191
|
-
origin TEXT NOT NULL CHECK (origin IN ('model', 'client', '
|
|
219
|
+
origin TEXT NOT NULL CHECK (origin IN ('model', 'client', 'plurnk', 'plugin')),
|
|
192
220
|
-- §14.5 environment-delta cause: a sibling run-id or a scheme ('file');
|
|
193
221
|
-- NULL = the owning run itself (self), rendered without a run= label.
|
|
194
222
|
source TEXT,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plurnk/plurnk-service",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Plurnk agent runtime — the server / engine / core. Implements the @plurnk/plurnk-grammar contract.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"dist/**/*",
|
|
23
23
|
"migrations/**/*.sql",
|
|
24
24
|
"persona.md",
|
|
25
|
+
"requirements.md",
|
|
25
26
|
"README.md",
|
|
26
27
|
"SPEC.md"
|
|
27
28
|
],
|
|
@@ -44,16 +45,17 @@
|
|
|
44
45
|
"prepare": "npm run build"
|
|
45
46
|
},
|
|
46
47
|
"dependencies": {
|
|
47
|
-
"@plurnk/plurnk-execs": "0.4.
|
|
48
|
-
"@plurnk/plurnk-execs-common": "0.2.
|
|
49
|
-
"@plurnk/plurnk-execs-git": "0.1.
|
|
50
|
-
"@plurnk/plurnk-execs-search": "0.2.
|
|
51
|
-
"@plurnk/plurnk-execs-sqlite": "0.1.
|
|
52
|
-
"@plurnk/plurnk-execs-wasm": "0.1.
|
|
53
|
-
"@plurnk/plurnk-grammar": "0.
|
|
54
|
-
"@plurnk/plurnk-mimetypes": "0.15.
|
|
48
|
+
"@plurnk/plurnk-execs": "0.4.3",
|
|
49
|
+
"@plurnk/plurnk-execs-common": "0.2.1",
|
|
50
|
+
"@plurnk/plurnk-execs-git": "0.1.1",
|
|
51
|
+
"@plurnk/plurnk-execs-search": "0.2.3",
|
|
52
|
+
"@plurnk/plurnk-execs-sqlite": "0.1.3",
|
|
53
|
+
"@plurnk/plurnk-execs-wasm": "0.1.2",
|
|
54
|
+
"@plurnk/plurnk-grammar": "0.32.0",
|
|
55
|
+
"@plurnk/plurnk-mimetypes": "0.15.8",
|
|
56
|
+
"@plurnk/plurnk-mimetypes-embeddings": "0.1.0",
|
|
55
57
|
"@plurnk/plurnk-providers": "0.2.2",
|
|
56
|
-
"@plurnk/plurnk-schemes": "0.
|
|
58
|
+
"@plurnk/plurnk-schemes": "0.6.0",
|
|
57
59
|
"@plurnk/plurnk-schemes-http": "0.1.0",
|
|
58
60
|
"@possumtech/sqlrite": "5.1.1",
|
|
59
61
|
"diff": "^9.0.0",
|
package/requirements.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Syntax: <<OPsuffix[signal]?(target)?<Line/Result>?:body?:OPsuffix
|
|
2
|
+
|
|
3
|
+
YOU MUST document all relevant questions and uncertainties into taxonomized, tagged, and topical unknown entries.
|
|
4
|
+
YOU MUST ONLY populate known entries with source entry information, never with model training.
|
|
5
|
+
YOU SHOULD prefer deterministic calculations and retrievals over model training or speculation.
|
|
6
|
+
YOU SHOULD FOLD log entries that are irrelevant, resolved, or already distilled into known entries.
|
|
7
|
+
YOU SHOULD leverage folksonomic path names, tags, and bulk pattern operations to optimize for context relevance.
|
|
8
|
+
YOU MUST use OPEN and FOLD to keep your context budget healthy, optimized, and topical, below the `tokensFree` limit.
|
|
9
|
+
YOU MUST terminate the turn with either a continuing (102) or loop terminating (200) `<<SEND[102]:status update:SEND`
|