@markii/runtime 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/failure.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * The closed, runtime-owned failure taxonomy for a script execution outcome
3
- * (DESIGN.md §8). This is the ONE vocabulary every concrete `ScriptExecutor`
3
+ * (docs/scripting.md). This is the ONE vocabulary every concrete `ScriptExecutor`
4
4
  * (e.g. `@markii/lua`'s `createLuaExecutor`) is expected to map its own
5
5
  * language-specific failure shape down to, and the one vocabulary
6
6
  * `@markii/react` (and any other renderer) is expected to branch its
@@ -1,5 +1,5 @@
1
1
  /**
2
- * DESIGN.md §10 ("Security model"): "Grants are remembered per note, keyed
2
+ * docs/security.md ("Security model"): "Grants are remembered per note, keyed
3
3
  * by a hash of the note's full *executable closure* — its inline scripts,
4
4
  * `src=` script files, required bundle-local modules, vault-library
5
5
  * modules, and the versions of any pack modules it requires. If any of that
@@ -13,7 +13,7 @@
13
13
  * follow its `require`s into the bundle and the vault library, and read the
14
14
  * installed pack manifest) assembles a `GrantClosure` and hands it in.
15
15
  * `@markii/core`'s `ScriptBlock` is NOT imported here on purpose — this
16
- * package stays independent of the parser layer (see CLAUDE.md's import
16
+ * package stays independent of the parser layer (see AGENTS.md's import
17
17
  * rule); `GrantClosureScript` below is a local structural type that mirrors
18
18
  * the fields that matter to the closure.
19
19
  *
@@ -113,7 +113,7 @@ export interface GrantClosureScript {
113
113
  /**
114
114
  * One installed pack's identity, plus its module sources when the host has
115
115
  * them. A pack's `version` alone must move the key even if the host never
116
- * fetched its source — DESIGN.md §10 keys the grant to "the versions of any
116
+ * fetched its source — docs/security.md keys the grant to "the versions of any
117
117
  * pack modules it requires", not only to code the host happens to have
118
118
  * bytes for.
119
119
  */
@@ -131,7 +131,7 @@ export interface GrantClosurePack {
131
131
  modules?: Record<string, string>;
132
132
  }
133
133
  /**
134
- * The full executable closure a grant is keyed to (DESIGN.md §10). Every
134
+ * The full executable closure a grant is keyed to (docs/security.md). Every
135
135
  * field here must be populated by the host from whatever it has already
136
136
  * resolved; `computeGrantKey` does no resolution of its own.
137
137
  */
@@ -153,7 +153,7 @@ export interface GrantClosure {
153
153
  packs: GrantClosurePack[];
154
154
  }
155
155
  /**
156
- * Computes the grant key for a note's executable closure (DESIGN.md §10):
156
+ * Computes the grant key for a note's executable closure (docs/security.md):
157
157
  * the lowercase hex SHA-256 digest of the closure's canonical serialization
158
158
  * — see this module's top doc comment for the exact byte form. Pure and
159
159
  * side-effect free: this function does not parse, fetch, or read anything;
package/dist/grant-key.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * DESIGN.md §10 ("Security model"): "Grants are remembered per note, keyed
2
+ * docs/security.md ("Security model"): "Grants are remembered per note, keyed
3
3
  * by a hash of the note's full *executable closure* — its inline scripts,
4
4
  * `src=` script files, required bundle-local modules, vault-library
5
5
  * modules, and the versions of any pack modules it requires. If any of that
@@ -13,7 +13,7 @@
13
13
  * follow its `require`s into the bundle and the vault library, and read the
14
14
  * installed pack manifest) assembles a `GrantClosure` and hands it in.
15
15
  * `@markii/core`'s `ScriptBlock` is NOT imported here on purpose — this
16
- * package stays independent of the parser layer (see CLAUDE.md's import
16
+ * package stays independent of the parser layer (see AGENTS.md's import
17
17
  * rule); `GrantClosureScript` below is a local structural type that mirrors
18
18
  * the fields that matter to the closure.
19
19
  *
@@ -206,7 +206,7 @@ function toHex(buffer) {
206
206
  return hex;
207
207
  }
208
208
  /**
209
- * Computes the grant key for a note's executable closure (DESIGN.md §10):
209
+ * Computes the grant key for a note's executable closure (docs/security.md):
210
210
  * the lowercase hex SHA-256 digest of the closure's canonical serialization
211
211
  * — see this module's top doc comment for the exact byte form. Pure and
212
212
  * side-effect free: this function does not parse, fetch, or read anything;
package/dist/run.d.ts CHANGED
@@ -3,7 +3,7 @@ import { type FailureKind } from './failure.js';
3
3
  import type { ValueStore } from './store.js';
4
4
  import type { VaultWriter } from './vault.js';
5
5
  /**
6
- * Slice 2 of the scripting-usability layer (DESIGN.md §8): the run
6
+ * Slice 2 of the scripting-usability layer (docs/scripting.md): the run
7
7
  * orchestrator that executes a document's script blocks and writes their
8
8
  * results into the `ValueStore` Slice 1 built. This module never imports a
9
9
  * concrete language runtime (no `@markii/lua`, no wasmoon) — it only knows
@@ -13,14 +13,14 @@ import type { VaultWriter } from './vault.js';
13
13
  * `runDocumentScripts` without this package ever changing.
14
14
  */
15
15
  /**
16
- * How a batch of scripts was invoked — DESIGN.md §8's three triggers:
16
+ * How a batch of scripts was invoked — docs/scripting.md's three triggers:
17
17
  * - `'manual'` — an explicit run/run-all click.
18
18
  * - `'auto'` — opt-in run-on-open.
19
19
  * - `'scheduled'` — opt-in periodic run.
20
20
  */
21
21
  export type RunTrigger = 'manual' | 'auto' | 'scheduled';
22
22
  /**
23
- * DESIGN.md §8's two-tier capability gate a concrete script executor (e.g.
23
+ * docs/scripting.md's two-tier capability gate a concrete script executor (e.g.
24
24
  * `@markii/lua`'s `runScript`) enforces: `'manual'` unlocks every manifest
25
25
  * grant, including effectful ops; `'auto'` is read-only regardless of what
26
26
  * was granted.
@@ -81,7 +81,7 @@ export interface RunSummaryEntry {
81
81
  */
82
82
  failureKind?: FailureKind;
83
83
  /**
84
- * Publish outcome (DESIGN.md §8's vault). Set ONLY for a script block
84
+ * Publish outcome (docs/scripting.md's vault). Set ONLY for a script block
85
85
  * whose fence carried the bare `publish` attribute (`ScriptBlock.publish
86
86
  * === true`) AND whose run succeeded (`status === 'fresh'`) — a
87
87
  * non-publish block never gets this field, and a publish-flagged block
@@ -102,7 +102,7 @@ export interface RunSummaryEntry {
102
102
  * The result of one `runDocumentScripts` call. `results` has one entry per
103
103
  * script block actually run, in document order — including every
104
104
  * duplicate-named attempt, not deduplicated. When `scripts` contained
105
- * repeated `name`s, `duplicateNames` lists which ones; per DESIGN.md §8
105
+ * repeated `name`s, `duplicateNames` lists which ones; per docs/scripting.md
106
106
  * ("`name`s land in one note-scoped value store regardless of position"),
107
107
  * the store ends up holding whatever the LAST run for that name produced
108
108
  * (document order) — `results` still records every individual attempt.
@@ -123,14 +123,14 @@ export interface RunDocumentScriptsOptions {
123
123
  trigger: RunTrigger;
124
124
  store: ValueStore;
125
125
  /**
126
- * Resolves a `src=` long-script reference (DESIGN.md §8) to its Lua
126
+ * Resolves a `src=` long-script reference (docs/scripting.md) to its Lua
127
127
  * source text. Optional: a document with only inline script blocks never
128
128
  * needs it. If a block has `src` set and this is not provided, that one
129
129
  * block is recorded as an error (never a thrown exception).
130
130
  */
131
131
  loadSource?: (src: string) => Promise<string> | string;
132
132
  /**
133
- * The publish grant (DESIGN.md §8: "Publishing requires a grant ...
133
+ * The publish grant (docs/scripting.md: "Publishing requires a grant ...
134
134
  * because it writes beyond the note"). ITS PRESENCE IS THE GRANT — there
135
135
  * is no separate flag to enable publishing, and no per-script grant
136
136
  * check; a host that hands in a `vault` is thereby authorizing every
@@ -156,7 +156,7 @@ export interface RunDocumentScriptsOptions {
156
156
  /**
157
157
  * Runs every script block in `scripts`, in document order, against
158
158
  * `executor`, and writes each outcome into `store`. This is the RUN PATH:
159
- * "Rendering is pure; running is an event" (DESIGN.md §8) — this function
159
+ * "Rendering is pure; running is an event" (docs/scripting.md) — this function
160
160
  * is the event. It never throws; a single script failing (bad `src`,
161
161
  * `loadSource` throwing, the executor rejecting/throwing, or an ordinary
162
162
  * `ok: false` result) is recorded as that one script's error status and the
@@ -165,7 +165,7 @@ export interface RunDocumentScriptsOptions {
165
165
  * `trigger` is mapped to an `ExecutionTier` via `tierForTrigger` exactly
166
166
  * once, up front, and that same tier is used for every script in the
167
167
  * batch — the security gate is applied per batch-invocation, not
168
- * per-script, matching DESIGN.md §8 (a run is manual, auto, or scheduled as
168
+ * per-script, matching docs/scripting.md (a run is manual, auto, or scheduled as
169
169
  * a whole; individual scripts don't choose their own tier).
170
170
  *
171
171
  * Publishing (§8's vault): after a `publish`-flagged block's run SUCCEEDS,
package/dist/run.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { normalizeFailureKind } from './failure.js';
2
2
  /**
3
- * DESIGN.md §8's trigger x capability table, expressed as a pure lookup —
3
+ * docs/scripting.md's trigger x capability table, expressed as a pure lookup —
4
4
  * THIS IS THE SECURITY GATE for the whole run path. `'manual'` is the only
5
5
  * trigger that can ever produce the full-grants `'manual'` tier; `'auto'`
6
6
  * and `'scheduled'` both map to the read-only `'auto'` tier, unconditionally.
@@ -134,7 +134,7 @@ async function runOne(script, executor, tier, loadSource) {
134
134
  /**
135
135
  * Runs every script block in `scripts`, in document order, against
136
136
  * `executor`, and writes each outcome into `store`. This is the RUN PATH:
137
- * "Rendering is pure; running is an event" (DESIGN.md §8) — this function
137
+ * "Rendering is pure; running is an event" (docs/scripting.md) — this function
138
138
  * is the event. It never throws; a single script failing (bad `src`,
139
139
  * `loadSource` throwing, the executor rejecting/throwing, or an ordinary
140
140
  * `ok: false` result) is recorded as that one script's error status and the
@@ -143,7 +143,7 @@ async function runOne(script, executor, tier, loadSource) {
143
143
  * `trigger` is mapped to an `ExecutionTier` via `tierForTrigger` exactly
144
144
  * once, up front, and that same tier is used for every script in the
145
145
  * batch — the security gate is applied per batch-invocation, not
146
- * per-script, matching DESIGN.md §8 (a run is manual, auto, or scheduled as
146
+ * per-script, matching docs/scripting.md (a run is manual, auto, or scheduled as
147
147
  * a whole; individual scripts don't choose their own tier).
148
148
  *
149
149
  * Publishing (§8's vault): after a `publish`-flagged block's run SUCCEEDS,
@@ -173,7 +173,7 @@ export async function runDocumentScripts(options) {
173
173
  seenNames.add(script.name);
174
174
  const outcome = await runOne(script, executor, tier, loadSource);
175
175
  store.set(script.name, outcome.storedValue);
176
- // Publishing (DESIGN.md §8): only for a block that both asked to
176
+ // Publishing (docs/scripting.md): only for a block that both asked to
177
177
  // publish (bare `publish` on its fence — see `ScriptBlock.publish`) and
178
178
  // actually succeeded. A failed run has nothing to publish; `runOne`
179
179
  // already recorded its failure in `outcome.entry.status`/`.error`, and
package/dist/store.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Slice 1's pure read path (DESIGN.md §8): the note-scoped value store that
2
+ * Slice 1's pure read path (docs/scripting.md): the note-scoped value store that
3
3
  * rendering reads from. Nothing here executes a script, fetches anything,
4
4
  * or knows Lua exists — this module only holds whatever a future runner
5
5
  * (Slice 2) or a bundle-cache hydration step has already written, keyed by
@@ -36,7 +36,7 @@ export interface StoredValue {
36
36
  /**
37
37
  * Read/write access to the note-scoped value store. Script blocks "may
38
38
  * appear anywhere markdown may... but `name`s land in one note-scoped value
39
- * store regardless of position" (DESIGN.md §8) — this interface is that
39
+ * store regardless of position" (docs/scripting.md) — this interface is that
40
40
  * store. Rendering only ever calls `get`/`has`/`snapshot`; `set` exists for
41
41
  * whatever publishes values into the store (a script runner, a bundle
42
42
  * cache-loader) — entirely out of scope for Slice 1.
package/dist/store.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Slice 1's pure read path (DESIGN.md §8): the note-scoped value store that
2
+ * Slice 1's pure read path (docs/scripting.md): the note-scoped value store that
3
3
  * rendering reads from. Nothing here executes a script, fetches anything,
4
4
  * or knows Lua exists — this module only holds whatever a future runner
5
5
  * (Slice 2) or a bundle-cache hydration step has already written, keyed by
package/dist/vault.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { StoredValue } from './store.js';
2
2
  /**
3
- * Slice 3 of the scripting-usability layer (DESIGN.md §8, "Vault-published
3
+ * Slice 3 of the scripting-usability layer (docs/scripting.md, "Vault-published
4
4
  * values (the bulletin board)"): the APP-SCOPED store that a `publish`-
5
5
  * flagged script block's result lands in, as distinct from `store.ts`'s
6
6
  * NOTE-scoped `ValueStore`. "The store is app-side (§9): publishing adds no
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markii/runtime",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "Host-side scripting glue for Mark (.mk.md): a null-proto value store and document-script execution with trigger-tier gating (auto/scheduled stay read-only). Framework-agnostic; the script executor is injected by the host (e.g. @markii/lua).",
5
5
  "keywords": [
6
6
  "markdown",
@@ -42,6 +42,6 @@
42
42
  "lint": "eslint ."
43
43
  },
44
44
  "dependencies": {
45
- "@markii/core": "0.2.0"
45
+ "@markii/core": "0.3.1"
46
46
  }
47
47
  }