@sema-agent/core 7.71.1 → 7.72.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.
Files changed (151) hide show
  1. package/CHANGELOG.md +181 -0
  2. package/dist/agents/cross-session-ref.d.ts +2 -2
  3. package/dist/agents/cross-session-ref.js +7 -2
  4. package/dist/agents/inherited-tool-pool.d.ts +4 -1
  5. package/dist/agents/inherited-tool-pool.js +7 -5
  6. package/dist/agents/send-message-tool.js +6 -2
  7. package/dist/agents/subagent.js +5 -1
  8. package/dist/agents/verify.js +1 -0
  9. package/dist/core/a2a.d.ts +24 -3
  10. package/dist/core/a2a.js +27 -8
  11. package/dist/core/agent-state.d.ts +28 -7
  12. package/dist/core/agent-state.js +19 -6
  13. package/dist/core/approval-object.d.ts +7 -3
  14. package/dist/core/approval-object.js +30 -9
  15. package/dist/core/checkpoint-features.d.ts +13 -3
  16. package/dist/core/checkpoint-features.js +34 -5
  17. package/dist/core/checkpoint-row-verdict.d.ts +1 -1
  18. package/dist/core/checkpoint-row-verdict.js +3 -3
  19. package/dist/core/effective-path-target.d.ts +19 -0
  20. package/dist/core/effective-path-target.js +95 -38
  21. package/dist/core/engine-notice.d.ts +4 -1
  22. package/dist/core/engine-version.js +1 -1
  23. package/dist/core/file-history-store.d.ts +15 -4
  24. package/dist/core/file-history-store.js +53 -23
  25. package/dist/core/gate-fold.js +3 -1
  26. package/dist/core/governance-codes.d.ts +4 -1
  27. package/dist/core/governance-codes.js +4 -0
  28. package/dist/core/judged-read.d.ts +57 -0
  29. package/dist/core/judged-read.js +1 -0
  30. package/dist/core/mcp-host-seat.d.ts +5 -0
  31. package/dist/core/mcp-host-seat.js +7 -1
  32. package/dist/core/mcp.js +3 -1
  33. package/dist/core/memory-engine/index.d.ts +1 -1
  34. package/dist/core/memory-engine/index.js +1 -1
  35. package/dist/core/memory-engine/layout.js +6 -4
  36. package/dist/core/memory-engine/scope-contract.d.ts +59 -6
  37. package/dist/core/memory-engine/scope-contract.js +90 -25
  38. package/dist/core/mounted-mcp.d.ts +7 -2
  39. package/dist/core/mounted-mcp.js +10 -1
  40. package/dist/core/param-rule-reach.d.ts +8 -3
  41. package/dist/core/param-rule-reach.js +9 -1
  42. package/dist/core/parent-spec-seat.d.ts +11 -1
  43. package/dist/core/parent-spec-seat.js +14 -0
  44. package/dist/core/peer-registration.d.ts +52 -0
  45. package/dist/core/peer-registration.js +37 -0
  46. package/dist/core/peer-seat.d.ts +3 -1
  47. package/dist/core/permission-rule-model.js +1 -1
  48. package/dist/core/runner/chain-mismatch.d.ts +32 -0
  49. package/dist/core/runner/chain-mismatch.js +29 -0
  50. package/dist/core/runner/changes-history.d.ts +1 -0
  51. package/dist/core/runner/changes-history.js +2 -2
  52. package/dist/core/runner/contracts.d.ts +3 -0
  53. package/dist/core/runner/file-history-restore.d.ts +3 -1
  54. package/dist/core/runner/file-history-restore.js +9 -6
  55. package/dist/core/runner/loaded-skills.d.ts +2 -0
  56. package/dist/core/runner/loaded-skills.js +10 -0
  57. package/dist/core/runner/person-path-rows.d.ts +2 -4
  58. package/dist/core/runner/person-path-rows.js +2 -3
  59. package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -0
  60. package/dist/core/runner/prepare-caps-and-workflow.js +7 -2
  61. package/dist/core/runner/prepare-file-history.js +1 -1
  62. package/dist/core/runner/prepare-hands-readface.d.ts +5 -0
  63. package/dist/core/runner/prepare-hands-readface.js +24 -21
  64. package/dist/core/runner/prepare-inherited-gate.d.ts +2 -2
  65. package/dist/core/runner/prepare-inherited-gate.js +1 -1
  66. package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -2
  67. package/dist/core/runner/prepare-memory-engine-session.js +2 -2
  68. package/dist/core/runner/prepare-memory.js +3 -15
  69. package/dist/core/runner/prepare-project-context.d.ts +1 -1
  70. package/dist/core/runner/prepare-project-context.js +3 -7
  71. package/dist/core/runner/prepare-protocol-tools.d.ts +5 -0
  72. package/dist/core/runner/prepare-protocol-tools.js +2 -2
  73. package/dist/core/runner/prepare-task.js +20 -16
  74. package/dist/core/runner/prepare-wiring-manifest.d.ts +2 -0
  75. package/dist/core/runner/prepare-wiring-manifest.js +4 -3
  76. package/dist/core/runner/read-session-changes.js +1 -1
  77. package/dist/core/runner/resume-checkpoint-screen.d.ts +8 -7
  78. package/dist/core/runner/resume-checkpoint-screen.js +7 -6
  79. package/dist/core/runner/rewind-files.js +3 -2
  80. package/dist/core/runner/run-leg.js +6 -2
  81. package/dist/core/runner/terminal-account.d.ts +4 -0
  82. package/dist/core/runner/terminal-account.js +7 -2
  83. package/dist/core/runner/tool-face-overlay.d.ts +2 -11
  84. package/dist/core/runner/tool-face-overlay.js +39 -0
  85. package/dist/core/runner/trim-stretch.js +7 -2
  86. package/dist/core/scheduler.d.ts +47 -7
  87. package/dist/core/scheduler.js +19 -7
  88. package/dist/core/secret-env.d.ts +7 -0
  89. package/dist/core/secret-env.js +1 -1
  90. package/dist/core/sensitive-path-policy.js +14 -7
  91. package/dist/core/shell-read-silence.js +1 -0
  92. package/dist/core/store-contracts/checkpoint-store-contract.js +7 -0
  93. package/dist/core/task-event.d.ts +4 -3
  94. package/dist/core/task-notification.d.ts +2 -1
  95. package/dist/core/task-spec.d.ts +13 -5
  96. package/dist/core/tool-catalog-entries.js +2 -0
  97. package/dist/core/tool-face-reader.js +1 -1
  98. package/dist/core/tool-face.d.ts +7 -0
  99. package/dist/core/tool-face.js +1 -0
  100. package/dist/core/tool-mount-facts.d.ts +4 -2
  101. package/dist/core/tool-mount-facts.js +3 -3
  102. package/dist/core/tool-mount-plan.d.ts +4 -2
  103. package/dist/core/tool-mount-plan.js +5 -5
  104. package/dist/core/tool-mount-static.d.ts +1 -1
  105. package/dist/core/tool-mount-static.js +25 -13
  106. package/dist/core/tool-registry.d.ts +33 -1
  107. package/dist/core/tool-registry.js +33 -0
  108. package/dist/core/tool-roster.d.ts +16 -0
  109. package/dist/core/tool-roster.js +6 -0
  110. package/dist/core/tool-spec.d.ts +4 -2
  111. package/dist/core/tools.d.ts +6 -0
  112. package/dist/core/tools.js +1 -1
  113. package/dist/core/wiring-manifest.d.ts +66 -12
  114. package/dist/core/wiring-manifest.js +37 -1
  115. package/dist/engine/harness/messages.d.ts +1 -1
  116. package/dist/engine/harness/messages.js +2 -1
  117. package/dist/engine/loop/types.d.ts +2 -0
  118. package/dist/engine/session/session.js +1 -1
  119. package/dist/index.d.ts +9 -5
  120. package/dist/index.js +7 -4
  121. package/dist/orchestration/workflow.js +2 -1
  122. package/dist/stores/file/adoption/marker.d.ts +2 -27
  123. package/dist/stores/file/adoption/marker.js +12 -0
  124. package/dist/stores/file/index.d.ts +1 -1
  125. package/dist/stores/file/index.js +1 -1
  126. package/dist/tools/artifact/artifact-tool.js +11 -6
  127. package/dist/tools/fs/file-read-check.d.ts +45 -11
  128. package/dist/tools/fs/file-read-check.js +200 -57
  129. package/dist/tools/fs/judged-reads.d.ts +51 -0
  130. package/dist/tools/fs/judged-reads.js +68 -0
  131. package/dist/tools/fs/safety.d.ts +8 -0
  132. package/dist/tools/fs/safety.js +12 -1
  133. package/dist/tools/fs/shell-read-check.d.ts +16 -3
  134. package/dist/tools/fs/shell-read-check.js +4 -1
  135. package/dist/tools/fs/shell-read-establish.js +13 -3
  136. package/dist/tools/scheduler-store-move.d.ts +74 -0
  137. package/dist/tools/scheduler-store-move.js +103 -0
  138. package/dist/tools/scheduler-tools.d.ts +43 -29
  139. package/dist/tools/scheduler-tools.js +161 -118
  140. package/package.json +2 -2
  141. package/test/export-surface.snapshot.json +43 -3
  142. package/wire-changes/answers/core-stores-sql@7.72.0.json +12 -0
  143. package/wire-changes/answers/core@7.72.0.json +84 -0
  144. package/wire-changes/answers/mods-kernel@7.72.0.json +7 -0
  145. package/wire-changes/answers/primitives@7.72.0.json +6 -0
  146. package/wire-changes/answers/wiki-gate@7.72.0.json +7 -0
  147. package/wire-changes/core-stores-sql@7.72.0.json +215 -0
  148. package/wire-changes/core@7.72.0.json +2426 -0
  149. package/wire-changes/mods-kernel@7.72.0.json +147 -0
  150. package/wire-changes/primitives@7.72.0.json +143 -0
  151. package/wire-changes/wiki-gate@7.72.0.json +145 -0
