@astrale-os/kernel-core 0.9.0-beta.51 → 0.9.0-beta.53

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.
@@ -3,8 +3,12 @@ import { AuthValueError } from '../error.js';
3
3
  import { admitAuthorityExpr } from './admission/index.js';
4
4
  import { AUTHORITY_PREDICATE_VERSION } from './language/index.js';
5
5
  import { canonicalizeAdmitted } from './normalization/index.js';
6
+ import { ownsCanonical } from './ownership.optimization.js';
6
7
  /** Re-admit one persisted or crossing canonical authority predicate. */
7
8
  export function accept(input) {
9
+ // The owner retains only deeply immutable, detached canonical predicates.
10
+ if (ownsCanonical(input))
11
+ return input;
8
12
  try {
9
13
  const admitted = portable.accept(input);
10
14
  if (admitted === null || Array.isArray(admitted) || typeof admitted !== 'object') {
@@ -1,7 +1,19 @@
1
+ import * as portable from '@astrale-os/kernel-dsl/value';
1
2
  // Static construction provenance only. No evaluated authority or graph facts live here.
2
3
  const canonical = new WeakSet();
3
4
  /** Called only by the owner after detachment, admission and immutable normalization. */
4
5
  export function ownCanonical(predicate) {
6
+ // Carry immutable structural provenance through containing Plans as well as Core calls.
7
+ // The normalized envelope can exceed a portable boundary's default budget even when the
8
+ // constructor's expression fits. In that case retain Core ownership only: a later crossing
9
+ // still applies its own limits, without adding a new constructor failure here.
10
+ try {
11
+ predicate = portable.acceptImmutable(predicate);
12
+ }
13
+ catch (cause) {
14
+ if (!(cause instanceof portable.BoundaryError) || cause.code !== 'VALUE_LIMIT')
15
+ throw cause;
16
+ }
5
17
  canonical.add(predicate);
6
18
  return predicate;
7
19
  }
@@ -28,7 +28,7 @@ export class GraphSpecDecodeError extends TypeError {
28
28
  /** Strengthen unknown JSON into detached immutable structural graph values. */
29
29
  export function decodeGraphSpec(input) {
30
30
  try {
31
- const value = decodeWire(graphSpecSchema, portable.accept(input), specInvalid);
31
+ const value = decodeWire(graphSpecSchema, portable.acceptForRead(input), specInvalid);
32
32
  const nodes = value.nodes.map((node, index) => decodeSpecNode(node, `/nodes/${index}`));
33
33
  const edges = value.edges.map((edge, index) => decodeSpecEdge(edge, `/edges/${index}`));
34
34
  validateGraphSpec(nodes, edges);
@@ -35,7 +35,7 @@ export function queryResultSelection(input) {
35
35
  /** Decode exact QueryResult structure; Query-relative closure remains Runtime-owned. */
36
36
  export function decodeQueryResult(input) {
37
37
  try {
38
- const value = decodeWire(queryResultSchema, portable.accept(input), invalid);
38
+ const value = decodeWire(queryResultSchema, portable.acceptForRead(input), invalid);
39
39
  if (value.kind === 'graph') {
40
40
  const graph = decodeGraph(value.graph, '/graph');
41
41
  const selection = decodeSelection(value.selection, graph);