@orkestrel/brief 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/core/index.cjs +132 -8
- package/dist/src/core/index.cjs.map +1 -0
- package/dist/src/core/index.d.cts +63 -10
- package/dist/src/core/index.d.ts +63 -10
- package/dist/src/core/index.js +132 -9
- package/dist/src/core/index.js.map +1 -0
- package/package.json +11 -9
|
@@ -31,6 +31,15 @@ import { Subject } from '@orkestrel/reason';
|
|
|
31
31
|
* nothing, so it is an assertion rather than a factory. Reserve it for programmer-error
|
|
32
32
|
* contexts where invalidity is a bug.
|
|
33
33
|
*
|
|
34
|
+
* Intake NARROWS, and transfers no ownership. What comes back is the caller's own object,
|
|
35
|
+
* so a member carried on an accessor can answer this guard one way and a later reader
|
|
36
|
+
* another. The division is deliberate: the borrowed-engine law governs values this package
|
|
37
|
+
* pulls across a seam it called, and a value handed in at the door stays the caller's.
|
|
38
|
+
* `snapshotBrief` is the ownership door, and `pinBrief`, `BriefManager`, `briefToMarkdown`,
|
|
39
|
+
* `briefToGoal`, and `briefToDispatch` take it. `briefToSubject`, `briefToContent`, and
|
|
40
|
+
* `briefToTrace` read the value they are handed instead, so a caller reaching one of those
|
|
41
|
+
* directly owns that reading. Pass `assertBrief` a value you already own.
|
|
42
|
+
*
|
|
34
43
|
* @param data - The candidate brief data.
|
|
35
44
|
* @returns The same value, now known to satisfy {@link Brief}.
|
|
36
45
|
* @throws {@link BriefError} `INVALID` when `data` fails `isBrief`.
|
|
@@ -173,22 +182,31 @@ import { Subject } from '@orkestrel/reason';
|
|
|
173
182
|
* is FIXED: readiness is this package's contract, not a caller setting.
|
|
174
183
|
*
|
|
175
184
|
* A borrowed engine is the caller's own code, not an attacker, and this package does not
|
|
176
|
-
* treat it as one. The line is OWNERSHIP, and it produces
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
* - Every value a borrowed engine returns is OWNED AT ARRIVAL — copied where
|
|
180
|
-
*
|
|
181
|
-
*
|
|
185
|
+
* treat it as one. The line is OWNERSHIP, and it produces obligations worth stating because
|
|
186
|
+
* none of them is enforced in code:
|
|
187
|
+
*
|
|
188
|
+
* - Every value a borrowed engine returns is OWNED AT ARRIVAL — copied where a structured
|
|
189
|
+
* clone can carry it, captured into a frozen plain view where it cannot — and read once,
|
|
190
|
+
* where that copy or capture takes the reading. The captured view is what the `Briefing`
|
|
191
|
+
* replays, exactly as the clone arm always produced: a member the caller's prototype
|
|
192
|
+
* carries, outside the published contract, does not survive capture, and it never survived
|
|
193
|
+
* a structured clone either. What the engine does with its own object afterwards cannot
|
|
194
|
+
* reach a `Briefing`.
|
|
182
195
|
* - Both returns are shape-checked with their packages' published guards — reasons' logical
|
|
183
196
|
* result guard for the verdict, interprets' interpretation guard at both of the interpret
|
|
184
197
|
* stage's doors. A malformed value at either door records `INTERPRET_FAILED` instead of
|
|
185
198
|
* escaping `compile` as a raw throw, and a supplied interpretation whose snapshot copy
|
|
186
|
-
* loses prototype-carried members is
|
|
199
|
+
* loses prototype-carried members is captured rather than refused.
|
|
187
200
|
* - Neither engine is narrowed past its published contract. `Entity.value` is `unknown` and
|
|
188
201
|
* `LogicalResult` is an interface a class instance satisfies, so a value JSON cannot
|
|
189
|
-
* express is on-contract
|
|
190
|
-
*
|
|
191
|
-
*
|
|
202
|
+
* express is on-contract: its uncloneable leaves keep their identity inside the captured
|
|
203
|
+
* view rather than being refused.
|
|
204
|
+
* - `actions` and `domains` are read as option slots ONCE, at construction, so replacing
|
|
205
|
+
* either property on the options object afterwards changes nothing. The map each slot
|
|
206
|
+
* names is dereferenced on every `compile`, and each lookup captures its mapping once
|
|
207
|
+
* through the own descriptor. Mutating a map between calls therefore changes what the next
|
|
208
|
+
* call derives, while a mapping that answers differently on a second read cannot change
|
|
209
|
+
* what one call already derived.
|
|
192
210
|
*
|
|
193
211
|
* Whether the engine is correct, and whether it answers the same way twice, remain the
|
|
194
212
|
* caller's own problem.
|
|
@@ -638,6 +656,32 @@ import { Subject } from '@orkestrel/reason';
|
|
|
638
656
|
*/
|
|
639
657
|
export declare function briefToTrace(source: Brief): string;
|
|
640
658
|
|
|
659
|
+
/**
|
|
660
|
+
* Captures one stable, frozen view of a foreign contract value.
|
|
661
|
+
*
|
|
662
|
+
* @remarks
|
|
663
|
+
* Rebuilds the root and every reachable plain container from its own enumerable members.
|
|
664
|
+
* Unknown own members survive. Each published member absent from that copied own set is read
|
|
665
|
+
* once and materialized, which admits a class that supplies its contract through prototype
|
|
666
|
+
* accessors without leaving later reads attached to the live instance. Non-container leaves
|
|
667
|
+
* retain their identity, including functions that `structuredClone` cannot carry.
|
|
668
|
+
*
|
|
669
|
+
* @param source - The foreign value to capture.
|
|
670
|
+
* @param members - The published root member names to materialize when absent from its own set.
|
|
671
|
+
* @returns A deeply frozen plain view, or `source` itself when it is a primitive.
|
|
672
|
+
*
|
|
673
|
+
* @example
|
|
674
|
+
* ```ts
|
|
675
|
+
* import { captureValue } from '@orkestrel/brief'
|
|
676
|
+
*
|
|
677
|
+
* const leaf = () => 'ready'
|
|
678
|
+
* const owned = captureValue({ leaf }, ['leaf'])
|
|
679
|
+
* Reflect.get(owned, 'leaf') === leaf // true — an uncloneable leaf keeps its identity
|
|
680
|
+
* Object.isFrozen(owned) // true
|
|
681
|
+
* ```
|
|
682
|
+
*/
|
|
683
|
+
export declare function captureValue(source: unknown, members: readonly string[]): unknown;
|
|
684
|
+
|
|
641
685
|
/**
|
|
642
686
|
* One external source — what it is called, where it lives, and why it is cited.
|
|
643
687
|
*
|
|
@@ -1572,6 +1616,15 @@ import { Subject } from '@orkestrel/reason';
|
|
|
1572
1616
|
* all fail the same way — `undefined`, never a throw. Coerce a bare vocabulary value with
|
|
1573
1617
|
* `parseEnum` from `@orkestrel/contract` against the exported tuple instead.
|
|
1574
1618
|
*
|
|
1619
|
+
* The half of the intake pair that is OWNED BY CONSTRUCTION, which is what separates it from
|
|
1620
|
+
* `assertBrief`. The argument is text, so the graph the guard reads is one `JSON.parse` built
|
|
1621
|
+
* inside this call: it carries no caller identity, no accessor, and no alias back into anything
|
|
1622
|
+
* the caller still holds, and the parse-and-guard primitive this file imports from
|
|
1623
|
+
* `@orkestrel/contract` returns that same parsed graph rather than a second reading of it.
|
|
1624
|
+
* Every member `isBrief` checked therefore answers a later reader identically. The value is
|
|
1625
|
+
* fresh rather than frozen, so the caller owns it outright — reach for `snapshotBrief` when the
|
|
1626
|
+
* value came from code instead of from text.
|
|
1627
|
+
*
|
|
1575
1628
|
* @param value - The JSON text to parse.
|
|
1576
1629
|
* @returns The `Brief` when the parsed value satisfies `isBrief`, otherwise `undefined`.
|
|
1577
1630
|
*
|
package/dist/src/core/index.d.ts
CHANGED
|
@@ -31,6 +31,15 @@ import { Subject } from '@orkestrel/reason';
|
|
|
31
31
|
* nothing, so it is an assertion rather than a factory. Reserve it for programmer-error
|
|
32
32
|
* contexts where invalidity is a bug.
|
|
33
33
|
*
|
|
34
|
+
* Intake NARROWS, and transfers no ownership. What comes back is the caller's own object,
|
|
35
|
+
* so a member carried on an accessor can answer this guard one way and a later reader
|
|
36
|
+
* another. The division is deliberate: the borrowed-engine law governs values this package
|
|
37
|
+
* pulls across a seam it called, and a value handed in at the door stays the caller's.
|
|
38
|
+
* `snapshotBrief` is the ownership door, and `pinBrief`, `BriefManager`, `briefToMarkdown`,
|
|
39
|
+
* `briefToGoal`, and `briefToDispatch` take it. `briefToSubject`, `briefToContent`, and
|
|
40
|
+
* `briefToTrace` read the value they are handed instead, so a caller reaching one of those
|
|
41
|
+
* directly owns that reading. Pass `assertBrief` a value you already own.
|
|
42
|
+
*
|
|
34
43
|
* @param data - The candidate brief data.
|
|
35
44
|
* @returns The same value, now known to satisfy {@link Brief}.
|
|
36
45
|
* @throws {@link BriefError} `INVALID` when `data` fails `isBrief`.
|
|
@@ -173,22 +182,31 @@ import { Subject } from '@orkestrel/reason';
|
|
|
173
182
|
* is FIXED: readiness is this package's contract, not a caller setting.
|
|
174
183
|
*
|
|
175
184
|
* A borrowed engine is the caller's own code, not an attacker, and this package does not
|
|
176
|
-
* treat it as one. The line is OWNERSHIP, and it produces
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
* - Every value a borrowed engine returns is OWNED AT ARRIVAL — copied where
|
|
180
|
-
*
|
|
181
|
-
*
|
|
185
|
+
* treat it as one. The line is OWNERSHIP, and it produces obligations worth stating because
|
|
186
|
+
* none of them is enforced in code:
|
|
187
|
+
*
|
|
188
|
+
* - Every value a borrowed engine returns is OWNED AT ARRIVAL — copied where a structured
|
|
189
|
+
* clone can carry it, captured into a frozen plain view where it cannot — and read once,
|
|
190
|
+
* where that copy or capture takes the reading. The captured view is what the `Briefing`
|
|
191
|
+
* replays, exactly as the clone arm always produced: a member the caller's prototype
|
|
192
|
+
* carries, outside the published contract, does not survive capture, and it never survived
|
|
193
|
+
* a structured clone either. What the engine does with its own object afterwards cannot
|
|
194
|
+
* reach a `Briefing`.
|
|
182
195
|
* - Both returns are shape-checked with their packages' published guards — reasons' logical
|
|
183
196
|
* result guard for the verdict, interprets' interpretation guard at both of the interpret
|
|
184
197
|
* stage's doors. A malformed value at either door records `INTERPRET_FAILED` instead of
|
|
185
198
|
* escaping `compile` as a raw throw, and a supplied interpretation whose snapshot copy
|
|
186
|
-
* loses prototype-carried members is
|
|
199
|
+
* loses prototype-carried members is captured rather than refused.
|
|
187
200
|
* - Neither engine is narrowed past its published contract. `Entity.value` is `unknown` and
|
|
188
201
|
* `LogicalResult` is an interface a class instance satisfies, so a value JSON cannot
|
|
189
|
-
* express is on-contract
|
|
190
|
-
*
|
|
191
|
-
*
|
|
202
|
+
* express is on-contract: its uncloneable leaves keep their identity inside the captured
|
|
203
|
+
* view rather than being refused.
|
|
204
|
+
* - `actions` and `domains` are read as option slots ONCE, at construction, so replacing
|
|
205
|
+
* either property on the options object afterwards changes nothing. The map each slot
|
|
206
|
+
* names is dereferenced on every `compile`, and each lookup captures its mapping once
|
|
207
|
+
* through the own descriptor. Mutating a map between calls therefore changes what the next
|
|
208
|
+
* call derives, while a mapping that answers differently on a second read cannot change
|
|
209
|
+
* what one call already derived.
|
|
192
210
|
*
|
|
193
211
|
* Whether the engine is correct, and whether it answers the same way twice, remain the
|
|
194
212
|
* caller's own problem.
|
|
@@ -638,6 +656,32 @@ import { Subject } from '@orkestrel/reason';
|
|
|
638
656
|
*/
|
|
639
657
|
export declare function briefToTrace(source: Brief): string;
|
|
640
658
|
|
|
659
|
+
/**
|
|
660
|
+
* Captures one stable, frozen view of a foreign contract value.
|
|
661
|
+
*
|
|
662
|
+
* @remarks
|
|
663
|
+
* Rebuilds the root and every reachable plain container from its own enumerable members.
|
|
664
|
+
* Unknown own members survive. Each published member absent from that copied own set is read
|
|
665
|
+
* once and materialized, which admits a class that supplies its contract through prototype
|
|
666
|
+
* accessors without leaving later reads attached to the live instance. Non-container leaves
|
|
667
|
+
* retain their identity, including functions that `structuredClone` cannot carry.
|
|
668
|
+
*
|
|
669
|
+
* @param source - The foreign value to capture.
|
|
670
|
+
* @param members - The published root member names to materialize when absent from its own set.
|
|
671
|
+
* @returns A deeply frozen plain view, or `source` itself when it is a primitive.
|
|
672
|
+
*
|
|
673
|
+
* @example
|
|
674
|
+
* ```ts
|
|
675
|
+
* import { captureValue } from '@orkestrel/brief'
|
|
676
|
+
*
|
|
677
|
+
* const leaf = () => 'ready'
|
|
678
|
+
* const owned = captureValue({ leaf }, ['leaf'])
|
|
679
|
+
* Reflect.get(owned, 'leaf') === leaf // true — an uncloneable leaf keeps its identity
|
|
680
|
+
* Object.isFrozen(owned) // true
|
|
681
|
+
* ```
|
|
682
|
+
*/
|
|
683
|
+
export declare function captureValue(source: unknown, members: readonly string[]): unknown;
|
|
684
|
+
|
|
641
685
|
/**
|
|
642
686
|
* One external source — what it is called, where it lives, and why it is cited.
|
|
643
687
|
*
|
|
@@ -1572,6 +1616,15 @@ import { Subject } from '@orkestrel/reason';
|
|
|
1572
1616
|
* all fail the same way — `undefined`, never a throw. Coerce a bare vocabulary value with
|
|
1573
1617
|
* `parseEnum` from `@orkestrel/contract` against the exported tuple instead.
|
|
1574
1618
|
*
|
|
1619
|
+
* The half of the intake pair that is OWNED BY CONSTRUCTION, which is what separates it from
|
|
1620
|
+
* `assertBrief`. The argument is text, so the graph the guard reads is one `JSON.parse` built
|
|
1621
|
+
* inside this call: it carries no caller identity, no accessor, and no alias back into anything
|
|
1622
|
+
* the caller still holds, and the parse-and-guard primitive this file imports from
|
|
1623
|
+
* `@orkestrel/contract` returns that same parsed graph rather than a second reading of it.
|
|
1624
|
+
* Every member `isBrief` checked therefore answers a later reader identically. The value is
|
|
1625
|
+
* fresh rather than frozen, so the caller owns it outright — reach for `snapshotBrief` when the
|
|
1626
|
+
* value came from code instead of from text.
|
|
1627
|
+
*
|
|
1575
1628
|
* @param value - The JSON text to parse.
|
|
1576
1629
|
* @returns The `Brief` when the parsed value satisfies `isBrief`, otherwise `undefined`.
|
|
1577
1630
|
*
|
package/dist/src/core/index.js
CHANGED
|
@@ -369,6 +369,84 @@ var isBrief = recordOf({
|
|
|
369
369
|
//#endregion
|
|
370
370
|
//#region src/core/cloners.ts
|
|
371
371
|
/**
|
|
372
|
+
* Captures one stable, frozen view of a foreign contract value.
|
|
373
|
+
*
|
|
374
|
+
* @remarks
|
|
375
|
+
* Rebuilds the root and every reachable plain container from its own enumerable members.
|
|
376
|
+
* Unknown own members survive. Each published member absent from that copied own set is read
|
|
377
|
+
* once and materialized, which admits a class that supplies its contract through prototype
|
|
378
|
+
* accessors without leaving later reads attached to the live instance. Non-container leaves
|
|
379
|
+
* retain their identity, including functions that `structuredClone` cannot carry.
|
|
380
|
+
*
|
|
381
|
+
* @param source - The foreign value to capture.
|
|
382
|
+
* @param members - The published root member names to materialize when absent from its own set.
|
|
383
|
+
* @returns A deeply frozen plain view, or `source` itself when it is a primitive.
|
|
384
|
+
*
|
|
385
|
+
* @example
|
|
386
|
+
* ```ts
|
|
387
|
+
* import { captureValue } from '@orkestrel/brief'
|
|
388
|
+
*
|
|
389
|
+
* const leaf = () => 'ready'
|
|
390
|
+
* const owned = captureValue({ leaf }, ['leaf'])
|
|
391
|
+
* Reflect.get(owned, 'leaf') === leaf // true — an uncloneable leaf keeps its identity
|
|
392
|
+
* Object.isFrozen(owned) // true
|
|
393
|
+
* ```
|
|
394
|
+
*/
|
|
395
|
+
function captureValue(source, members) {
|
|
396
|
+
if (source === null || typeof source !== "object" && typeof source !== "function") return source;
|
|
397
|
+
const target = Array.isArray(source) ? [] : Object.create(null);
|
|
398
|
+
const seen = new WeakMap([[source, target]]);
|
|
399
|
+
const captured = [target];
|
|
400
|
+
const pending = [[
|
|
401
|
+
source,
|
|
402
|
+
target,
|
|
403
|
+
members
|
|
404
|
+
]];
|
|
405
|
+
while (pending.length > 0) {
|
|
406
|
+
const frame = pending.pop();
|
|
407
|
+
if (frame === void 0) continue;
|
|
408
|
+
const [current, view, expected] = frame;
|
|
409
|
+
const entries = [];
|
|
410
|
+
const copied = /* @__PURE__ */ new Set();
|
|
411
|
+
for (const key of Reflect.ownKeys(current)) {
|
|
412
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(current, key);
|
|
413
|
+
if (descriptor === void 0 || !descriptor.enumerable) continue;
|
|
414
|
+
copied.add(key);
|
|
415
|
+
entries.push([key, "value" in descriptor ? descriptor.value : Reflect.get(current, key)]);
|
|
416
|
+
}
|
|
417
|
+
for (const key of expected ?? []) if (!copied.has(key)) entries.push([key, Reflect.get(current, key)]);
|
|
418
|
+
for (const [key, value] of entries) {
|
|
419
|
+
let owned = value;
|
|
420
|
+
if (value !== null && typeof value === "object") {
|
|
421
|
+
const existing = seen.get(value);
|
|
422
|
+
if (existing !== void 0) owned = existing;
|
|
423
|
+
else {
|
|
424
|
+
const prototype = Reflect.getPrototypeOf(value);
|
|
425
|
+
if (Array.isArray(value) || prototype === null || prototype === Object.prototype) {
|
|
426
|
+
const branch = Array.isArray(value) ? [] : Object.create(null);
|
|
427
|
+
seen.set(value, branch);
|
|
428
|
+
captured.push(branch);
|
|
429
|
+
pending.push([
|
|
430
|
+
value,
|
|
431
|
+
branch,
|
|
432
|
+
void 0
|
|
433
|
+
]);
|
|
434
|
+
owned = branch;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
Reflect.defineProperty(view, key, {
|
|
439
|
+
value: owned,
|
|
440
|
+
enumerable: true,
|
|
441
|
+
configurable: false,
|
|
442
|
+
writable: false
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
for (const view of captured) Object.freeze(view);
|
|
447
|
+
return target;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
372
450
|
* Return a deeply owned, deeply frozen copy of a brief, refusing anything off-contract.
|
|
373
451
|
*
|
|
374
452
|
* @remarks
|
|
@@ -1163,6 +1241,15 @@ function errorToMessage(error) {
|
|
|
1163
1241
|
* nothing, so it is an assertion rather than a factory. Reserve it for programmer-error
|
|
1164
1242
|
* contexts where invalidity is a bug.
|
|
1165
1243
|
*
|
|
1244
|
+
* Intake NARROWS, and transfers no ownership. What comes back is the caller's own object,
|
|
1245
|
+
* so a member carried on an accessor can answer this guard one way and a later reader
|
|
1246
|
+
* another. The division is deliberate: the borrowed-engine law governs values this package
|
|
1247
|
+
* pulls across a seam it called, and a value handed in at the door stays the caller's.
|
|
1248
|
+
* `snapshotBrief` is the ownership door, and `pinBrief`, `BriefManager`, `briefToMarkdown`,
|
|
1249
|
+
* `briefToGoal`, and `briefToDispatch` take it. `briefToSubject`, `briefToContent`, and
|
|
1250
|
+
* `briefToTrace` read the value they are handed instead, so a caller reaching one of those
|
|
1251
|
+
* directly owns that reading. Pass `assertBrief` a value you already own.
|
|
1252
|
+
*
|
|
1166
1253
|
* @param data - The candidate brief data.
|
|
1167
1254
|
* @returns The same value, now known to satisfy {@link Brief}.
|
|
1168
1255
|
* @throws {@link BriefError} `INVALID` when `data` fails `isBrief`.
|
|
@@ -1502,8 +1589,10 @@ function deriveStatement(text) {
|
|
|
1502
1589
|
* ```
|
|
1503
1590
|
*/
|
|
1504
1591
|
function deriveTask(intent, text, actions, domains) {
|
|
1505
|
-
const
|
|
1506
|
-
const
|
|
1592
|
+
const operationDescriptor = Object.getOwnPropertyDescriptor(actions, intent.action);
|
|
1593
|
+
const domainDescriptor = Object.getOwnPropertyDescriptor(domains, intent.domain);
|
|
1594
|
+
const operation = operationDescriptor === void 0 ? void 0 : "value" in operationDescriptor ? operationDescriptor.value : operationDescriptor.get === void 0 ? void 0 : Reflect.apply(operationDescriptor.get, actions, []);
|
|
1595
|
+
const domain = domainDescriptor === void 0 ? void 0 : "value" in domainDescriptor ? domainDescriptor.value : domainDescriptor.get === void 0 ? void 0 : Reflect.apply(domainDescriptor.get, domains, []);
|
|
1507
1596
|
if (!isTaskOperation(operation) || !isTaskDomain(domain)) return void 0;
|
|
1508
1597
|
const statement = deriveStatement(text);
|
|
1509
1598
|
return statement.length === 0 ? void 0 : task(operation, domain, statement);
|
|
@@ -1569,6 +1658,15 @@ function deriveGaps(ambiguities) {
|
|
|
1569
1658
|
* all fail the same way — `undefined`, never a throw. Coerce a bare vocabulary value with
|
|
1570
1659
|
* `parseEnum` from `@orkestrel/contract` against the exported tuple instead.
|
|
1571
1660
|
*
|
|
1661
|
+
* The half of the intake pair that is OWNED BY CONSTRUCTION, which is what separates it from
|
|
1662
|
+
* `assertBrief`. The argument is text, so the graph the guard reads is one `JSON.parse` built
|
|
1663
|
+
* inside this call: it carries no caller identity, no accessor, and no alias back into anything
|
|
1664
|
+
* the caller still holds, and the parse-and-guard primitive this file imports from
|
|
1665
|
+
* `@orkestrel/contract` returns that same parsed graph rather than a second reading of it.
|
|
1666
|
+
* Every member `isBrief` checked therefore answers a later reader identically. The value is
|
|
1667
|
+
* fresh rather than frozen, so the caller owns it outright — reach for `snapshotBrief` when the
|
|
1668
|
+
* value came from code instead of from text.
|
|
1669
|
+
*
|
|
1572
1670
|
* @param value - The JSON text to parse.
|
|
1573
1671
|
* @returns The `Brief` when the parsed value satisfies `isBrief`, otherwise `undefined`.
|
|
1574
1672
|
*
|
|
@@ -1879,7 +1977,15 @@ var BriefCompiler = class {
|
|
|
1879
1977
|
}
|
|
1880
1978
|
gate(source) {
|
|
1881
1979
|
this.#refuseDestroyed();
|
|
1882
|
-
const ruled = attempt(() => this.#own(this.#reason.reason(briefToSubject(source), gateDefinition())
|
|
1980
|
+
const ruled = attempt(() => this.#own(this.#reason.reason(briefToSubject(source), gateDefinition()), [
|
|
1981
|
+
"reasoning",
|
|
1982
|
+
"conclusion",
|
|
1983
|
+
"rules",
|
|
1984
|
+
"count",
|
|
1985
|
+
"success",
|
|
1986
|
+
"trace",
|
|
1987
|
+
"errors"
|
|
1988
|
+
]));
|
|
1883
1989
|
if (!ruled.success) throw new BriefError("GATE_FAILED", errorToMessage(ruled.error), {
|
|
1884
1990
|
stage: "gate",
|
|
1885
1991
|
field: "reason"
|
|
@@ -1902,14 +2008,30 @@ var BriefCompiler = class {
|
|
|
1902
2008
|
#snapshot(input) {
|
|
1903
2009
|
return freezeDeep(structuredClone(input));
|
|
1904
2010
|
}
|
|
1905
|
-
#own(value) {
|
|
2011
|
+
#own(value, members) {
|
|
1906
2012
|
const cloned = attempt(() => structuredClone(value));
|
|
1907
|
-
return
|
|
2013
|
+
return cloned.success ? freezeDeep(cloned.value) : captureValue(value, members);
|
|
1908
2014
|
}
|
|
1909
2015
|
#read(input, raw, stages, failures) {
|
|
2016
|
+
const members = [
|
|
2017
|
+
"text",
|
|
2018
|
+
"normalized",
|
|
2019
|
+
"intent",
|
|
2020
|
+
"entities",
|
|
2021
|
+
"subject",
|
|
2022
|
+
"definition",
|
|
2023
|
+
"mappings",
|
|
2024
|
+
"ambiguities",
|
|
2025
|
+
"prompt",
|
|
2026
|
+
"stages",
|
|
2027
|
+
"failures",
|
|
2028
|
+
"complete",
|
|
2029
|
+
"confidence",
|
|
2030
|
+
"digest"
|
|
2031
|
+
];
|
|
1910
2032
|
const text = input.text;
|
|
1911
2033
|
if (text !== void 0) {
|
|
1912
|
-
const read = attempt(() => this.#own(this.#interpret.interpret(text)));
|
|
2034
|
+
const read = attempt(() => this.#own(this.#interpret.interpret(text), members));
|
|
1913
2035
|
if (read.success && isInterpretation(read.value)) {
|
|
1914
2036
|
stages.push(Object.freeze({
|
|
1915
2037
|
stage: "interpret",
|
|
@@ -1934,7 +2056,8 @@ var BriefCompiler = class {
|
|
|
1934
2056
|
const supplied = input.interpretation;
|
|
1935
2057
|
if (supplied === void 0 || isInterpretation(supplied)) return supplied;
|
|
1936
2058
|
const live = raw.interpretation;
|
|
1937
|
-
|
|
2059
|
+
const captured = attempt(() => captureValue(live, members));
|
|
2060
|
+
if (captured.success && isInterpretation(captured.value)) return captured.value;
|
|
1938
2061
|
const message = "The supplied interpretation does not satisfy the published shape";
|
|
1939
2062
|
stages.push(Object.freeze({
|
|
1940
2063
|
stage: "interpret",
|
|
@@ -1958,7 +2081,7 @@ var BriefCompiler = class {
|
|
|
1958
2081
|
code: "BLOCKED",
|
|
1959
2082
|
message: `Gate refused: ${unready.join(", ")}`
|
|
1960
2083
|
};
|
|
1961
|
-
if (
|
|
2084
|
+
if (verdict === void 0) return void 0;
|
|
1962
2085
|
const refused = verdict.rules.filter((entry) => !entry.conclusion).map((entry) => entry.id).join(", ");
|
|
1963
2086
|
if (refused.length === 0) return {
|
|
1964
2087
|
stage: "gate",
|
|
@@ -2092,6 +2215,6 @@ function createBriefContract() {
|
|
|
2092
2215
|
return createContract(briefShape);
|
|
2093
2216
|
}
|
|
2094
2217
|
//#endregion
|
|
2095
|
-
export { BLANK_PATTERN, BriefCompiler, BriefError, BriefManager, DEFAULT_BRIEF_TURNS, GATE_ID, LINE_BREAK_PATTERN, OUTPUT_FORMATS, RISK_SEVERITIES, SINGLE_LINE_PATTERN, TASK_DOMAINS, TASK_OPERATIONS, assertBrief, brief, briefShape, briefToContent, briefToDispatch, briefToGoal, briefToHash, briefToMarkdown, briefToSubject, briefToTrace, citation, citationShape, countSentences, createBriefCompiler, createBriefContract, createBriefManager, deriveGaps, deriveGivens, deriveStatement, deriveTask, errorToMessage, example, exampleShape, exampleToLines, findBlockingGaps, findManifestOverlaps, findUngrantedAuthority, findUnmetRules, findUnpairedGaps, freezeBranch, freezeDeep, gap, gapShape, gateDefinition, given, givenShape, isBrief, isBriefError, isCitation, isExample, isGap, isGiven, isLine, isManifest, isOutcome, isOutput, isOutputFormat, isProof, isReference, isRisk, isRiskSeverity, isTask, isTaskDomain, isTaskOperation, isText, lineShape, manifest, manifestShape, outcome, outcomeShape, output, outputShape, parseBrief, pinBrief, proof, proofShape, reference, referenceShape, risk, riskShape, snapshotBrief, task, taskShape, textShape, validateBrief };
|
|
2218
|
+
export { BLANK_PATTERN, BriefCompiler, BriefError, BriefManager, DEFAULT_BRIEF_TURNS, GATE_ID, LINE_BREAK_PATTERN, OUTPUT_FORMATS, RISK_SEVERITIES, SINGLE_LINE_PATTERN, TASK_DOMAINS, TASK_OPERATIONS, assertBrief, brief, briefShape, briefToContent, briefToDispatch, briefToGoal, briefToHash, briefToMarkdown, briefToSubject, briefToTrace, captureValue, citation, citationShape, countSentences, createBriefCompiler, createBriefContract, createBriefManager, deriveGaps, deriveGivens, deriveStatement, deriveTask, errorToMessage, example, exampleShape, exampleToLines, findBlockingGaps, findManifestOverlaps, findUngrantedAuthority, findUnmetRules, findUnpairedGaps, freezeBranch, freezeDeep, gap, gapShape, gateDefinition, given, givenShape, isBrief, isBriefError, isCitation, isExample, isGap, isGiven, isLine, isManifest, isOutcome, isOutput, isOutputFormat, isProof, isReference, isRisk, isRiskSeverity, isTask, isTaskDomain, isTaskOperation, isText, lineShape, manifest, manifestShape, outcome, outcomeShape, output, outputShape, parseBrief, pinBrief, proof, proofShape, reference, referenceShape, risk, riskShape, snapshotBrief, task, taskShape, textShape, validateBrief };
|
|
2096
2219
|
|
|
2097
2220
|
//# sourceMappingURL=index.js.map
|