@sema-agent/core 7.52.0 → 7.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +194 -0
- package/README.md +3 -1
- package/dist/agents/cross-session-envelope.d.ts +8 -0
- package/dist/agents/cross-session-envelope.js +6 -0
- package/dist/agents/cross-session-judge.d.ts +21 -1
- package/dist/agents/cross-session-judge.js +8 -0
- package/dist/agents/cross-session-ref.d.ts +5 -0
- package/dist/agents/cross-session-ref.js +1 -0
- package/dist/agents/org-delivery-gate.d.ts +122 -0
- package/dist/agents/org-delivery-gate.js +69 -0
- package/dist/agents/peer-held-queue.d.ts +9 -4
- package/dist/agents/peer-held-queue.js +6 -5
- package/dist/agents/peer-session-drain.d.ts +35 -5
- package/dist/agents/peer-session-drain.js +271 -180
- package/dist/agents/read-inbox-tool.d.ts +7 -0
- package/dist/agents/read-inbox-tool.js +5 -1
- package/dist/agents/subagent.d.ts +3 -0
- package/dist/agents/subagent.js +99 -72
- package/dist/agents/tool-filter.d.ts +18 -0
- package/dist/agents/tool-filter.js +6 -0
- package/dist/brain/anthropic.d.ts +6 -1
- package/dist/brain/anthropic.js +4 -4
- package/dist/brain/model-presets.js +2 -1
- package/dist/brain/route-adjudicator.d.ts +6 -0
- package/dist/brain/routing.d.ts +24 -1
- package/dist/brain/routing.js +54 -19
- package/dist/brain/timeout.js +5 -4
- package/dist/core/a2a.d.ts +5 -2
- package/dist/core/a2a.js +30 -13
- package/dist/core/allow-entry.d.ts +2 -1
- package/dist/core/allow-entry.js +2 -2
- package/dist/core/auto-compaction.d.ts +57 -0
- package/dist/core/auto-compaction.js +28 -2
- package/dist/core/checkpoint-store.d.ts +29 -20
- package/dist/core/checkpoint-store.js +3 -3
- package/dist/core/compliance.js +3 -1
- package/dist/core/effective-path-target.d.ts +25 -6
- package/dist/core/effective-path-target.js +24 -2
- package/dist/core/engine-notice.d.ts +13 -2
- package/dist/core/gate-fold.js +3 -2
- package/dist/core/gate-lanes.js +11 -13
- package/dist/core/gate-outcome.d.ts +11 -6
- package/dist/core/governance-codes.d.ts +3 -1
- package/dist/core/governance-codes.js +3 -0
- package/dist/core/hands-band-screen.d.ts +7 -0
- package/dist/core/hands-band-screen.js +32 -0
- package/dist/core/hooks.d.ts +7 -5
- package/dist/core/hooks.js +5 -3
- package/dist/core/locked-config.d.ts +84 -32
- package/dist/core/locked-config.js +128 -42
- package/dist/core/mcp-probe.js +1 -1
- package/dist/core/mcp-server-spec.d.ts +88 -10
- package/dist/core/mcp-server-spec.js +183 -33
- package/dist/core/mcp.d.ts +21 -14
- package/dist/core/mcp.js +55 -51
- package/dist/core/memory-engine/engine.d.ts +14 -19
- package/dist/core/memory-engine/engine.js +7 -5
- package/dist/core/mode-policy.d.ts +3 -18
- package/dist/core/mode-policy.js +2 -16
- package/dist/core/mods/kernel/dispatch.js +13 -15
- package/dist/core/mods/kernel/events.d.ts +9 -6
- package/dist/core/mods/kernel/events.js +2 -2
- package/dist/core/mods/kernel/receive.d.ts +39 -10
- package/dist/core/mods/kernel/receive.js +119 -54
- package/dist/core/mods/kernel/site-rules.d.ts +80 -15
- package/dist/core/mods/kernel/site-rules.js +232 -40
- package/dist/core/mods/stations.d.ts +0 -6
- package/dist/core/mods/stations.js +0 -7
- package/dist/core/mounted-mcp.d.ts +57 -0
- package/dist/core/mounted-mcp.js +71 -2
- package/dist/core/own-property-receipt.d.ts +13 -0
- package/dist/core/own-property-receipt.js +3 -1
- package/dist/core/parent-spec-seat.d.ts +2 -2
- package/dist/core/permission-rule-model.d.ts +58 -9
- package/dist/core/permission-rule-model.js +81 -7
- package/dist/core/permission-rule-org.d.ts +163 -33
- package/dist/core/permission-rule-org.js +205 -71
- package/dist/core/permission-rules.d.ts +7 -1
- package/dist/core/permission-rules.js +37 -8
- package/dist/core/retention.js +7 -2
- package/dist/core/retired-keys.d.ts +8 -2
- package/dist/core/retired-keys.js +12 -1
- package/dist/core/roles.js +60 -10
- package/dist/core/rule-lane-reads.js +1 -1
- package/dist/core/runner/contracts.d.ts +1 -0
- package/dist/core/runner/gate-exit.js +4 -3
- package/dist/core/runner/mcp-redial.d.ts +52 -10
- package/dist/core/runner/mcp-redial.js +38 -9
- package/dist/core/runner/permission-rule-lanes.d.ts +5 -2
- package/dist/core/runner/permission-rule-lanes.js +22 -10
- package/dist/core/runner/person-path-rows.d.ts +3 -1
- package/dist/core/runner/person-path-rows.js +2 -2
- package/dist/core/runner/prepare-config-doors.d.ts +48 -2
- package/dist/core/runner/prepare-config-doors.js +161 -145
- package/dist/core/runner/prepare-defer-classify.js +4 -7
- package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
- package/dist/core/runner/prepare-delegation-surface.js +7 -5
- package/dist/core/runner/prepare-hands-readface.d.ts +1 -1
- package/dist/core/runner/prepare-hands-readface.js +2 -1
- package/dist/core/runner/prepare-inherited-gate.js +2 -2
- package/dist/core/runner/prepare-listings.d.ts +1 -1
- package/dist/core/runner/prepare-listings.js +4 -2
- package/dist/core/runner/prepare-memory-engine-session.d.ts +0 -6
- package/dist/core/runner/prepare-memory-engine-session.js +19 -6
- package/dist/core/runner/prepare-memory.d.ts +3 -2
- package/dist/core/runner/prepare-memory.js +6 -2
- package/dist/core/runner/prepare-offload-wrappers.d.ts +4 -4
- package/dist/core/runner/prepare-offload-wrappers.js +2 -1
- package/dist/core/runner/prepare-policy-chain.d.ts +1 -1
- package/dist/core/runner/prepare-policy-chain.js +12 -12
- package/dist/core/runner/prepare-project-context.d.ts +1 -1
- package/dist/core/runner/prepare-project-context.js +6 -4
- package/dist/core/runner/prepare-prompt-assembly.d.ts +1 -1
- package/dist/core/runner/prepare-prompt-assembly.js +20 -16
- package/dist/core/runner/prepare-prompt-inputs.d.ts +12 -6
- package/dist/core/runner/prepare-prompt-inputs.js +6 -3
- package/dist/core/runner/prepare-protocol-tools.d.ts +7 -5
- package/dist/core/runner/prepare-protocol-tools.js +19 -12
- package/dist/core/runner/prepare-question-face.d.ts +4 -2
- package/dist/core/runner/prepare-question-face.js +4 -3
- package/dist/core/runner/prepare-task.js +10 -10
- package/dist/core/runner/prepare-wiring-manifest.d.ts +8 -3
- package/dist/core/runner/prepare-wiring-manifest.js +8 -5
- package/dist/core/runner/resume-admission.d.ts +4 -1
- package/dist/core/runner/resume-admission.js +7 -5
- package/dist/core/runner/resume-internals-and-config.d.ts +3 -3
- package/dist/core/runner/resume-internals-and-config.js +3 -8
- package/dist/core/runner/retired-runner-deps.d.ts +5 -6
- package/dist/core/runner/retired-runner-deps.js +1 -4
- package/dist/core/runner/run-leg.js +42 -12
- package/dist/core/runner/run-recovery-lanes.js +5 -3
- package/dist/core/runner/run-terminal-adoption.js +6 -5
- package/dist/core/runner/run-turn-boundary.js +9 -3
- package/dist/core/runner/runtask.js +1 -1
- package/dist/core/runner/skills-seat.d.ts +15 -0
- package/dist/core/runner/skills-seat.js +57 -0
- package/dist/core/runner/sub-agent-deny-lists.d.ts +13 -11
- package/dist/core/runner/sub-agent-deny-lists.js +7 -5
- package/dist/core/runner/synthetic-tools.d.ts +5 -2
- package/dist/core/runner/synthetic-tools.js +2 -12
- package/dist/core/runner-deps.d.ts +29 -14
- package/dist/core/session-policy-store.d.ts +19 -0
- package/dist/core/session-policy-store.js +22 -2
- package/dist/core/store-contracts/mailbox-store-contract.js +13 -0
- package/dist/core/task-event.d.ts +38 -2
- package/dist/core/task-notification.js +2 -2
- package/dist/core/task-spec.d.ts +1 -1
- package/dist/core/tool-policy.d.ts +3 -0
- package/dist/core/tool-policy.js +10 -4
- package/dist/core/types.d.ts +2 -2
- package/dist/core/types.js +1 -1
- package/dist/core/untrusted-text.d.ts +16 -0
- package/dist/core/untrusted-text.js +7 -2
- package/dist/core/user-attachment.d.ts +13 -2
- package/dist/core/user-attachment.js +47 -41
- package/dist/core/wiring-manifest.d.ts +4 -2
- package/dist/engine/harness/agent-harness.js +2 -1
- package/dist/engine/harness/types.d.ts +3 -0
- package/dist/engine/loop/agent-loop.d.ts +12 -1
- package/dist/engine/loop/agent-loop.js +17 -5
- package/dist/engine/loop/types.d.ts +7 -1
- package/dist/index.d.ts +15 -9
- package/dist/index.js +12 -6
- package/dist/internal/harness.d.ts +1 -0
- package/dist/internal/harness.js +1 -0
- package/dist/orchestration/goal.d.ts +24 -1
- package/dist/orchestration/goal.js +3 -2
- package/dist/prompt-assembly/artifact-store.d.ts +44 -9
- package/dist/prompt-assembly/artifact-store.js +38 -12
- package/dist/prompt-assembly/artifact.d.ts +12 -11
- package/dist/prompt-assembly/artifact.js +52 -21
- package/dist/prompt-assembly/assemble.d.ts +2 -0
- package/dist/prompt-assembly/assemble.js +2 -1
- package/dist/prompt-assembly/catalog/index.js +2 -1
- package/dist/prompt-assembly/catalog/memory.d.ts +13 -0
- package/dist/prompt-assembly/catalog/memory.js +6 -0
- package/dist/prompt-assembly/catalog/schema.d.ts +16 -2
- package/dist/prompt-assembly/composer.d.ts +2 -0
- package/dist/prompt-assembly/composer.js +1 -1
- package/dist/prompt-assembly/overlay.d.ts +21 -11
- package/dist/prompt-assembly/overlay.js +55 -17
- package/dist/prompt-assembly/select.d.ts +21 -6
- package/dist/prompt-assembly/select.js +39 -2
- package/dist/prompts/default.d.ts +0 -11
- package/dist/prompts/default.js +0 -3
- package/dist/stores/file/permission-rule-store.d.ts +1 -1
- package/dist/stores/file/permission-rule-store.js +2 -1
- package/dist/tools/artifact/artifact-tool.js +4 -3
- package/package.json +1 -1
- package/test/export-surface.snapshot.json +65 -5
- package/wire-changes/core@7.53.0.json +1946 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { types } from "node:util";
|
|
2
2
|
import { describeFault, isPlainRecord, receive } from "./mods/kernel/receive.js";
|
|
3
|
+
import { MODS_VALUE_DEPTH } from "./mods/kernel/site-rules.js";
|
|
3
4
|
export function receiptRefusal(message) {
|
|
4
5
|
const e = new Error(message);
|
|
5
6
|
e.code = "config.invalid_argument";
|
|
@@ -9,7 +10,8 @@ export function refuseProxy(given, words) {
|
|
|
9
10
|
if (types.isProxy(given))
|
|
10
11
|
throw receiptRefusal(`${words.subject} must be a plain object, not a Proxy: its ${words.unit}s are read once off its own descriptors, and a Proxy would run its traps in that read — refused rather than wired through it`);
|
|
11
12
|
}
|
|
12
|
-
const CONFIG_RECEIPT_MODE = Object.freeze({ accessors: "call-once", depth: 1, others: "as-is", isProxy: (v) => types.isProxy(v) });
|
|
13
|
+
export const CONFIG_RECEIPT_MODE = Object.freeze({ accessors: "call-once", depth: 1, others: "as-is", isProxy: (v) => types.isProxy(v) });
|
|
14
|
+
export const DECLARATION_RECEIPT_MODE = Object.freeze({ accessors: "call-once", depth: MODS_VALUE_DEPTH + 1, others: "refuse", freeze: true, isProxy: (v) => types.isProxy(v) });
|
|
13
15
|
export function receiveOwnProperties(given, words) {
|
|
14
16
|
refuseProxy(given, words);
|
|
15
17
|
if (!isPlainRecord(given)) {
|
|
@@ -52,8 +52,8 @@ export type ParentSpecSeatFields = Pick<TaskSpec, "principal" | "oneShot" | "cli
|
|
|
52
52
|
* · `promptForm` — the host form of the system prompt (`"minimal"`, its only word: the core-behavior band is out). A
|
|
53
53
|
* host's product choice for the whole delegation tree, so every engine-built child (both delegation lanes and the
|
|
54
54
|
* observer sidecar) composes the same set of sections. An ORDINARY member (fill law).
|
|
55
|
-
* · `promptBinding` — the
|
|
56
|
-
* artifact, so
|
|
55
|
+
* · `promptBinding` — the binding (a deployment's scenario name), a prompt selector value. A child composes its
|
|
56
|
+
* parent's center artifact, so its overlays' `when.binding` reads the same binding. An ORDINARY member (fill law).
|
|
57
57
|
*/
|
|
58
58
|
export interface ParentSpecSeat {
|
|
59
59
|
readonly principal?: string;
|
|
@@ -161,15 +161,43 @@ export declare function callPathFaceOf(call: ToolCallLike): DenyFace | undefined
|
|
|
161
161
|
* it, whatever the call's tool is called (a caller's tool declaring a read path target is on the read face too)? */
|
|
162
162
|
export declare function faceRowsSpeakFor(face: DenyFace | undefined): boolean;
|
|
163
163
|
/**
|
|
164
|
-
* The tools whose rule content NAMES THE VALUE of one parameter instead of a command or a path —
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
164
|
+
* The tools whose rule content NAMES THE VALUE of one parameter instead of a command or a path — ONE grammar (the name grammar,
|
|
165
|
+
* match `name`), one row per tool, the row declaring the tool's SPELLING of it:
|
|
166
|
+
* · BARE — the reference's `Skill(<name>)` / `Skill(<prefix>:*)`: `param` is the argument the rule's content is read against,
|
|
167
|
+
* `params` every scalar argument the tool carries (the parameter spelling `Tool(<param>:<pattern>)` those names used to reach
|
|
168
|
+
* is retired for such a tool, see {@link parseNameRuleContent}). The Skill tool's real schema keys are pinned equal to
|
|
169
|
+
* `params` (test/backlog1318).
|
|
170
|
+
* · KEYED — `words` present: the reference's `Artifact(action:<word>)`, the content carrying the argument's own key. `params`
|
|
171
|
+
* is that one key; `words` is the closed set of values the tool itself declares for it (the row points at the tool's own
|
|
172
|
+
* set, never a copy), and a rule names exactly one of them — no prefix form, no `*`.
|
|
173
|
+
* Whatever the spelling, a rule of this grammar says "the call's value of `param` is this value", read by the one subject
|
|
174
|
+
* reader ({@link nameRuleSubjectOf}), the one predicate ({@link nameRuleAdmits}), the one precedence walk
|
|
175
|
+
* ({@link adjudicatePersistedNameRules}) and the one offer ({@link suggestRuleForName}).
|
|
168
176
|
*/
|
|
169
177
|
export declare const NAME_RULE_FACES: Readonly<Record<string, {
|
|
170
178
|
readonly param: string;
|
|
171
179
|
readonly params: readonly string[];
|
|
180
|
+
readonly words?: readonly string[];
|
|
172
181
|
}>>;
|
|
182
|
+
/**
|
|
183
|
+
* Why a call of a KEYED value tool that names no value for the key cannot be read against that key's deny / ask rules, or
|
|
184
|
+
* undefined (a bare-spelling tool, or no value tool). Every judge reads a call's arguments as the tool reads them
|
|
185
|
+
* (`argsAsTheToolReads`: its argument preparation, then the schema's coercions); a call that STILL names no value for the key
|
|
186
|
+
* runs a value no argument shows — a default filled in inside the tool's execution (a caller's tool mounted under the keyed
|
|
187
|
+
* name, or answering to it, with no argument preparation of its own). Whether a rule by the key reaches such a call is
|
|
188
|
+
* unknown, so every reader REFUSES it on the key's deny or ask rule — a refusal, never an ask a person could approve past a
|
|
189
|
+
* deny, and no allow by the key reaches it. A tool whose reading always names the key (the built-in `Artifact`: an absent
|
|
190
|
+
* action reads as `publish`) never meets this. A bare-spelling tool's call that names nothing is reached by nothing: no
|
|
191
|
+
* default stands behind it.
|
|
192
|
+
*/
|
|
193
|
+
export declare function keyedValueAbsentReason(tool: string): string | undefined;
|
|
194
|
+
/**
|
|
195
|
+
* Does the name grammar read this content of this tool? Every content of a bare-spelling tool; on a keyed tool only content
|
|
196
|
+
* keyed by its own parameter (`action:…` on `Artifact`) — another key (`Artifact(url:…)`) is a rule on another argument,
|
|
197
|
+
* which the persisted grammar has no form for and the caller policy reads with its generic parameter lane. Undefined grammar
|
|
198
|
+
* ⇒ false.
|
|
199
|
+
*/
|
|
200
|
+
export declare function nameGrammarReads(tool: string, content: string): boolean;
|
|
173
201
|
/**
|
|
174
202
|
* The tools whose rule content names the HOST of the URL one parameter carries — the reference's `WebFetch(domain:<host>)`
|
|
175
203
|
* form, one row per tool: `param` is the URL argument the host is read from ({@link domainRuleSubjectOf}). Read by
|
|
@@ -182,8 +210,9 @@ export declare const DOMAIN_RULE_FACES: Readonly<Record<string, {
|
|
|
182
210
|
* Which tools a rule may name — the model's tool set is DERIVED, never a hand-kept list: the command rule word
|
|
183
211
|
* ({@link COMMAND_RULE_TOOL}) takes the COMMAND grammar — the other shell-face tools take none of their own, their command is
|
|
184
212
|
* judged by the `Bash(…)` rules ({@link laneToolNamesOf}); every tool the catalog declares a path target for (Read / Edit / Write /
|
|
185
|
-
* Glob / NotebookEdit / …, `pathTargetOf`) takes the PATH grammar; the tools of {@link NAME_RULE_FACES} take the NAME grammar
|
|
186
|
-
* the tools of {@link DOMAIN_RULE_FACES} the
|
|
213
|
+
* Glob / NotebookEdit / …, `pathTargetOf`) takes the PATH grammar; the tools of {@link NAME_RULE_FACES} take the NAME grammar
|
|
214
|
+
* (each in its row's spelling: bare `Skill(<name>)`, keyed `Artifact(action:<word>)`); the tools of {@link DOMAIN_RULE_FACES} the
|
|
215
|
+
* DOMAIN grammar.
|
|
187
216
|
* A rule on any other tool has no content this model can judge and is refused (`unsupported.tool`). The tool set therefore
|
|
188
217
|
* moves with the catalog's declarations, exactly as the protective fences' covered set does.
|
|
189
218
|
*/
|
|
@@ -355,6 +384,21 @@ export interface ParsedRule {
|
|
|
355
384
|
/** Upper bound on a rule text. Rules are human-authored one-liners; anything longer is a mistake or an
|
|
356
385
|
* attempt to make the store unreadable. */
|
|
357
386
|
export declare const MAX_RULE_TEXT_CHARS = 512;
|
|
387
|
+
/**
|
|
388
|
+
* The most code points of a rule's ORIGINAL text a notice's machine-read slot carries: twice the grammar's own bound. A text past
|
|
389
|
+
* {@link MAX_RULE_TEXT_CHARS} reads as no rule whatever follows its first characters, so the slot keeps room to show it as far as a person
|
|
390
|
+
* needs to recognise it and no further; every text a rule can be is carried whole. Not exported from the package root: a consumer reads
|
|
391
|
+
* the slot and never judges its length (it is not a relay that must refuse what the engine did not mint).
|
|
392
|
+
*/
|
|
393
|
+
export declare const NOTICE_RULE_TEXT_MAX: number;
|
|
394
|
+
/**
|
|
395
|
+
* A rule's (or allow-list entry's) text as a notice's machine-read slot carries it: the original string, untouched, when it is at most
|
|
396
|
+
* {@link NOTICE_RULE_TEXT_MAX} code points; a longer one is cut to that many and ends in the engine's one truncation mark
|
|
397
|
+
* ({@link INLINE_TRUNCATION_MARK}), so the longest slot is `NOTICE_RULE_TEXT_MAX + INLINE_TRUNCATION_MARK_CODEPOINTS` (1 025) code points.
|
|
398
|
+
* The ONE reading both `permission.allowed_tool_not_granted` (`detail.entries[].entry`) and `permission.rule_row_dropped`
|
|
399
|
+
* (`detail.rows[].rule`) hand their rule text over through — what spells it for a person is the sentence, never this slot.
|
|
400
|
+
*/
|
|
401
|
+
export declare function noticeRuleText(text: string): string;
|
|
358
402
|
/**
|
|
359
403
|
* Interpreter names whose PREFIX form is refused everywhere a rule can enter the store (minting,
|
|
360
404
|
* import, file reload, every backend). `Bash(node:*)` reads as one narrow-looking rule and means "run
|
|
@@ -956,7 +1000,9 @@ export declare function commandCoverageOf(rules: readonly PersistedRule[], call:
|
|
|
956
1000
|
};
|
|
957
1001
|
/** The answer of {@link adjudicatePersistedRules}: which behavior decided, and the rule(s) it stands
|
|
958
1002
|
* on — a one-element set for a deny/ask (the first table-order rule of the deciding behavior that
|
|
959
|
-
* reaches the call
|
|
1003
|
+
* reaches the call; for a keyed tool's call naming no value for its key, a DENY standing on the first deny — else ask —
|
|
1004
|
+
* row of that key, which the call cannot be read against: {@link adjudicatePersistedNameRules}) and the allow
|
|
1005
|
+
* direction's coverage SET ({@link findAdmittingRule}). */
|
|
960
1006
|
export interface PersistedRuleVerdict {
|
|
961
1007
|
readonly behavior: RuleBehavior;
|
|
962
1008
|
readonly rules: readonly PersistedRule[];
|
|
@@ -1032,8 +1078,11 @@ export declare function adjudicatePersistedPathRules(rules: readonly PersistedRu
|
|
|
1032
1078
|
* ({@link NAME_RULE_FACES}), judged on the one string the call names (`nameRuleSubjectOf`). A rule of the tool speaks for the call
|
|
1033
1079
|
* when it is live, of this behavior, in scope ({@link eligiblePersisted}, the one predicate) and {@link nameRuleAdmits} the name; the
|
|
1034
1080
|
* first behavior in {@link RULE_BEHAVIORS_BY_PRECEDENCE} whose rules speak decides, the first table-order rule of it is the answer.
|
|
1035
|
-
* Every behavior is judged with the one predicate — a name has no "program run" the tightening direction could read wider
|
|
1036
|
-
*
|
|
1081
|
+
* Every behavior is judged with the one predicate — a name has no "program run" the tightening direction could read wider.
|
|
1082
|
+
* A call that names nothing (read as the tool reads it): on a bare-spelling tool it is reached by no rule; on a KEYED tool it
|
|
1083
|
+
* cannot be read against the key's rules ({@link keyedValueAbsentReason}) and is REFUSED — a deny verdict standing on the
|
|
1084
|
+
* first eligible deny row of the key, else its first ask row (an ask a person could approve would let a deny be approved
|
|
1085
|
+
* past) — and no allow row reaches it.
|
|
1037
1086
|
*/
|
|
1038
1087
|
export declare function adjudicatePersistedNameRules(rules: readonly PersistedRule[], call: {
|
|
1039
1088
|
tool: string;
|
|
@@ -3,13 +3,15 @@ import { shellWordsOf } from "../shell/shell-words.js";
|
|
|
3
3
|
import { parsePermissionRule } from "./permission-rule-syntax.js";
|
|
4
4
|
import { compileReadDeny } from "../tools/fs/read-deny.js";
|
|
5
5
|
import { carriesShellRedirection, parseLeadingCommandName, splitShellCompoundSegments } from "../tools/fs/bash-readonly-classifier.js";
|
|
6
|
-
import { inlineUntrusted } from "./untrusted-text.js";
|
|
6
|
+
import { INLINE_TRUNCATION_MARK, inlineUntrusted } from "./untrusted-text.js";
|
|
7
7
|
import { isShellFaceToolName, pathTargetOf, protectivePathTargetOf } from "./tool-registry.js";
|
|
8
8
|
import { heldValues } from "./tool-name-readings.js";
|
|
9
9
|
import { carriesDotSegment, isAbsoluteForFamily, isIdentityDir, isPathIdentity, isShellRootedSpellingUnmapped, isUncIdentity, pathFamilyOf, pathIdentityOf } from "../tools/fs/safety.js";
|
|
10
10
|
import { bindPathRules, judgeRuleRows, rowsWhereTheyLead } from "./path-rule-binding.js";
|
|
11
11
|
import { readShellCommand } from "./shell-lexer.js";
|
|
12
12
|
import { lineDescriptorsOfText, readOnlyLineObjection, readOnlyShellVerdict } from "./read-only-shell.js";
|
|
13
|
+
import { ARTIFACT_ACTIONS } from "./artifact-host.js";
|
|
14
|
+
import { ARTIFACT_TOOL_NAME } from "./tool-catalog-entries.js";
|
|
13
15
|
export const RULE_BEHAVIORS = Object.freeze(["deny", "ask", "allow"]);
|
|
14
16
|
const RULE_BEHAVIOR_SET = new Set(RULE_BEHAVIORS);
|
|
15
17
|
export function isRuleBehavior(v) {
|
|
@@ -43,7 +45,25 @@ export function faceRowsSpeakFor(face) {
|
|
|
43
45
|
}
|
|
44
46
|
export const NAME_RULE_FACES = Object.freeze({
|
|
45
47
|
Skill: Object.freeze({ param: "skill", params: Object.freeze(["skill", "args"]) }),
|
|
48
|
+
[ARTIFACT_TOOL_NAME]: Object.freeze({ param: "action", params: Object.freeze(["action"]), words: ARTIFACT_ACTIONS }),
|
|
46
49
|
});
|
|
50
|
+
function keyedValueParamOf(tool) {
|
|
51
|
+
const face = Object.hasOwn(NAME_RULE_FACES, tool) ? NAME_RULE_FACES[tool] : undefined;
|
|
52
|
+
return face?.words !== undefined ? face.param : undefined;
|
|
53
|
+
}
|
|
54
|
+
export function keyedValueAbsentReason(tool) {
|
|
55
|
+
const key = keyedValueParamOf(tool);
|
|
56
|
+
return key === undefined ? undefined : `the ${tool} call names no ${key} as the tool reads it, so the ${key} it runs is not one its arguments show — a rule by ${key} cannot be read against it`;
|
|
57
|
+
}
|
|
58
|
+
export function nameGrammarReads(tool, content) {
|
|
59
|
+
if (ruleToolGrammarOf(tool) !== "name")
|
|
60
|
+
return false;
|
|
61
|
+
const key = keyedValueParamOf(tool);
|
|
62
|
+
if (key === undefined)
|
|
63
|
+
return true;
|
|
64
|
+
const colon = content.indexOf(":");
|
|
65
|
+
return colon > 0 && content.slice(0, colon).trim() === key;
|
|
66
|
+
}
|
|
47
67
|
export const DOMAIN_RULE_FACES = Object.freeze({
|
|
48
68
|
WebFetch: Object.freeze({ param: "url" }),
|
|
49
69
|
});
|
|
@@ -95,6 +115,20 @@ function isCommandMatch(match) {
|
|
|
95
115
|
return match === "exact" || match === "prefix" || match === "wildcard";
|
|
96
116
|
}
|
|
97
117
|
export const MAX_RULE_TEXT_CHARS = 512;
|
|
118
|
+
export const NOTICE_RULE_TEXT_MAX = 2 * MAX_RULE_TEXT_CHARS;
|
|
119
|
+
export function noticeRuleText(text) {
|
|
120
|
+
if (text.length <= NOTICE_RULE_TEXT_MAX)
|
|
121
|
+
return text;
|
|
122
|
+
let kept = 0;
|
|
123
|
+
let end = 0;
|
|
124
|
+
for (const ch of text) {
|
|
125
|
+
if (kept === NOTICE_RULE_TEXT_MAX)
|
|
126
|
+
return `${text.slice(0, end)}${INLINE_TRUNCATION_MARK}`;
|
|
127
|
+
end += ch.length;
|
|
128
|
+
kept += 1;
|
|
129
|
+
}
|
|
130
|
+
return text;
|
|
131
|
+
}
|
|
98
132
|
export const BARE_INTERPRETER_NAMES = new Set([
|
|
99
133
|
"node", "deno", "bun", "python", "python2", "python3", "perl", "ruby", "php", "osascript",
|
|
100
134
|
"java", "dotnet", "mono", "lua", "luajit", "julia", "Rscript", "tclsh", "groovy", "scala",
|
|
@@ -243,6 +277,13 @@ function ruleLaneShapeOf(command, reading) {
|
|
|
243
277
|
}
|
|
244
278
|
const CONTROL_CHARS_RE = /[\u0000-\u0008\u000A-\u001F\u007F-\u009F\p{Cf}\u2028\u2029]/u;
|
|
245
279
|
const CONTROL_CHARS_GLOBAL_RE = new RegExp(CONTROL_CHARS_RE.source, "gu");
|
|
280
|
+
const RULE_SPELLING_REJECT_BYTES = "<>";
|
|
281
|
+
const RULE_SPELLING_REJECT_RE = new RegExp(`[${RULE_SPELLING_REJECT_BYTES}]`);
|
|
282
|
+
function valueRuleFormsSentence() {
|
|
283
|
+
return Object.entries(NAME_RULE_FACES)
|
|
284
|
+
.map(([tool, face]) => (face.words !== undefined ? `${tool}(${face.param}:<${face.param}>) rules` : `${tool}(<${face.param}>) rules`))
|
|
285
|
+
.join(", ");
|
|
286
|
+
}
|
|
246
287
|
const DISCLOSED_RULE_TEXT_MAX_CHARS = 120;
|
|
247
288
|
export function escapeForDisclosure(value) {
|
|
248
289
|
let text;
|
|
@@ -293,13 +334,16 @@ export function parseRuleText(text, behavior) {
|
|
|
293
334
|
}
|
|
294
335
|
if (parsed.toolName !== COMMAND_RULE_TOOL) {
|
|
295
336
|
const grammar = ruleToolGrammarOf(parsed.toolName);
|
|
337
|
+
if (grammar === undefined) {
|
|
338
|
+
return reject("unsupported.tool", `only Bash command rules, rules on path-targeting tools (Read, Edit, Write, …), ${valueRuleFormsSentence()} and WebFetch domain rules have a rule form in this version (got "${parsed.toolName}")`);
|
|
339
|
+
}
|
|
340
|
+
if (!tighten && RULE_SPELLING_REJECT_RE.test(parsed.ruleContent)) {
|
|
341
|
+
return reject("invalid.grammar", `"${text}" carries a shell redirection byte (${[...RULE_SPELLING_REJECT_BYTES].map((b) => `\`${b}\``).join(" or ")}) — no path, name or host allow spells one, and the grant would not read as what it looks like`);
|
|
342
|
+
}
|
|
296
343
|
if (grammar === "name")
|
|
297
344
|
return parseNameRuleContent(text, parsed.toolName, parsed.ruleContent, behavior);
|
|
298
345
|
if (grammar === "domain")
|
|
299
346
|
return parseDomainRuleContent(text, parsed.toolName, parsed.ruleContent, behavior);
|
|
300
|
-
if (grammar !== "path") {
|
|
301
|
-
return reject("unsupported.tool", `only Bash command rules, rules on path-targeting tools (Read, Edit, Write, …), Skill name rules and WebFetch domain rules have a rule form in this version (got "${parsed.toolName}")`);
|
|
302
|
-
}
|
|
303
347
|
return parsePathRuleContent(text, parsed.toolName, parsed.ruleContent, behavior);
|
|
304
348
|
}
|
|
305
349
|
const content = parsed.ruleContent;
|
|
@@ -353,14 +397,18 @@ export function parseRuleText(text, behavior) {
|
|
|
353
397
|
export function formatRuleText(command, match, tool) {
|
|
354
398
|
if (match === "subpath")
|
|
355
399
|
return `${tool}(//${command.startsWith("/") ? command.slice(1) : command}/**)`;
|
|
356
|
-
if (match === "path"
|
|
400
|
+
if (match === "path")
|
|
357
401
|
return `${tool}(${command})`;
|
|
402
|
+
if (match === "name")
|
|
403
|
+
return `${tool}(${keyedValueParamOf(tool) !== undefined ? `${keyedValueParamOf(tool)}:` : ""}${command})`;
|
|
358
404
|
if (match === "host" || match === "subdomain")
|
|
359
405
|
return `${tool}(domain:${match === "subdomain" ? "*." : ""}${command})`;
|
|
360
406
|
return `${tool}(${command}${match === "prefix" || match === "name_prefix" ? ":*" : match === "wildcard" ? " *" : ""})`;
|
|
361
407
|
}
|
|
362
408
|
function parseNameRuleContent(text, tool, content, behavior, verifyCanonical = true) {
|
|
363
409
|
const face = NAME_RULE_FACES[tool];
|
|
410
|
+
if (face?.words !== undefined)
|
|
411
|
+
return parseKeyedValueRuleContent(text, tool, content, behavior, { param: face.param, words: face.words });
|
|
364
412
|
const bare = content.startsWith("/") ? content.slice(1) : content;
|
|
365
413
|
const colon = bare.indexOf(":");
|
|
366
414
|
if (face !== undefined && colon > 0 && face.params.includes(bare.slice(0, colon).trim())) {
|
|
@@ -389,6 +437,24 @@ function parseNameRuleContent(text, tool, content, behavior, verifyCanonical = t
|
|
|
389
437
|
}
|
|
390
438
|
return { rule };
|
|
391
439
|
}
|
|
440
|
+
function parseKeyedValueRuleContent(text, tool, content, behavior, face) {
|
|
441
|
+
const vocabulary = face.words.join(", ");
|
|
442
|
+
const colon = content.indexOf(":");
|
|
443
|
+
if (colon <= 0 || content.slice(0, colon).trim() !== face.param) {
|
|
444
|
+
return reject("invalid.grammar", `${tool} rules name the ${face.param}: ${tool}(${face.param}:<${face.param}>) with one of ${vocabulary} ("${text}") — a bare value, or a rule on another argument, has no rule form here`);
|
|
445
|
+
}
|
|
446
|
+
const word = content.slice(colon + 1).trim();
|
|
447
|
+
if (word === "") {
|
|
448
|
+
return reject("invalid.grammar", `the ${face.param} in "${text}" is empty — ${tool} rules name the ${face.param} exactly as the call carries it`);
|
|
449
|
+
}
|
|
450
|
+
if (word.includes("*")) {
|
|
451
|
+
return reject("unsupported.wildcard", `a \`*\` in the ${face.param} of "${text}" has no rule form — ${tool} rules name one ${face.param} (${vocabulary}); the whole tool is the bare ${tool} entry`);
|
|
452
|
+
}
|
|
453
|
+
if (!face.words.includes(word)) {
|
|
454
|
+
return reject("invalid.grammar", `"${word}" is not one of the ${face.param} values ${tool} declares (${vocabulary}) — the rule would never reach a call`);
|
|
455
|
+
}
|
|
456
|
+
return { rule: { behavior, rule: formatRuleText(word, "name", tool), tool, match: "name", command: word } };
|
|
457
|
+
}
|
|
392
458
|
export function nameRuleAdmits(rule, name) {
|
|
393
459
|
if (rule.match === "name")
|
|
394
460
|
return name === rule.command;
|
|
@@ -802,7 +868,7 @@ export function directoryIdentityOf(spelling, bases) {
|
|
|
802
868
|
const r = pathIdentityOf(spelling, pathFamilyOf(bases), bases.root ?? bases.cwd);
|
|
803
869
|
return r.ok ? r.identity : undefined;
|
|
804
870
|
}
|
|
805
|
-
const CD_TARGET_REJECT_CHARS =
|
|
871
|
+
const CD_TARGET_REJECT_CHARS = new RegExp(String.raw `[*?[\]{}$` + "`" + String.raw `\\'"\n\r` + RULE_SPELLING_REJECT_BYTES + "]");
|
|
806
872
|
function cdSegmentDirectoryOf(segment, opts) {
|
|
807
873
|
if (/[^\S \t]/.test(segment))
|
|
808
874
|
return undefined;
|
|
@@ -1033,8 +1099,16 @@ export function adjudicatePersistedPathRules(rules, call, views, anchorsOf, lead
|
|
|
1033
1099
|
return undefined;
|
|
1034
1100
|
}
|
|
1035
1101
|
export function adjudicatePersistedNameRules(rules, call) {
|
|
1036
|
-
if (call.name === undefined)
|
|
1102
|
+
if (call.name === undefined) {
|
|
1103
|
+
if (keyedValueAbsentReason(call.tool) === undefined)
|
|
1104
|
+
return undefined;
|
|
1105
|
+
for (const behavior of ["deny", "ask"]) {
|
|
1106
|
+
const row = rules.find((rule) => rule.match === "name" && eligiblePersisted(rule, call, behavior));
|
|
1107
|
+
if (row !== undefined)
|
|
1108
|
+
return { behavior: "deny", rules: [row] };
|
|
1109
|
+
}
|
|
1037
1110
|
return undefined;
|
|
1111
|
+
}
|
|
1038
1112
|
for (const behavior of RULE_BEHAVIORS_BY_PRECEDENCE) {
|
|
1039
1113
|
for (const rule of rules) {
|
|
1040
1114
|
if (eligiblePersisted(rule, call, behavior) && nameRuleAdmits(rule, call.name))
|
|
@@ -34,8 +34,30 @@
|
|
|
34
34
|
* refused and disclosed — identity comparison alone cannot catch it, and an in-memory-only mark would
|
|
35
35
|
* accept revision N−1 after a restart. Signature / predecessor chaining belongs to the privilege-
|
|
36
36
|
* separation ticket; the high-water mark is the floor that needs no key distribution.
|
|
37
|
+
*
|
|
38
|
+
* ## One reading of a row
|
|
39
|
+
*
|
|
40
|
+
* A snapshot is installed and served on its ENVELOPE ({@link validateOrgSnapshot}: revision, observation
|
|
41
|
+
* time, a rules list) and the anti-rollback fence; what its rows say never decides which snapshot is in
|
|
42
|
+
* force. Whether the rules are a list is judged in ONE place ({@link listRefusalOf}) for the partition and for
|
|
43
|
+
* every store that hands a resolution over — rules that are not a list, or that carry more places than a rule set may
|
|
44
|
+
* (the same cap the rule compiler holds a set to), are governance nobody can read (the
|
|
45
|
+
* partition refuses the snapshot; the org lane answers unavailable), never a policy of zero rows — and ONE reader
|
|
46
|
+
* ({@link orgRuleListOf}) copies the whole list in one receipt: a member of a row that cannot be read is left out of
|
|
47
|
+
* that row's copy alone, and every row is judged on its copy. A snapshot the partition holds — fetched or read back
|
|
48
|
+
* from its persistence — is that same copy ({@link orgSnapshotCopyOf}). Every row is then read by ONE reader
|
|
49
|
+
* ({@link readOrgRules}), the same for every store that hands a resolution over, on its policy members
|
|
50
|
+
* ({@link ORG_ROW_POLICY_MEMBERS}): a row is READ when its behavior is `deny` or `ask` and its text is a shell command
|
|
51
|
+
* rule under that behavior. Any other row — another grammar's rule, a shell rule the validator refuses, a row
|
|
52
|
+
* with no text, a behavior this layer has no bucket for — is UNREADABLE, and stands at its strictest
|
|
53
|
+
* reading over the calls it may reach ({@link OrgRowReach}): an `ask` row asks a person, every other row
|
|
54
|
+
* refuses. Readable deny and ask rows hold as published beside it. One unreadable row therefore never
|
|
55
|
+
* takes the rest of the policy down with it, and never turns a published deny into a question; the
|
|
56
|
+
* snapshot is served DEGRADED, and every resolution and every adjudication over it names the unreadable
|
|
57
|
+
* rows ({@link describeUnreadableOrgRows}).
|
|
37
58
|
*/
|
|
38
|
-
import { type PersistedRule, type RuleRejectCode } from "./permission-rule-model.js";
|
|
59
|
+
import { type ParsedRule, type PersistedRule, type RuleRejectCode } from "./permission-rule-model.js";
|
|
60
|
+
import type { DenyFace } from "../tools/fs/read-deny.js";
|
|
39
61
|
import type { PermissionRuleStore } from "./permission-rule-provider.js";
|
|
40
62
|
/** One org rule. There is structurally no allow bucket (design/179 §9: the org layer only tightens). */
|
|
41
63
|
export interface OrgPermissionRule {
|
|
@@ -171,42 +193,146 @@ export declare const UNGOVERNED_ORG_RESOLUTION: Readonly<OrgRuleResolution>;
|
|
|
171
193
|
* bound is refused loudly, never coerced.
|
|
172
194
|
*/
|
|
173
195
|
export declare function createOrgRulePartition(cfg: OrgRulePartitionConfig): OrgRulePartition;
|
|
196
|
+
/** Whether two snapshots carry the same POLICY: row for row, the same policy members ({@link ORG_ROW_POLICY_MEMBERS}) — never
|
|
197
|
+
* observation metadata, never a member no judgment reads (which a copy may carry or leave out). The ONE test of "the same
|
|
198
|
+
* revision, the same content": the partition's equal-revision guard asks it of two snapshots it holds in one form
|
|
199
|
+
* ({@link orgSnapshotCopyOf}), and a persistence backend asks it of what it stores. */
|
|
200
|
+
export declare function sameOrgPolicyContent(a: OrgRuleSnapshot, b: OrgRuleSnapshot): boolean;
|
|
174
201
|
/**
|
|
175
|
-
* Which
|
|
176
|
-
* that can match nothing on this build. Empty ⟺ every rule is enforceable.
|
|
202
|
+
* Which calls an UNREADABLE row may reach — the calls its strictest reading stands over.
|
|
177
203
|
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
204
|
+
* `"every"` when the row names no tool this layer can place: no rule text, a head the rule syntax cannot read, the lone
|
|
205
|
+
* `*`, or a tool with no rule grammar (a misspelled tool name and a tool this build does not know look the same, and
|
|
206
|
+
* both may be the shell). Otherwise the rule WORD it names — a shell tool's head is the command word, as a call's is —
|
|
207
|
+
* and, for a tool whose path rules speak for a face ({@link PATH_RULE_FACES}), the faces of the column its strictest
|
|
208
|
+
* behavior reads: such a row reaches what a readable rule of its tool could reach, and nothing else.
|
|
209
|
+
*/
|
|
210
|
+
export type OrgRowReach = "every" | {
|
|
211
|
+
readonly words: readonly string[];
|
|
212
|
+
readonly faces: readonly DenyFace[];
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* A row the layer cannot read: its text (as published; the rendering of the scalar its `rule` holds when that is not a string;
|
|
216
|
+
* `<unreadable>` when it holds none — a structure is no value, {@link orgRowPolicyOf}), its 1-based place in the
|
|
217
|
+
* snapshot, why (`code`, and `detail` for a row whose shape — not its text — is at fault), the behavior it stands at, and
|
|
218
|
+
* the calls it reaches. `behavior` is the row's STRICTEST reading: `ask` only when the row says `ask`, `deny` for a row
|
|
219
|
+
* that says `deny` and for one whose behavior cannot be read.
|
|
220
|
+
*/
|
|
221
|
+
export interface UnreadableOrgRow {
|
|
222
|
+
readonly kind: "unreadable";
|
|
223
|
+
readonly index: number;
|
|
224
|
+
readonly rule: string;
|
|
225
|
+
readonly code: RuleRejectCode;
|
|
226
|
+
readonly detail?: string;
|
|
227
|
+
readonly behavior: "deny" | "ask";
|
|
228
|
+
readonly reach: OrgRowReach;
|
|
229
|
+
}
|
|
230
|
+
/** A row the layer reads: a shell command rule under the behavior it publishes. */
|
|
231
|
+
export interface ReadOrgRow {
|
|
232
|
+
readonly kind: "read";
|
|
233
|
+
readonly index: number;
|
|
234
|
+
readonly rule: string;
|
|
235
|
+
readonly behavior: "deny" | "ask";
|
|
236
|
+
readonly parsed: ParsedRule;
|
|
237
|
+
}
|
|
238
|
+
/** One call as the org layer judges it: the rule words it answers to (`laneToolNamesOf`; one word is enough), its shell
|
|
239
|
+
* command when it is the shell tool's, and the face of its path target when it has one (`callPathFaceOf`). */
|
|
240
|
+
export interface OrgRuleCall {
|
|
241
|
+
readonly tool: string | readonly string[];
|
|
242
|
+
readonly command?: string;
|
|
243
|
+
readonly face?: DenyFace;
|
|
244
|
+
}
|
|
245
|
+
/** Every row of a snapshot read once, and the one judgment of a call against them. */
|
|
246
|
+
export interface OrgRulesReading {
|
|
247
|
+
readonly rows: readonly (ReadOrgRow | UnreadableOrgRow)[];
|
|
248
|
+
readonly unreadable: readonly UnreadableOrgRow[];
|
|
249
|
+
verdictFor(call: OrgRuleCall): OrgRuleVerdict | undefined;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* The members of an org row the layer reads to judge a call — the row's POLICY. A row IS these members: every reader holds and
|
|
253
|
+
* judges a row as its policy ({@link orgRowPolicyOf}), and two rows with the same policy members are the same policy
|
|
254
|
+
* ({@link sameOrgPolicyContent}). Any other member a row carries is never judged, held, served or persisted (the receipt reads
|
|
255
|
+
* each of a row's own members once — a getter on one runs once — and copies none of what it holds beyond a scalar).
|
|
256
|
+
*/
|
|
257
|
+
export declare const ORG_ROW_POLICY_MEMBERS: readonly ["rule", "behavior"];
|
|
258
|
+
/** A JSON scalar — the only value a member the partition keeps holds as data. */
|
|
259
|
+
type Scalar = string | number | boolean | null;
|
|
260
|
+
type ScalarMembers<K extends string> = {
|
|
261
|
+
[P in K]?: Scalar;
|
|
262
|
+
};
|
|
263
|
+
type OrgRowPolicy = Readonly<ScalarMembers<(typeof ORG_ROW_POLICY_MEMBERS)[number]>>;
|
|
264
|
+
/**
|
|
265
|
+
* The envelope's rules LIST, read once: `refused` when it is not a list of at most the cap's places ({@link listRefusalOf} —
|
|
266
|
+
* judged before the list is received, so an oversized or sparse list builds no row) or cannot be received at all;
|
|
267
|
+
* otherwise its rows, each as its policy ({@link orgRowPolicyOf}) — the list received whole in one receipt
|
|
268
|
+
* ({@link ORG_RULES_RECEIPT}), so a row's member that cannot be read is that row's alone, a row that cannot be read at all (and
|
|
269
|
+
* a hole) is a row with nothing in it (`{}`: no rule text, read at its strictest reading) and the rows beside it are untouched.
|
|
270
|
+
* The ONE reader of the list — the partition holds a snapshot's rows as these, fetched and read back alike
|
|
271
|
+
* ({@link orgSnapshotCopyOf}), and every reading of rows ({@link readOrgRules}) reads them through it — so no store's rows can be
|
|
272
|
+
* read two ways, and no row can take the reading of another down with it.
|
|
273
|
+
*/
|
|
274
|
+
export declare function orgRuleListOf(rules: unknown): {
|
|
275
|
+
readonly rows: readonly OrgRowPolicy[];
|
|
276
|
+
} | {
|
|
277
|
+
readonly refused: string;
|
|
278
|
+
};
|
|
279
|
+
/**
|
|
280
|
+
* The ONE reading of an org snapshot's rows: each row read once ({@link readOrgRow}), and the one judgment of a call
|
|
281
|
+
* against them. Every reader of org rows goes through it — the partition's degraded line, the lane's adjudication,
|
|
282
|
+
* {@link orgRuleVerdictFor}, {@link unenforceableOrgRules} and the shadow view — so no two of them can read one row two ways.
|
|
283
|
+
*
|
|
284
|
+
* A call meets the rows in three answers. DENY: a readable deny reaches one of its program runs, or an unreadable row
|
|
285
|
+
* standing at deny reaches the call — the first such row in snapshot order speaks. ASK: a readable rule the call cannot be
|
|
286
|
+
* READ against (the lexer's reason — a rule that cannot be judged may be a deny, so it outranks a reached ask), else a
|
|
287
|
+
* readable ask reaching it or an unreadable row standing at ask reaching it, the first in snapshot order. Otherwise none.
|
|
288
|
+
* An unreadable row's verdict carries its reason ({@link unreadableOrgRowReason}) beside its text.
|
|
289
|
+
*
|
|
290
|
+
* The rows are read off the one list reader's copy ({@link orgRuleListOf}): rules that are not a list come back `refused` —
|
|
291
|
+
* the org's rules cannot be read, which is never a policy of zero rows — and a row is judged on what its copy holds: a policy
|
|
292
|
+
* member that could not be read is one the row does not have (no `rule` ⇒ no rule text, every call; no `behavior` ⇒ its
|
|
293
|
+
* strictest reading over the calls of the tool it names), read like any other unreadable row while the rows beside it keep
|
|
294
|
+
* their effect.
|
|
295
|
+
*/
|
|
296
|
+
export declare function readOrgRules(rules: unknown): OrgRulesReading | {
|
|
297
|
+
readonly refused: string;
|
|
298
|
+
};
|
|
299
|
+
/**
|
|
300
|
+
* Which rows of an org snapshot this layer cannot read, each with its code — the rows that stand at their strictest
|
|
301
|
+
* reading instead of as published. Empty ⟺ every row is read. Every unreadable row is reported, a row with no rule text
|
|
302
|
+
* or a behavior other than deny / ask included (its text rendered when it is not a string). Rules that are not a list, or a
|
|
303
|
+
* list past the cap, throw the one list judgment's sentence ({@link readListedOrgRules}) — never a reading of fewer rows.
|
|
182
304
|
*/
|
|
183
305
|
export declare function unenforceableOrgRules(rules: readonly OrgPermissionRule[]): Array<{
|
|
184
306
|
rule: string;
|
|
185
307
|
code: RuleRejectCode;
|
|
186
308
|
}>;
|
|
309
|
+
/** The reason an unreadable row's verdict carries — its place in the snapshot, its code, and the repair. */
|
|
310
|
+
export declare function unreadableOrgRowReason(row: Pick<UnreadableOrgRow, "index" | "code" | "detail">): string;
|
|
311
|
+
/** The ONE clause for an org verdict that carries an `unreadable` reason — a rule the call could not be read against, or
|
|
312
|
+
* a row this layer cannot read — on a refusal and on a question alike. */
|
|
313
|
+
export declare function orgUnreadableClause(reason: string): string;
|
|
187
314
|
/**
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
* against a rule is an ASK with the reason — fail closed, never silence).
|
|
194
|
-
*
|
|
195
|
-
* The skip below is a defensive floor, and what stands behind it is worth stating precisely: rules that
|
|
196
|
-
* arrive from the org partition's `resolve` ({@link createOrgRulePartition}) have passed {@link validateOrgSnapshot} on BOTH the install
|
|
197
|
-
* and the serving path (backlog #177), so an unenforceable entry cannot reach here through the overlay
|
|
198
|
-
* — the whole snapshot is refused, or the resolution reports `unavailable`, and either way it is
|
|
199
|
-
* disclosed. A caller that hands this function a snapshot it obtained ELSEWHERE gets no such guarantee:
|
|
200
|
-
* the skip is silent, and naming the dead entries is that caller's job — {@link unenforceableOrgRules}
|
|
201
|
-
* is the shared way to do it.
|
|
315
|
+
* The ONE line naming a snapshot's unreadable rows (count, the first {@link DISCLOSED_UNREADABLE_ROWS} by place, text and
|
|
316
|
+
* code, the rest summarized), or `undefined` when every row is read. The partition puts it on every resolution that
|
|
317
|
+
* serves such a snapshot, and the org lane hands it to its operator sink on every adjudication over one, so the two seats
|
|
318
|
+
* describe one snapshot in one sentence. Each text is escaped — the characters that most often make a row unreadable are
|
|
319
|
+
* exactly the ones that do not render.
|
|
202
320
|
*/
|
|
203
|
-
export declare function
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
*
|
|
209
|
-
*
|
|
321
|
+
export declare function describeUnreadableOrgRows(unreadable: readonly UnreadableOrgRow[], revision?: unknown): string | undefined;
|
|
322
|
+
/**
|
|
323
|
+
* design/182 §7.2 — which org rule speaks for this call, if any: {@link readOrgRules}'s judgment, over a snapshot read for
|
|
324
|
+
* this call alone. Matching uses the SAME parser and the SAME tightening reach the personal deny/ask rows use
|
|
325
|
+
* ({@link programRunReachOf}: an interpreter-headed prefix deny like `Bash(node:*)` is a legitimately wide tightening and
|
|
326
|
+
* matches; a segment hit is a hit; a call the lexer cannot read against a rule is an ASK with the reason — fail closed,
|
|
327
|
+
* never silence), and a row this layer cannot read stands at its strictest reading over the calls it may reach. A caller
|
|
328
|
+
* judging many calls against one snapshot reads it once with {@link readOrgRules} instead. Rules that are not a list, or a
|
|
329
|
+
* list past the cap, throw the one list judgment's sentence ({@link readListedOrgRules}) — never a verdict over fewer rows.
|
|
330
|
+
*/
|
|
331
|
+
export declare function orgRuleVerdictFor(rules: readonly OrgPermissionRule[], call: OrgRuleCall): OrgRuleVerdict | undefined;
|
|
332
|
+
/** The org layer's answer for one call: which rule spoke, with what behavior — and, when the rule could not be judged
|
|
333
|
+
* against the call, why (`unreadable`): either the call could not be READ against it (the lexer's reason; `behavior` is
|
|
334
|
+
* then `ask` — the org published a rule that may reach this call, and nobody can say), or the row is not one this layer
|
|
335
|
+
* reads ({@link unreadableOrgRowReason}; `behavior` is the row's strictest reading). */
|
|
210
336
|
export interface OrgRuleVerdict {
|
|
211
337
|
readonly behavior: "deny" | "ask";
|
|
212
338
|
readonly rule: string;
|
|
@@ -234,14 +360,18 @@ export interface OrgRuleVerdict {
|
|
|
234
360
|
* either way. org ASK rules do not shadow: the personal lane never consumes a `requiresRealApproval`
|
|
235
361
|
* ask, so the two never actually meet on one call.
|
|
236
362
|
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
363
|
+
* An UNREADABLE row standing at deny refuses every call it reaches ({@link readOrgRules}), so it shadows every personal
|
|
364
|
+
* rule of a tool it reaches — by the rule word, or by the face that tool's calls are on — exactly as the gate refuses
|
|
365
|
+
* those calls; one standing at ask does not shadow, as a readable ask does not.
|
|
366
|
+
*
|
|
367
|
+
* design/382 §2.6 — no READABLE org row reaches a Read directory rule in this version: the org layer has no Read
|
|
368
|
+
* grammar, and the rule's `command` is a PATH that must not be fed to the shell lane's segment reader as though it
|
|
369
|
+
* were a command line.
|
|
241
370
|
*/
|
|
242
371
|
export declare function orgRuleShadows(orgRules: readonly OrgPermissionRule[], rule: Pick<PersistedRule, "tool" | "command">): boolean;
|
|
243
|
-
/** The shadow predicate with the org
|
|
372
|
+
/** The shadow predicate with the org rows read ONCE — what a read over many rows uses. */
|
|
244
373
|
export declare function compileOrgShadowPredicate(orgRules: readonly OrgPermissionRule[]): (rule: Pick<PersistedRule, "tool" | "command">) => boolean;
|
|
245
374
|
/** Does this store carry a write face? Re-exported convenience for org-ticket integrations that need to
|
|
246
375
|
* distinguish a read-only projection from a writable personal bucket without importing the writer seam. */
|
|
247
376
|
export declare function isWritablePermissionRuleStore(store: PermissionRuleStore): boolean;
|
|
377
|
+
export {};
|