@@ -1,8 +1,9 @@
1
- import { effectivePathSpellingOf } from "../../core/effective-path-target.js";
2
- import { pathTargetOf } from "../../core/tool-registry.js";
1
+ import { effectivePathSpellingOf, effectivePathSpellingsOf } from "../../core/effective-path-target.js";
2
+ import { declaredReadSlotOf, PATH_TARGET_ELEMENTS_MAX, pathTargetOf } from "../../core/tool-registry.js";
3
+ import { judgedReadsOf as portOf } from "./judged-reads.js";
3
4
  import { fitMiddle, READ_DENY_SENTENCE_PART_MAX, seatForCall } from "./read-deny.js";
4
- import { resolveKey, violationDetails, violationText } from "./safety.js";
5
- import { readStationMemberOf } from "./shell-read-check.js";
5
+ import { resolveKey, violationDetails, violationText, withinAnyRoot } from "./safety.js";
6
+ import { readStationMemberOf, readTargetsRefusedDetails as readTargetsRefusedCard, unestablishedDetails as unestablishedCard } from "./shell-read-check.js";
6
7
  import { decideShellRead, grantOfferFor, parentDirLexically } from "./shell-read-judge.js";
7
8
  const ADMISSION_MAX = 1024;
8
9
  export function outsideReadDisposition(leg) {
@@ -11,70 +12,190 @@ export function outsideReadDisposition(leg) {
11
12
  return leg.readOnlyMount ? "tool_fence" : "question";
12
13
  }
13
14
  export const READ_BLOCK_REMEDY = "This task refuses reads outside its directories (blockReadsOutsideRoots); ask the user to add the directory to the task's directories.";
15
+ export function declaredReadOf(call) {
16
+ return declaredReadSlotOf(call);
17
+ }
14
18
  const VOUCH = { disposition: "vouch", finding: "none" };
19
+ function setBounded(map, key, value) {
20
+ map.delete(key);
21
+ if (map.size >= ADMISSION_MAX) {
22
+ const oldest = map.keys().next().value;
23
+ if (oldest !== undefined)
24
+ map.delete(oldest);
25
+ }
26
+ map.set(key, value);
27
+ }
28
+ function namedTargets(targets) {
29
+ if (targets.length === 1)
30
+ return `"${fitMiddle(targets[0], READ_DENY_SENTENCE_PART_MAX)}"`;
31
+ const shown = [];
32
+ for (const t of targets) {
33
+ const next = [...shown, `"${t}"`].join(", ");
34
+ if (next.length > READ_DENY_SENTENCE_PART_MAX)
35
+ break;
36
+ shown.push(`"${t}"`);
37
+ }
38
+ if (shown.length === targets.length)
39
+ return shown.join(", ");
40
+ return `${shown.length > 0 ? `${shown.join(", ")} and ` : ""}${targets.length - shown.length} more (${targets.length} in all)`;
41
+ }
15
42
  export function createFileReadStation(opts) {
16
43
  const admissions = new Map();
17
- const remember = (toolCallId, key) => {
18
- if (admissions.size >= ADMISSION_MAX) {
19
- const oldest = admissions.keys().next().value;
20
- if (oldest !== undefined)
21
- admissions.delete(oldest);
44
+ const declaredCalls = new Map();
45
+ const pendingDeclared = new Map();
46
+ const tables = {
47
+ env: opts.env,
48
+ rootCanonical: opts.rootCanonical,
49
+ roots: opts.roots,
50
+ ...(opts.readDeny !== undefined ? { readDeny: opts.readDeny } : {}),
51
+ ...(opts.readFace !== undefined ? { readFace: opts.readFace } : {}),
52
+ ...(opts.excluded !== undefined ? { excluded: opts.excluded } : {}),
53
+ ...(opts.exempt !== undefined ? { exempt: opts.exempt } : {}),
54
+ ...(opts.outsideReads === "refusal" ? { outsideRemedy: READ_BLOCK_REMEDY } : {}),
55
+ };
56
+ const refuse = (sentence, finding, details) => ({ disposition: "refuse", finding, sentence, ...(details !== undefined ? { details } : {}) });
57
+ const judgeTargets = async (j, signal) => {
58
+ const only = (verdict) => ({ verdict });
59
+ const { toolName } = j;
60
+ const extra = seatForCall(opts.roots, j.toolCallId)();
61
+ const deny = seatForCall(opts.readDeny, j.toolCallId);
62
+ const roots = [opts.rootCanonical, ...extra];
63
+ const allowed = fitMiddle(roots.join(", "), READ_DENY_SENTENCE_PART_MAX);
64
+ const outside = [];
65
+ const keys = [];
66
+ for (const t of j.targets) {
67
+ const r = await resolveKey(opts.env, opts.rootCanonical, t.spelled, signal, t.base, extra, undefined, deny, opts.readFace);
68
+ if (r.ok) {
69
+ keys.push(r.key);
70
+ continue;
71
+ }
72
+ const v = r.violation;
73
+ const outsideTarget = v.code === "path_not_in_root" ? v.target : undefined;
74
+ if (outsideTarget !== undefined && opts.exempt?.(outsideTarget) === true) {
75
+ keys.push(outsideTarget);
76
+ continue;
77
+ }
78
+ const details = violationDetails(v);
79
+ if (opts.outsideReads === "refusal") {
80
+ if (outsideTarget === undefined)
81
+ return only(refuse(violationText(toolName, v), v.code === "read_path_denied" ? "deny_hit" : "none", details));
82
+ return only(refuse(`Error (${toolName}): "${fitMiddle(outsideTarget, READ_DENY_SENTENCE_PART_MAX)}" is outside the directories this task may read (${allowed}). ${READ_BLOCK_REMEDY}`, "outside_roots", details));
83
+ }
84
+ if (outsideTarget !== undefined && opts.outsideReads !== "tool_fence" && opts.excluded?.(outsideTarget) !== true) {
85
+ outside.push({ target: outsideTarget, v });
86
+ keys.push(outsideTarget);
87
+ continue;
88
+ }
89
+ if (j.declared)
90
+ return only(refuse(violationText(toolName, v), v.code === "read_path_denied" ? "deny_hit" : "none", details));
91
+ return only(VOUCH);
92
+ }
93
+ if (outside.length === 0)
94
+ return { verdict: VOUCH, keys };
95
+ const targets = outside.map((o) => o.target);
96
+ const named = namedTargets(targets);
97
+ const first = violationDetails(outside[0].v);
98
+ const details = first !== undefined && first.code === "path_not_in_root" && targets.length > 1 ? { ...first, targets } : first;
99
+ const disposition = decideShellRead("outside_roots", j.seat === "rejudge" ? "rejudge" : "file_tool");
100
+ const are = targets.length === 1 ? "is" : "are";
101
+ if (disposition === "refuse") {
102
+ return only(refuse(j.seat === "rejudge"
103
+ ? `Error (${toolName}): the approved edit reads ${named}, outside the directories allowed for this session (${allowed}) — re-submit it as a fresh call and answer its card.`
104
+ : `Error (${toolName}): ${named} ${are} outside the directories allowed for this session (${allowed}).`, "outside_roots", details));
105
+ }
106
+ const head = targets[0];
107
+ const info = j.mayBeDirectory ? await opts.env.fileInfo(head, signal) : undefined;
108
+ const proposed = grantOfferFor(info?.ok === true && info.value.kind === "directory" ? head : parentDirLexically(head), targets.length === 1 ? head : undefined, { roots, ...(opts.homeDir !== undefined ? { homeDir: opts.homeDir } : {}) });
109
+ const offer = proposed !== undefined && targets.every((t) => withinAnyRoot([proposed.dir], t)) ? proposed : undefined;
110
+ return {
111
+ verdict: {
112
+ disposition,
113
+ finding: "outside_roots",
114
+ sentence: `reads outside the allowed directories for this session: ${named} ${are} not under ${allowed}`,
115
+ ...(details !== undefined ? { details } : {}),
116
+ ...(offer !== undefined ? { readRootCandidate: { dir: offer.dir, ...(offer.covers !== undefined ? { covers: offer.covers } : {}), clearsThisAsk: true } } : {}),
117
+ ...(j.declared ? { cause: { code: "read.outside_roots", roots: { shown: targets, total: targets.length } } } : {}),
118
+ admit: () => j.admit(targets),
119
+ },
120
+ keys,
121
+ };
122
+ };
123
+ const judgeDeclared = (call, pt, args, cwd, signal, callOpts) => {
124
+ const toolName = call.toolName;
125
+ const toolCallId = callOpts.toolCallId;
126
+ const mine = {};
127
+ if (toolCallId !== undefined) {
128
+ declaredCalls.delete(toolCallId);
129
+ setBounded(pendingDeclared, toolCallId, mine);
22
130
  }
23
- admissions.set(toolCallId, key);
131
+ let judged;
132
+ const landed = (verdict) => {
133
+ if (toolCallId === undefined || pendingDeclared.get(toolCallId) !== mine)
134
+ return verdict;
135
+ pendingDeclared.delete(toolCallId);
136
+ if (verdict.disposition !== "refuse" && judged !== undefined)
137
+ setBounded(declaredCalls, toolCallId, judged);
138
+ return verdict;
139
+ };
140
+ const sels = effectivePathSpellingsOf({ toolName, args, ...(call.face !== undefined ? { face: call.face } : {}) }, pt, { root: opts.rootCanonical, cwd }) ?? [];
141
+ if (sels.length > PATH_TARGET_ELEMENTS_MAX)
142
+ return Promise.resolve(landed(refuse(`Error (${toolName}): this call names ${sels.length} paths; a call may name at most ${PATH_TARGET_ELEMENTS_MAX}. Split it into calls of at most ${PATH_TARGET_ELEMENTS_MAX}; the call was not run.`, "none", readTargetsRefusedCard("read_targets_over_limit"))));
143
+ const targets = [];
144
+ for (const sel of sels) {
145
+ if ("refused" in sel)
146
+ return Promise.resolve(landed(refuse(`Error (${toolName}): a path this call names is one this environment refuses (${String(sel.refused)}); the call was not run.`, "none")));
147
+ const spelled = "malformed" in sel ? undefined : (sel.spelled ?? sel.base);
148
+ if ("malformed" in sel || spelled === undefined)
149
+ return Promise.resolve(landed(refuse(`Error (${toolName}): a value of "${pt.param}" is not a path (the slot takes a non-empty string${pt.each === true ? " or a list of them" : ""}); the call was not run.`, "none", readTargetsRefusedCard("read_target_not_a_path"))));
150
+ targets.push({ spelled, base: sel.spelled !== undefined ? sel.base : undefined });
151
+ }
152
+ mine.targets = targets.length;
153
+ const admitted = new Set();
154
+ return judgeTargets({ toolName, targets, toolCallId, seat: callOpts.seat, declared: true, mayBeDirectory: true, admit: (outside) => outside.forEach((o) => admitted.add(o)) }, signal).then(({ verdict, keys }) => {
155
+ if (verdict.disposition !== "refuse" && keys !== undefined)
156
+ judged = { toolName, elements: targets.map((t, i) => ({ spelled: t.spelled, base: t.base, key: keys[i] })), admitted };
157
+ return landed(verdict);
158
+ });
24
159
  };
25
160
  const check = {
26
161
  judge(call, args, cwd, signal, callOpts) {
162
+ const declared = declaredReadOf(call);
163
+ if (declared !== undefined)
164
+ return judgeDeclared(call, declared, args, cwd, signal, callOpts);
27
165
  const member = readStationMemberOf(call, opts.tools)?.name;
28
166
  if (member === undefined)
29
167
  return null;
30
- const toolName = call.toolName;
31
- const selection = effectivePathSpellingOf({ toolName, args }, pathTargetOf(member), { root: opts.rootCanonical, cwd });
168
+ const selection = effectivePathSpellingOf({ toolName: call.toolName, args }, pathTargetOf(member), { root: opts.rootCanonical, cwd });
32
169
  if (selection === undefined || "refused" in selection || selection.spelled === undefined)
33
170
  return null;
34
- const spelled = selection.spelled;
35
- return (async () => {
36
- const extra = seatForCall(opts.roots, callOpts.toolCallId)();
37
- const r = await resolveKey(opts.env, opts.rootCanonical, spelled, signal, selection.base, extra, undefined, seatForCall(opts.readDeny, callOpts.toolCallId), opts.readFace);
38
- if (opts.outsideReads === "refusal") {
39
- if (r.ok || (r.violation.code === "path_not_in_root" && r.violation.target !== undefined && opts.exempt?.(r.violation.target) === true))
40
- return VOUCH;
41
- const v = r.violation;
42
- const details = violationDetails(v);
43
- if (v.code !== "path_not_in_root" || v.target === undefined)
44
- return { disposition: "refuse", finding: v.code === "read_path_denied" ? "deny_hit" : "none", sentence: violationText(toolName, v), ...(details !== undefined ? { details } : {}) };
45
- const allowed = fitMiddle([opts.rootCanonical, ...extra].join(", "), READ_DENY_SENTENCE_PART_MAX);
46
- return { disposition: "refuse", finding: "outside_roots", sentence: `Error (${toolName}): "${fitMiddle(v.target, READ_DENY_SENTENCE_PART_MAX)}" is outside the directories this task may read (${allowed}). ${READ_BLOCK_REMEDY}`, ...(details !== undefined ? { details } : {}) };
47
- }
48
- if (r.ok || r.violation.code !== "path_not_in_root" || r.violation.target === undefined || opts.excluded?.(r.violation.target) === true || opts.exempt?.(r.violation.target) === true)
49
- return VOUCH;
50
- const target = r.violation.target;
51
- const toolCallId = callOpts.toolCallId;
52
- const roots = [opts.rootCanonical, ...extra];
53
- const details = violationDetails(r.violation);
54
- const allowed = fitMiddle(roots.join(", "), READ_DENY_SENTENCE_PART_MAX);
55
- const disposition = decideShellRead("outside_roots", callOpts.seat === "rejudge" ? "rejudge" : "file_tool");
56
- if (disposition === "refuse") {
57
- const sentence = callOpts.seat === "rejudge"
58
- ? `Error (${toolName}): the approved edit reads "${fitMiddle(target, READ_DENY_SENTENCE_PART_MAX)}", outside the directories allowed for this session (${allowed}) — re-submit it as a fresh call and answer its card.`
59
- : `Error (${toolName}): "${fitMiddle(target, READ_DENY_SENTENCE_PART_MAX)}" is outside the directories allowed for this session (${allowed}).`;
60
- return { disposition, finding: "outside_roots", sentence, details };
61
- }
62
- const info = pathTargetOf(member)?.absent === "base" ? await opts.env.fileInfo(target, signal) : undefined;
63
- const readsDirectory = info?.ok === true && info.value.kind === "directory";
64
- const offer = grantOfferFor(readsDirectory ? target : parentDirLexically(target), target, { roots, ...(opts.homeDir !== undefined ? { homeDir: opts.homeDir } : {}) });
65
- return {
66
- disposition,
67
- finding: "outside_roots",
68
- sentence: `reads outside the allowed directories for this session: "${fitMiddle(target, READ_DENY_SENTENCE_PART_MAX)}" is not under ${allowed}`,
69
- details,
70
- ...(offer !== undefined ? { readRootCandidate: { dir: offer.dir, ...(offer.covers !== undefined ? { covers: offer.covers } : {}), clearsThisAsk: true } } : {}),
71
- ...(toolCallId !== undefined ? { admit: () => remember(toolCallId, target) } : {}),
72
- };
73
- })();
171
+ const toolCallId = callOpts.toolCallId;
172
+ return judgeTargets({
173
+ toolName: call.toolName,
174
+ targets: [{ spelled: selection.spelled, base: selection.base }],
175
+ toolCallId,
176
+ seat: callOpts.seat,
177
+ declared: false,
178
+ mayBeDirectory: pathTargetOf(member)?.absent === "base",
179
+ admit: (outside) => {
180
+ if (toolCallId !== undefined && outside[0] !== undefined)
181
+ setBounded(admissions, toolCallId, outside[0]);
182
+ },
183
+ }, signal).then(({ verdict }) => verdict);
184
+ },
185
+ unanswered: (call, cause) => {
186
+ const id = call.toolCallId;
187
+ const named = id !== undefined ? pendingDeclared.get(id)?.targets : undefined;
188
+ if (id !== undefined) {
189
+ pendingDeclared.delete(id);
190
+ declaredCalls.delete(id);
191
+ }
192
+ const remedy = named !== undefined && named > 1 ? `This call names ${named} paths: split them into several calls, each naming fewer.` : "Try the call again.";
193
+ if (declaredReadOf(call) !== undefined)
194
+ return { disposition: "refuse", finding: "unanswered", environmentSilent: true, sentence: `Error (${call.toolName}): where this call reads could not be established (${cause}), and nothing after the read station judges what this tool reads, so the call was not run. ${remedy}`, details: unestablishedCard() };
195
+ return opts.outsideReads === "refusal"
196
+ ? { disposition: "refuse", finding: "unanswered", environmentSilent: true, sentence: `Error (${call.toolName}): where this call reads could not be established (${cause}), and this task refuses reads it cannot place inside its directories (blockReadsOutsideRoots). Try the call again.` }
197
+ : VOUCH;
74
198
  },
75
- unanswered: (call, cause) => opts.outsideReads === "refusal"
76
- ? { disposition: "refuse", finding: "unanswered", environmentSilent: true, sentence: `Error (${call.toolName}): where this call reads could not be established (${cause}), and this task refuses reads it cannot place inside its directories (blockReadsOutsideRoots). Try the call again.` }
77
- : VOUCH,
78
199
  };
79
200
  const admitted = (toolCallId, key) => {
80
201
  if (toolCallId === undefined || admissions.get(toolCallId) !== key)
@@ -82,7 +203,14 @@ export function createFileReadStation(opts) {
82
203
  admissions.delete(toolCallId);
83
204
  return true;
84
205
  };
85
- return { check, tools: opts.tools, admitted };
206
+ const judgedReadsOf = (toolCallId) => {
207
+ const judged = declaredCalls.get(toolCallId);
208
+ return judged === undefined ? undefined : portOf(tables, toolCallId, judged);
209
+ };
210
+ return { check, tools: opts.tools, admitted, judgedReadsOf, declares: (call) => declaredReadOf(call) !== undefined };
211
+ }
212
+ export function readStationsHold(stations, call) {
213
+ return stations.some((s) => readStationMemberOf(call, s.tools) !== undefined || s.declares?.(call) === true);
86
214
  }
87
215
  export function composeReadChecks(stations) {
88
216
  if (stations.length === 0)
@@ -94,9 +222,24 @@ export function composeReadChecks(stations) {
94
222
  for (const n of s.tools)
95
223
  if (!byName.has(n))
96
224
  byName.set(n, s);
97
- const stationOf = (call) => readStationMemberOf(call, byName)?.value;
225
+ const stationOf = (call) => stations.find((s) => s.declares?.(call) === true) ?? readStationMemberOf(call, byName)?.value;
98
226
  return {
99
227
  judge: (call, args, cwd, signal, callOpts) => stationOf(call)?.check.judge(call, args, cwd, signal, callOpts) ?? null,
100
228
  unanswered: (call, cause) => (stationOf(call) ?? stations[0]).check.unanswered(call, cause),
101
229
  };
102
230
  }
231
+ export function unjudgedReadsMember(ported) {
232
+ const declares = (call) => declaredReadOf(call) !== undefined && !ported(call.toolName);
233
+ const refusal = (call) => ({
234
+ disposition: "refuse",
235
+ finding: "unanswered",
236
+ environmentSilent: true,
237
+ sentence: `Error (${call.toolName}): this leg has no execution environment, so nothing can judge the paths this tool declares it reads, and the tool opens them itself; the call was not run. Give the Runner an execution environment (executionEnv or executionEnvFactory), or drop the tool's read declaration (its pathTarget).`,
238
+ details: unestablishedCard(),
239
+ });
240
+ return {
241
+ tools: new Set(),
242
+ declares,
243
+ check: { judge: (call) => (declares(call) ? Promise.resolve(refusal(call)) : null), unanswered: (call) => (declares(call) ? refusal(call) : VOUCH) },
244
+ };
245
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * The judged-read PORT of a caller tool's declared read ({@link import("../../core/tool-spec.js").ToolExecuteContext.judgedReads}):
3
+ * the one way such a tool reads a target the model named. Each entry is a target the file read station judged for the call; `open`
4
+ * is that judgment again, on the key the station judged, then the environment's bound open, then the judgment once more — and only
5
+ * the held object leaves. An environment that cannot hold the object is a refusal: the target is never read by name instead.
6
+ */
7
+ import type { ExecutionEnv } from "../../internal/harness-types.js";
8
+ import type { JudgedRead, JudgedReadsUnavailable } from "../../core/judged-read.js";
9
+ import type { ToolExecuteContext } from "../../core/tool-spec.js";
10
+ /** The closed set of {@link JudgedReadsUnavailable}, as a list (every word once). */
11
+ export declare const JUDGED_READS_UNAVAILABLE: readonly JudgedReadsUnavailable[];
12
+ /** The port seat of one leg: the station's ports per call, or none when the leg mounts no file read station; and the wire names of
13
+ * the tools the leg mounted with the port (`ported`, written where they are mounted). */
14
+ export type JudgedReadsSeat = {
15
+ current?: ((toolCallId: string) => readonly JudgedRead[] | undefined) | null;
16
+ ported?: Set<string>;
17
+ };
18
+ /**
19
+ * `ctx` with the port of a tool that declares a read target: a fresh object with `ctx`'s own property descriptors (its getters stay
20
+ * getters) and `judgedReads`, read when the tool reads it — the station's judgment of this call, or why there is none.
21
+ */
22
+ export declare function withJudgedReads(ctx: ToolExecuteContext, seat: JudgedReadsSeat): ToolExecuteContext;
23
+ import type { ContainmentFace } from "./containment-face.js";
24
+ import { type ReadDenyMatcher } from "./read-deny.js";
25
+ /** One element of a call's declared read as the station recorded it: its spelling, the base it resolves against, and the
26
+ * canonical key the judgment landed on. */
27
+ export interface JudgedElement {
28
+ readonly spelled: string;
29
+ readonly base: string | undefined;
30
+ readonly key: string;
31
+ }
32
+ /** What the station holds for one judged call: the call's name (the refusals say it), its elements in slot order, and the targets
33
+ * outside the roots whose question the gate applied (an open may read them; nothing else outside the roots). */
34
+ export interface JudgedCall {
35
+ readonly toolName: string;
36
+ readonly elements: readonly JudgedElement[];
37
+ readonly admitted: Set<string>;
38
+ }
39
+ /** The judgment the port asks again: the station's own tables, read for the call. */
40
+ export interface JudgedReadTables {
41
+ readonly env: ExecutionEnv;
42
+ readonly rootCanonical: string;
43
+ readonly roots: () => readonly string[];
44
+ readonly readDeny?: ReadDenyMatcher;
45
+ readonly readFace?: ContainmentFace;
46
+ readonly excluded?: (canonicalKey: string) => boolean;
47
+ readonly exempt?: (canonicalKey: string) => boolean;
48
+ readonly outsideRemedy?: string;
49
+ }
50
+ /** The port's entries for one judged call (`toolCallId`), in slot order. Never throws: every refusal is a result. */
51
+ export declare function judgedReadsOf(tables: JudgedReadTables, toolCallId: string, call: JudgedCall): readonly JudgedRead[];
@@ -0,0 +1,68 @@
1
+ import { FileError, err, ok } from "../../internal/harness.js";
2
+ import { thrownText } from "../../core/thrown-value.js";
3
+ export const JUDGED_READS_UNAVAILABLE = Object.freeze(["no_read_station", "not_judged"]);
4
+ export function withJudgedReads(ctx, seat) {
5
+ const read = () => {
6
+ const ports = seat.current;
7
+ if (ports === undefined || ports === null)
8
+ return Object.freeze({ kind: "unavailable", reason: "no_read_station" });
9
+ const targets = ports(ctx.toolCallId);
10
+ return targets === undefined ? Object.freeze({ kind: "unavailable", reason: "not_judged" }) : Object.freeze({ kind: "judged", targets });
11
+ };
12
+ return Object.create(Object.getPrototypeOf(ctx), { ...Object.getOwnPropertyDescriptors(ctx), judgedReads: { get: read, enumerable: true, configurable: true } });
13
+ }
14
+ import { openBoundAt } from "./bound-open.js";
15
+ import { createEntryDenyJudge, enumerateDirectory } from "./dir-entries.js";
16
+ import { seatForCall } from "./read-deny.js";
17
+ import { resolveKey, violationText } from "./safety.js";
18
+ export function judgedReadsOf(tables, toolCallId, call) {
19
+ return Object.freeze(call.elements.map((el) => Object.freeze({ spelled: el.spelled, key: el.key, open: (signal) => openJudged(tables, toolCallId, call, el, signal) })));
20
+ }
21
+ async function openJudged(tables, toolCallId, call, el, signal) {
22
+ try {
23
+ const { env } = tables;
24
+ const deny = seatForCall(tables.readDeny, toolCallId);
25
+ const target = el.key;
26
+ const judge = (s) => resolveKey(env, tables.rootCanonical, target, s, el.base, seatForCall(tables.roots, toolCallId)(), (k) => call.admitted.has(k) || tables.exempt?.(k) === true, deny, tables.readFace, tables.outsideRemedy);
27
+ const first = await judge(signal);
28
+ if (!first.ok)
29
+ return err(new FileError("permission_denied", violationText(call.toolName, first.violation), first.violation.target ?? target));
30
+ if (first.key !== el.key)
31
+ return err(new FileError("precondition_failed", `Error (${call.toolName}): "${el.spelled}" no longer lands on the file that was judged; it was not read`, el.key));
32
+ if (tables.excluded?.(first.key) === true)
33
+ return err(new FileError("permission_denied", `Error (${call.toolName}): "${el.spelled}" is in the engine's artifact store, which no tool reads`, first.key));
34
+ const opening = await openBoundAt(env, first.key, signal);
35
+ if (opening.kind === "unbindable")
36
+ return err(new FileError("not_supported", `Error (${call.toolName}): this environment cannot hold the file it judged ("${el.spelled}"), so it is not read`, first.key));
37
+ if (opening.kind === "refused")
38
+ return err(opening.error);
39
+ const object = opening.object;
40
+ const again = await judge(signal);
41
+ if (!again.ok || again.key !== first.key) {
42
+ await object.close();
43
+ return err(again.ok ? new FileError("precondition_failed", `Error (${call.toolName}): "${el.spelled}" moved while it was opened; it was not read`, first.key) : new FileError("permission_denied", violationText(call.toolName, again.violation), first.key));
44
+ }
45
+ return ok(heldFile(env, first.key, object, deny));
46
+ }
47
+ catch (thrown) {
48
+ return err(new FileError("unknown", `Error (${call.toolName}): "${el.spelled}" could not be judged: ${thrownText(thrown)}`, el.key));
49
+ }
50
+ }
51
+ function heldFile(env, key, object, deny) {
52
+ return Object.freeze({
53
+ key,
54
+ identity: object.identity,
55
+ kind: object.kind,
56
+ size: () => object.size(),
57
+ readBytes: async (max, signal) => (object.kind === "file" ? object.readBytes(max, signal) : { ok: false, error: new FileError("is_directory", "The object is a directory", key) }),
58
+ list: async (signal) => {
59
+ if (object.kind !== "directory")
60
+ return { ok: false, error: new FileError("not_directory", "The object is a file", key) };
61
+ const listing = await enumerateDirectory(env, key, deny !== undefined ? createEntryDenyJudge(env, deny, signal) : undefined, signal, () => object.list(signal));
62
+ if (!listing.ok)
63
+ return listing;
64
+ return { ok: true, value: { entries: listing.value.entries.map((e) => ({ name: e.name, kind: e.kind })), omitted: listing.value.omitted, more: listing.value.more } };
65
+ },
66
+ close: () => object.close(),
67
+ });
68
+ }
@@ -21,6 +21,12 @@ export { familyFor, foldRedundantPathSegments, isAbsoluteForFamily, isWinFormPat
21
21
  * normalization is identity for it.
22
22
  */
23
23
  export declare function writeTargetPath(call: ToolCallLike, pt?: ReturnType<typeof protectivePathTargetOf>): string | undefined;
24
+ /**
25
+ * EVERY target a call names — the reader for a fence that may meet a declared read, in the read station's one reading
26
+ * ({@link declaredReadValuesOf}): a declared read slot is every non-empty string its one reading carries (never falling back
27
+ * to {@link writeTargetPath}); any other call is the one target {@link writeTargetPath} reads. `[]` ⇔ no resolvable path.
28
+ */
29
+ export declare function targetPathsOf(call: ToolCallLike, pt?: ReturnType<typeof protectivePathTargetOf>): readonly string[];
24
30
  /**
25
31
  * The "hand" file tools' safety invariants, ported from CC's `FileEditTool`: without these a weak
26
32
  * model blind-edits / overwrites files (a safety property, not polish). This module is the
@@ -126,6 +132,7 @@ export declare function isProcSensitiveFile(key: string): boolean;
126
132
  export declare function holdsProcSensitiveFile(dir: string): boolean;
127
133
  export declare function ownProcessSpelling(spelled: string): string | undefined;
128
134
  export declare function belowOwnProcessLink(spelled: string, walks?: boolean): boolean;
135
+ export declare function isBareOwnDescriptorLink(spelled: string): boolean;
129
136
  /**
130
137
  * Expand a LEADING `~` (bare, or followed by a separator of either family) against `home`; every other
131
138
  * spelling is returned untouched — a `~` anywhere but the front is an ordinary filename character.
@@ -494,6 +501,7 @@ export declare function violationDetails(v: FsViolation): {
494
501
  code: "path_not_in_root";
495
502
  target: string;
496
503
  roots: readonly string[];
504
+ targets?: readonly string[];
497
505
  } | ReadPathDeniedCard | undefined;
498
506
  /** The read face's refusal card: which target, which deny pattern. */
499
507
  export type ReadPathDeniedCard = {
@@ -4,7 +4,7 @@ import { envErrorDetail } from "./env-error-detail.js";
4
4
  import { homeViewsOf, homeViewUnreadSentence } from "./read-deny-home.js";
5
5
  import { skipsRootsContainment } from "./containment-face.js";
6
6
  import { sliceHeadSafe } from "../../core/surrogate-safe-slice.js";
7
- import { fileArgPath, pathTargetValue, protectivePathTargetOf } from "../../core/tool-registry.js";
7
+ import { declaredReadValuesOf, fileArgPath, pathTargetValue, protectivePathTargetOf } from "../../core/tool-registry.js";
8
8
  import { readPath } from "../../core/effective-path-target.js";
9
9
  import { familyFor, foldRedundantPathSegments, isAbsoluteForFamily, isUncSpelling, isWinFormPath, nativeSepOf, normalizeAbsPathLexically, pathFamilyOf, rejoinMissingTail, stripWin32ExtendedPrefix, win32NamespacePrefixFolded, WIN_RESERVED_RE, } from "../../core/unc-spelling.js";
10
10
  export { familyFor, foldRedundantPathSegments, isAbsoluteForFamily, isWinFormPath, normalizeAbsPathLexically, pathFamilyOf };
@@ -17,6 +17,13 @@ export function writeTargetPath(call, pt = protectivePathTargetOf(call)) {
17
17
  const notebook = typeof np === "string" && np.length > 0 ? np : undefined;
18
18
  return fileArgPath(call.args) ?? notebook;
19
19
  }
20
+ export function targetPathsOf(call, pt = protectivePathTargetOf(call)) {
21
+ const declared = declaredReadValuesOf(call);
22
+ if (declared !== undefined)
23
+ return declared.values.filter((e) => typeof e === "string" && e.length > 0);
24
+ const one = writeTargetPath(call, pt);
25
+ return typeof one === "string" && one.length > 0 ? [one] : [];
26
+ }
20
27
  export const FRAME_TRANSMISSION_PREFIX = "attachment:";
21
28
  export function sha256(content) {
22
29
  return createHash("sha256").update(content, "utf8").digest("hex");
@@ -74,6 +81,10 @@ export function belowOwnProcessLink(spelled, walks = false) {
74
81
  const link = OWN_PROCESS_LINK.exec(p);
75
82
  return link !== null && (walks || /^\/[^/]/.test(p.slice(link[0].length)));
76
83
  }
84
+ const BARE_OWN_DESCRIPTOR_LINK = /^\/(?:proc\/(?:self|thread-self)\/(?:task\/[^/]+\/)?fd\/\d+|dev\/fd\/\d+)\/?$/;
85
+ export function isBareOwnDescriptorLink(spelled) {
86
+ return BARE_OWN_DESCRIPTOR_LINK.test(behindOwnRootLinks(spelled).p);
87
+ }
77
88
  export function expandHomeTilde(p, home) {
78
89
  if (p === "~")
79
90
  return home;
@@ -36,14 +36,20 @@ declare function containmentDetails(paths: readonly string[]): {
36
36
  };
37
37
  /** The ONE mint of the card of a finding that established nothing: where the command reads could not be established
38
38
  * (an unreadable or re-entered program text, a program named from its input, a station that could not answer). */
39
- declare function unestablishedDetails(): {
39
+ export declare function unestablishedDetails(): {
40
40
  readonly type: "read_unestablished";
41
41
  readonly code: "read_unestablished";
42
42
  };
43
+ /** The card of a declared read refused for the SHAPE of what it names (the file read station): more targets than one call may name,
44
+ * or a value in its slot that is not a path. The word is the reason (`code`, which `tool_end.errorCode` lifts). */
45
+ export declare function readTargetsRefusedDetails(code: "read_targets_over_limit" | "read_target_not_a_path"): {
46
+ readonly type: "read_targets_refused";
47
+ readonly code: "read_targets_over_limit" | "read_target_not_a_path";
48
+ };
43
49
  /** The structured details a refusal or a mandated card carries: the deny card is the read faces' own (`violationDetails`,
44
50
  * safety.ts), the containment and the unestablished cards are minted above, and a call the target refused before it started
45
51
  * carries the shell's own card for that word ({@link targetUnavailableCard}). */
46
- export type ShellReadRefusalDetails = NonNullable<ReturnType<typeof violationDetails>> | ReturnType<typeof containmentDetails> | ReturnType<typeof unestablishedDetails> | TargetUnavailableCard;
52
+ export type ShellReadRefusalDetails = NonNullable<ReturnType<typeof violationDetails>> | ReturnType<typeof containmentDetails> | ReturnType<typeof unestablishedDetails> | ReturnType<typeof readTargetsRefusedDetails> | TargetUnavailableCard;
47
53
  /**
48
54
  * What the station answers for ONE call: a VOUCH — the finding `none`, nothing beside it but the facts — or a QUESTION, a
49
55
  * disposition the decision table gives its finding ({@link import("./shell-read-judge.js").dispositionsOfRow}). A vouch carries no
@@ -64,6 +70,7 @@ export interface ShellReadVouch extends ShellReadVerdictFacts {
64
70
  readonly details?: never;
65
71
  readonly echoed?: never;
66
72
  readonly readRootCandidate?: never;
73
+ readonly cause?: never;
67
74
  readonly unestablished?: never;
68
75
  }
69
76
  /** The station refuses the call or puts a question about it. */
@@ -95,6 +102,9 @@ export interface ShellReadQuestion extends ShellReadVerdictFacts {
95
102
  readonly echoed?: readonly RefusalEcho[];
96
103
  /** `mandated` on an `outside_roots` finding: the directory whose grant would clear this ask. */
97
104
  readonly readRootCandidate?: ReadRootGrantCandidate;
105
+ /** A question's structured account for the card a person answers (`AskRequest.probeCause`, the park row's twin): the file read
106
+ * station names every target a yes admits (`roots`), as many as the call names. */
107
+ readonly cause?: import("../../core/checkpoint-store.js").ProbeCause;
98
108
  /** A FACT beside the disposition: some read of the command could not be established (an `unestablishable` or `declined`
99
109
  * finding anywhere in it, whichever finding won). A mode that releases the call releases it past the read-deny table. */
100
110
  readonly unestablished?: true;
@@ -167,7 +177,10 @@ export interface ShellReadCheck {
167
177
  readonly toolCallId?: string;
168
178
  readonly seat?: "rejudge";
169
179
  }): Promise<ShellReadVerdict> | null;
170
- unanswered(call: ReadStationCall, cause: string): ShellReadVerdict;
180
+ /** `call.toolCallId`: the call the gate gave up on (a station that hands a call something on its judgment withdraws it). */
181
+ unanswered(call: ReadStationCall & {
182
+ readonly toolCallId?: string;
183
+ }, cause: string): ShellReadVerdict;
171
184
  }
172
185
  /** The call a read station judges: its wire name and the face the gate stamped (whose `names` the station reads). */
173
186
  export type ReadStationCall = Pick<ToolCallLike, "toolName" | "face">;
@@ -23,9 +23,12 @@ import { assertNoRetiredShellReadBoundaryKeys } from "../../core/retired-keys.js
23
23
  function containmentDetails(paths) {
24
24
  return { type: "readonly_out_of_root", code: "readonly_out_of_root", paths };
25
25
  }
26
- function unestablishedDetails() {
26
+ export function unestablishedDetails() {
27
27
  return { type: "read_unestablished", code: "read_unestablished" };
28
28
  }
29
+ export function readTargetsRefusedDetails(code) {
30
+ return { type: "read_targets_refused", code };
31
+ }
29
32
  function findingDetails(finding, paths) {
30
33
  return finding === "unestablishable" || finding === "declined" || finding === "unanswered" ? unestablishedDetails() : containmentDetails(paths);
31
34
  }
@@ -1,5 +1,5 @@
1
1
  import { canonicalRootsOnce, isAbsence, observeEnvironment } from "./shell-read-environment.js";
2
- import { anchorSpelling, belowOwnProcessLink, isAbsoluteForFamily, normalizeAbsPathLexically, ownProcessSpelling, pathFamilyOf, withinAnyRoot } from "./safety.js";
2
+ import { anchorSpelling, belowOwnProcessLink, isAbsoluteForFamily, isBareOwnDescriptorLink, normalizeAbsPathLexically, ownProcessSpelling, pathFamilyOf, withinAnyRoot } from "./safety.js";
3
3
  import { landingsOf, noteClimb, readingsAt, withClimbedPatterns, withClimbedViews, withFloorClimbs } from "./shell-climb.js";
4
4
  import { boundaryIsTheSandbox } from "../../core/remote-env.js";
5
5
  import { resolveOperandSpellings, tildeNamesAnAccount } from "./bash-readonly-classifier.js";
@@ -451,12 +451,22 @@ function establishLegOver(seen, readRoots) {
451
451
  return undefined;
452
452
  return { value: joinUnder(parent.value, leaf), exact: parent.exact, ...(parent.missing !== undefined ? { missing: parent.missing } : {}) };
453
453
  };
454
+ const takenAsSpelled = (candidate, spelling, spellings, origin) => ({
455
+ candidate,
456
+ established: "lexical",
457
+ target: normalizeAbsPathLexically(spelling),
458
+ spellings,
459
+ ...(origin !== undefined ? { origin } : {}),
460
+ });
454
461
  const canonicalReadOf = async (candidate, spelling, spellings, established, origin, canonicalKnown, signal, seat = "landing", climbs) => {
455
- const real = canonicalKnown !== undefined ? { value: canonicalKnown, exact: true } : candidate.provenance === "traversal_root" && belowOwnProcessLink(spelling, true) ? { value: spelling, exact: false } : seat === "entry" ? await entryOf(spelling, signal, climbs) : await resolve(spelling, signal, candidate.face === "write", WRITE_LINK_HOPS, climbs);
462
+ const unplacedOwnLink = belowOwnProcessLink(spelling, candidate.provenance === "traversal_root");
463
+ if (isBareOwnDescriptorLink(spelling) && !unplacedOwnLink)
464
+ return takenAsSpelled(candidate, spelling, spellings, origin);
465
+ const real = canonicalKnown !== undefined ? { value: canonicalKnown, exact: true } : unplacedOwnLink ? { value: spelling, exact: false } : seat === "entry" ? await entryOf(spelling, signal, climbs) : await resolve(spelling, signal, candidate.face === "write", WRITE_LINK_HOPS, climbs);
456
466
  if (real === undefined) {
457
467
  if (resolverIsAuthoritative)
458
468
  return { candidate, established: "unestablishable", spellings, ...(origin !== undefined ? { origin } : {}), cause: `"${spelling}" cannot be resolved to verify where it reads`, unresolved: true };
459
- return { candidate, established: "lexical", target: normalizeAbsPathLexically(spelling), spellings, ...(origin !== undefined ? { origin } : {}) };
469
+ return takenAsSpelled(candidate, spelling, spellings, origin);
460
470
  }
461
471
  if (!real.exact && real.missing !== true) {
462
472
  return { candidate, established: "unestablishable", spellings, ...(origin !== undefined ? { origin } : {}), cause: `"${spelling}" cannot be resolved to verify where it reads`, unresolved: true };