@inventarch/runtime 2.0.0 → 3.1.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/README.md +5 -5
- package/SPEC.md +18 -4
- package/dist/authoring-execution/execution.d.ts.map +1 -1
- package/dist/authoring-execution/execution.js +4 -2
- package/dist/authoring-execution/execution.js.map +1 -1
- package/dist/authoring-execution/inventory.d.ts.map +1 -1
- package/dist/authoring-execution/inventory.js +2 -0
- package/dist/authoring-execution/inventory.js.map +1 -1
- package/dist/authoring-execution/types.d.ts +2 -0
- package/dist/authoring-execution/types.d.ts.map +1 -1
- package/dist/door.d.ts.map +1 -1
- package/dist/door.js +3 -2
- package/dist/door.js.map +1 -1
- package/dist/editor/index.d.ts +3 -1
- package/dist/editor/index.d.ts.map +1 -1
- package/dist/editor/index.js +4 -1
- package/dist/editor/index.js.map +1 -1
- package/dist/editor/workspace.d.ts.map +1 -1
- package/dist/editor/workspace.js +11 -2
- package/dist/editor/workspace.js.map +1 -1
- package/dist/errors.d.ts +18 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +10 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/machine-protocol.js +1 -1
- package/dist/mandate-guard.d.ts +91 -0
- package/dist/mandate-guard.d.ts.map +1 -0
- package/dist/mandate-guard.js +160 -0
- package/dist/mandate-guard.js.map +1 -0
- package/dist/mandate-modes.d.ts +251 -4
- package/dist/mandate-modes.d.ts.map +1 -1
- package/dist/mandate-modes.js +426 -18
- package/dist/mandate-modes.js.map +1 -1
- package/dist/next.d.ts +4 -1
- package/dist/next.d.ts.map +1 -1
- package/dist/next.js +1 -1
- package/dist/next.js.map +1 -1
- package/dist/packet-host.d.ts +124 -4
- package/dist/packet-host.d.ts.map +1 -1
- package/dist/packet-host.js +11 -6
- package/dist/packet-host.js.map +1 -1
- package/dist/packet.d.ts +17 -2
- package/dist/packet.d.ts.map +1 -1
- package/dist/packet.js +9 -5
- package/dist/packet.js.map +1 -1
- package/dist/position.d.ts +18 -9
- package/dist/position.d.ts.map +1 -1
- package/dist/position.js +4 -3
- package/dist/position.js.map +1 -1
- package/dist/steward.d.ts +8 -1
- package/dist/steward.d.ts.map +1 -1
- package/dist/steward.js +10 -0
- package/dist/steward.js.map +1 -1
- package/package.json +8 -4
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { selects } from '@inventarch/graph';
|
|
2
|
+
import { RuntimeError } from './errors.js';
|
|
3
|
+
import { defaultActor, governingMandates, isAdmissionRefusal, profileRefusal, seatedWorkspace, } from './mandate-modes.js';
|
|
4
|
+
import { freeze } from './types.js';
|
|
5
|
+
const LIMIT = 512;
|
|
6
|
+
const governance = (seat) => `ia position --seat ${seat} --shape governance`;
|
|
7
|
+
const order = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
8
|
+
/** Whether the hook decides the edit: its tools name the tool and its paths select a spelling of the file (C10). */
|
|
9
|
+
export function mandateGuardSelects(request) {
|
|
10
|
+
const fold = request.fold ?? ((text) => text);
|
|
11
|
+
if (!request.hook.tools.includes(request.tool))
|
|
12
|
+
return false;
|
|
13
|
+
return request.paths.some((path) => request.hook.paths.some((selection) => selects(fold(selection), fold(path))));
|
|
14
|
+
}
|
|
15
|
+
/** OD4's actor, through the scope token `within`; `workspace` is the workspace position seats the path in, if one. */
|
|
16
|
+
function acting(reader, within, request, workspace) {
|
|
17
|
+
const { agentId, agentType } = request;
|
|
18
|
+
if (agentId !== undefined) {
|
|
19
|
+
if (typeof agentId !== 'string' || agentId === '' || agentId.length > LIMIT)
|
|
20
|
+
return { refusal: 'the subagent event carries a malformed agent_id', subagent: true };
|
|
21
|
+
if (typeof agentType !== 'string' || agentType === '' || agentType.length > LIMIT)
|
|
22
|
+
return { refusal: 'the subagent event names no agent_type', subagent: true };
|
|
23
|
+
const profiles = reader
|
|
24
|
+
.records({ within })
|
|
25
|
+
.filter((node) => node.discriminator === 'agent-profile' && node.band === 100 && node.name === agentType);
|
|
26
|
+
if (profiles.length !== 1)
|
|
27
|
+
return {
|
|
28
|
+
refusal: `subagent ${agentType} matches no single authored @agent-profile of that name`,
|
|
29
|
+
subagent: true,
|
|
30
|
+
};
|
|
31
|
+
const profile = profiles[0].identity;
|
|
32
|
+
const agents = reader
|
|
33
|
+
.directedView(profile, { within })
|
|
34
|
+
.filter((row) => row.kind === 'field-ref' &&
|
|
35
|
+
row.direction === 'out' &&
|
|
36
|
+
row.field === 'composition.agent' &&
|
|
37
|
+
reader.get(row.counterpart, { within })?.discriminator === 'agent')
|
|
38
|
+
.map((row) => row.counterpart);
|
|
39
|
+
if (agents.length !== 1)
|
|
40
|
+
return { refusal: `${profile} names no admitted composition.agent`, subagent: true };
|
|
41
|
+
return { agent: agents[0], as: `subagent ${agentType} acts as ${agents[0]} (${profile})` };
|
|
42
|
+
}
|
|
43
|
+
if (workspace === undefined)
|
|
44
|
+
return { as: 'the main session has no default actor: no @workspace holds this path' };
|
|
45
|
+
const fallback = defaultActor(reader, within, workspace);
|
|
46
|
+
if (fallback.refusal !== undefined)
|
|
47
|
+
return { refusal: fallback.refusal.message, next: fallback.refusal.next, subagent: false };
|
|
48
|
+
return fallback.actor === undefined
|
|
49
|
+
? { as: `the main session has no default actor: ${fallback.reason}` }
|
|
50
|
+
: { agent: fallback.actor, as: `the main session acts as ${fallback.actor}` };
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Decide one edit (see the module comment). A mandate whose authority cannot be read refuses a selected edit as
|
|
54
|
+
* IA-HOOK-MANDATE-UNAVAILABLE, naming its governance position; so, while any authored `@mandate` fails admission (lane
|
|
55
|
+
* D), does every selected edit, whoever acts, naming the mandate's `path:line` and `ia report` (`root` spelled when the
|
|
56
|
+
* request carries it). An edit the hook does not select is still allowed.
|
|
57
|
+
*/
|
|
58
|
+
export function evaluateMandateGuard(reader, within, request) {
|
|
59
|
+
const { hook } = request, paths = [...new Set(request.paths)];
|
|
60
|
+
if (!mandateGuardSelects({ ...request, paths }))
|
|
61
|
+
return freeze({ allowed: true, selected: false, message: `${hook.identity} does not select this edit` });
|
|
62
|
+
const deny = (code, why, next, actor) => freeze({
|
|
63
|
+
allowed: false,
|
|
64
|
+
selected: true,
|
|
65
|
+
code,
|
|
66
|
+
message: `${hook.message} (${hook.identity}: ${why}) Next: ${next}`,
|
|
67
|
+
next,
|
|
68
|
+
...(actor === undefined ? {} : { actor }),
|
|
69
|
+
});
|
|
70
|
+
try {
|
|
71
|
+
const workspace = seatedWorkspace(reader, within, paths[0]);
|
|
72
|
+
// C1 for the path and its workspace, over every spelling of the file; one row per mandate.
|
|
73
|
+
const locate = (actor) => {
|
|
74
|
+
const found = new Map();
|
|
75
|
+
for (const path of paths)
|
|
76
|
+
for (const mandate of governingMandates(reader, within, {
|
|
77
|
+
path,
|
|
78
|
+
...(workspace === undefined ? {} : { workspace }),
|
|
79
|
+
...(request.fold === undefined ? {} : { fold: request.fold }),
|
|
80
|
+
...(actor === undefined ? {} : { actor }),
|
|
81
|
+
}))
|
|
82
|
+
if (!found.has(mandate.identity))
|
|
83
|
+
found.set(mandate.identity, mandate);
|
|
84
|
+
return [...found.values()].sort((a, b) => order(a.identity, b.identity));
|
|
85
|
+
};
|
|
86
|
+
// The actor before anything else: an unknown subagent is refused at every selected path, governed or not.
|
|
87
|
+
const actor = acting(reader, within, request, workspace), governing = locate(), seat = governing[0]?.identity ?? workspace;
|
|
88
|
+
const first = seat === undefined ? 'ia position --shape governance' : governance(seat);
|
|
89
|
+
if (actor.refusal !== undefined && actor.subagent)
|
|
90
|
+
return deny('IA-HOOK-IDENTITY-UNAVAILABLE', actor.refusal, first);
|
|
91
|
+
if (governing.length === 0)
|
|
92
|
+
return freeze({
|
|
93
|
+
allowed: true,
|
|
94
|
+
selected: true,
|
|
95
|
+
message: `no authored @mandate governs ${paths[0]}, so ${hook.identity} restricts nothing there`,
|
|
96
|
+
...(actor.refusal === undefined && actor.agent !== undefined ? { actor: actor.agent } : {}),
|
|
97
|
+
});
|
|
98
|
+
if (actor.refusal !== undefined)
|
|
99
|
+
return deny('IA-HOOK-IDENTITY-UNAVAILABLE', actor.refusal, actor.next ?? first);
|
|
100
|
+
let verdict;
|
|
101
|
+
if (actor.agent === undefined) {
|
|
102
|
+
// No actor to bind: a mandate that names a participant cannot be satisfied, and only participant-less ones judge.
|
|
103
|
+
const named = governing.find((mandate) => mandate.participant !== undefined);
|
|
104
|
+
if (named !== undefined)
|
|
105
|
+
return deny('IA-HOOK-IDENTITY-UNAVAILABLE', `${actor.as}; ${named.identity} binds ${named.participant}`, governance(named.identity));
|
|
106
|
+
verdict = profileRefusal(governing, 'author');
|
|
107
|
+
}
|
|
108
|
+
else
|
|
109
|
+
verdict = profileRefusal(locate(actor.agent), 'author');
|
|
110
|
+
if (verdict.refusal !== undefined)
|
|
111
|
+
return deny('IA-HOOK-NOT-MANDATED', `${actor.as}; ${verdict.refusal.message}`, verdict.refusal.next, actor.agent);
|
|
112
|
+
return freeze({
|
|
113
|
+
allowed: true,
|
|
114
|
+
selected: true,
|
|
115
|
+
message: `${actor.as}, which a governing mandate allows to author here`,
|
|
116
|
+
...(actor.agent === undefined ? {} : { actor: actor.agent }),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
if (!(error instanceof RuntimeError))
|
|
121
|
+
throw error;
|
|
122
|
+
// Review D-R2: by its cause. A refused record a mandate resolution reads is shown by the admission report, not a
|
|
123
|
+
// position, which cannot seat at a refused record (or would seat at an admitted one of another band sharing its
|
|
124
|
+
// identity); `ia validate` and every other mandate-gated command refuse in that state. An admitted mandate whose
|
|
125
|
+
// authority the resolver cannot read is shown by its governance position.
|
|
126
|
+
const where = error.where, report = admissionReport(request.root), next = !isAdmissionRefusal(error) && where?.identity !== undefined ? governance(where.identity) : report.command, spelled = next === report.command && report.fromRoot ? `${next}, run from the workspace root` : next;
|
|
127
|
+
return freeze({
|
|
128
|
+
allowed: false,
|
|
129
|
+
selected: true,
|
|
130
|
+
code: 'IA-HOOK-MANDATE-UNAVAILABLE',
|
|
131
|
+
message: `${hook.message} (${hook.identity}: the mandates that govern this edit cannot be read: ${error.message}) Next: ${spelled}`,
|
|
132
|
+
next,
|
|
133
|
+
...(where === undefined ? {} : { where }),
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/** Characters a printed root may hold and stay inert unquoted in sh, PowerShell and cmd: letters, digits, `._-/:`. */
|
|
138
|
+
const INERT_ROOT = /^[\p{L}\p{N}._\-/:]+$/u;
|
|
139
|
+
/** Whether a known root can appear in a suggested shell command, double-quoted when it contains spaces. */
|
|
140
|
+
export function inertCommandRoot(root) {
|
|
141
|
+
// JSON-quoted UNC backslashes do not round-trip through native Windows shell argument handling.
|
|
142
|
+
if (root.startsWith('\\\\'))
|
|
143
|
+
return false;
|
|
144
|
+
const spelled = process.platform === 'win32' ? root.replaceAll('\\', '/') : root;
|
|
145
|
+
return /^[\p{L}\p{N}._\-/: ]+$/u.test(spelled);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Lane D, review findings D-R1 and D-N2: the admission report command (`ia report`, the version 1 machine route no
|
|
149
|
+
* mandate gates) for a workspace root, spelled so no shell reads anything in it. `root` is printed, with forward slashes
|
|
150
|
+
* on win32, only when every character is inert unquoted (`INERT_ROOT`); otherwise no path is printed and `fromRoot` says
|
|
151
|
+
* the command is run from the workspace root, where `ia report` opens the working directory. A root is never wrapped in
|
|
152
|
+
* double quotes, where `$` and backticks stay live.
|
|
153
|
+
*/
|
|
154
|
+
export function admissionReport(root) {
|
|
155
|
+
const spelled = root === undefined ? undefined : process.platform === 'win32' ? root.replaceAll('\\', '/') : root;
|
|
156
|
+
return spelled !== undefined && INERT_ROOT.test(spelled)
|
|
157
|
+
? freeze({ command: `ia report --root ${spelled}`, fromRoot: false })
|
|
158
|
+
: freeze({ command: 'ia report',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,gGAAgG;IAChG,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IAC1C,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACjF,OAAO,yBAAyB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACjD,CAAC;AACD;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,IAAa;IAC3C,MAAM,OAAO,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAClH,OAAO,OAAO,KAAK,SAAS,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC;QACtD,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,oBAAoB,OAAO,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QACrE,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;AACvD,CAAC"}
|
package/dist/mandate-modes.d.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import type { CompiledRecord } from '@inventarch/language';
|
|
2
|
+
import type { ReadHandle } from '@inventarch/db';
|
|
3
|
+
import { RuntimeError } from './errors.js';
|
|
2
4
|
import type { RuntimeCode } from './errors.js';
|
|
3
5
|
/**
|
|
4
6
|
* Mandate authority as closed moves (position-and-projection design, items 2c and 13).
|
|
5
7
|
*
|
|
6
8
|
* A `@mandate` may declare an `authority` section: the participant it binds, the moves it allows (closed to the five
|
|
7
9
|
* kernel moves), the workspaces it scopes, and the words and path selections it excludes or covers. This module
|
|
8
|
-
* publishes the CLI mode -> move table and the pure refusal check that the authoring verbs will consume
|
|
9
|
-
*
|
|
10
|
-
*
|
|
10
|
+
* publishes the CLI mode -> move table and the pure refusal check that the authoring verbs will consume, and resolves
|
|
11
|
+
* the authored mandates that govern an actor at a workspace or path, the actor a command acts as when none is named and
|
|
12
|
+
* the refusal profile those mandates give a mode (plan amendment C1). The CLI's profile module and the generated
|
|
13
|
+
* mandate guard consume these checks for their gated commands and host events. A mandate adds closed restrictions
|
|
14
|
+
* only; it never grants host permissions, and a mandate without
|
|
11
15
|
* `authority.moves` restricts no move.
|
|
12
16
|
*/
|
|
13
17
|
/** The five kernel moves, in kernel order. */
|
|
@@ -26,7 +30,7 @@ export type Mode = keyof typeof MODE_MOVES;
|
|
|
26
30
|
export declare const MODES: readonly Mode[];
|
|
27
31
|
export declare function isMode(value: unknown): value is Mode;
|
|
28
32
|
export type MandateCode = Extract<RuntimeCode, `IA-RUNTIME-MANDATE-${string}`>;
|
|
29
|
-
/** The refusal codes a mandate can return;
|
|
33
|
+
/** The refusal codes a mandate, a profile or the default actor can return; each is registered in RUNTIME_CODES. */
|
|
30
34
|
export declare const MANDATE_CODES: readonly MandateCode[];
|
|
31
35
|
/** The `authority` section of one compiled `@mandate`; an absent field is an absent restriction. */
|
|
32
36
|
export interface MandateAuthority {
|
|
@@ -57,4 +61,247 @@ export declare function mandateAuthorityOf(record: CompiledRecord): MandateAutho
|
|
|
57
61
|
* names the one catalog command that shows the mandate.
|
|
58
62
|
*/
|
|
59
63
|
export declare function mandateRefusal(mandate: MandateAuthority | CompiledRecord, mode: Mode, words?: readonly string[]): MandateRefusal | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Mandate resolution (plan amendment C1; operator decision OD1): one answer to "which `@mandate` governs this actor
|
|
66
|
+
* here" for the CLI's refusal profile and the edit guard. Every read goes through the scope token `within` and none
|
|
67
|
+
* needs a clean scope: a workspace with admission errors resolves the records admission admitted, except that an
|
|
68
|
+
* authored `@mandate` that failed admission fails every resolver closed (`refusedMandates`; lane D, operator ruling
|
|
69
|
+
* 2026-10-12). Only authored mandates (band 100) govern, only those of the workspace's closure as position reads it
|
|
70
|
+
* (plan amendment A8), and a record at runtime placement is never read.
|
|
71
|
+
*/
|
|
72
|
+
/** Lane D, D1: one authored `@mandate` that failed admission, and the admission finding that refused it. */
|
|
73
|
+
export interface RefusedMandate {
|
|
74
|
+
/**
|
|
75
|
+
* Its canonical identity, when db compiled the record or spec 3.1 names its parsed header; absent for a header only
|
|
76
|
+
* the source text shows.
|
|
77
|
+
*/
|
|
78
|
+
readonly identity?: string;
|
|
79
|
+
readonly path: string;
|
|
80
|
+
/** Its header line. */
|
|
81
|
+
readonly line: number;
|
|
82
|
+
/** The code and message of its own admission finding, as db records it (`UnadmittedRecord.finding`). */
|
|
83
|
+
readonly code: string;
|
|
84
|
+
readonly message: string;
|
|
85
|
+
/**
|
|
86
|
+
* Present when db cannot tell what the line declares (an error line of a file refused whole that no identified record
|
|
87
|
+
* accounts for; review D2-R2): it may be a mandate, so it counts as one.
|
|
88
|
+
*/
|
|
89
|
+
readonly unidentified?: true;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Lane D, D1: every `@mandate` of the workspace's own authored sources (band 100) that failed admission, frozen, by path
|
|
93
|
+
* then line, each with its own admission finding as db records it (db `unadmitted`): (a) one admission refused,
|
|
94
|
+
* `refused` naming it; (b) both occurrences of a mandate identity that ties at band 100; (c) one a file refused whole
|
|
95
|
+
* declares, by a language error or a duplicate requirement id, as db's own parse of the file reads its headers, or as
|
|
96
|
+
* its captured text shows a header the parse could not read, or a `@mandate` token on a line no parsed record spans and
|
|
97
|
+
* the language scanner does not read as a whole-line comment (db D15), so the attribution `ia author` writes is none
|
|
98
|
+
* outside the damaged files D15 names (a bare CR anywhere, the comment inside `"""` prose, a byte-order mark before it
|
|
99
|
+
* on line 1 with no pragma); and
|
|
100
|
+
* (d) review D2-R2: every record db cannot identify (db D15 lists it with no word, by the rules and limits D15 states),
|
|
101
|
+
* which may be a mandate, so it counts as one, marked `unidentified`, except at a line db also lists a mandate at, which
|
|
102
|
+
* is counted once, as that mandate (review D2 recheck F3). A record is a mandate when its word is `mandate` or its
|
|
103
|
+
* identity's facet is, or when db names no word. The band is the one db reads from the source's placement, as capture
|
|
104
|
+
* membership and governingMandates read it, so a mandate refused inside an installed base (band 90) never counts: it
|
|
105
|
+
* never governs.
|
|
106
|
+
*
|
|
107
|
+
* It reads db's root view, not a scope: a record admission refused belongs to no scope, and its scope, covers and
|
|
108
|
+
* participant cannot be trusted, so what it fails closed (D2) it fails closed workspace-wide.
|
|
109
|
+
*/
|
|
110
|
+
export declare function refusedMandates(reader: ReadHandle): readonly RefusedMandate[];
|
|
111
|
+
/**
|
|
112
|
+
* Lane D, D9: one admitted authored record a `@mandate` resolution reads whose typed reference names an authored record
|
|
113
|
+
* that failed admission: a `@mandate` whose `authority.participant` names a refused `@agent` (whom it binds) or whose
|
|
114
|
+
* `authority.scope` names a refused `@workspace` (where it governs), or a `@workspace` whose `composition.steward`
|
|
115
|
+
* names a refused `@agent` (the default actor every mandate there judges).
|
|
116
|
+
*/
|
|
117
|
+
export interface RefusedDependency {
|
|
118
|
+
/** The admitted authored record whose field names the refused one, a `@mandate` or a `@workspace`, by identity. */
|
|
119
|
+
readonly dependent: string;
|
|
120
|
+
readonly field: 'authority.participant' | 'authority.scope' | 'composition.steward';
|
|
121
|
+
/** The reference as authored, `@agent <name>` or `@workspace <name>`. */
|
|
122
|
+
readonly reference: string;
|
|
123
|
+
/** The refused record's identity, when db names one. */
|
|
124
|
+
readonly identity?: string;
|
|
125
|
+
/** Where the refused record is authored: its path and header line. */
|
|
126
|
+
readonly path: string;
|
|
127
|
+
readonly line: number;
|
|
128
|
+
/** The code and message of the refused record's own admission finding. */
|
|
129
|
+
readonly code: string;
|
|
130
|
+
readonly message: string;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Lane D, D9: every admitted authored (band 100) record whose resolution a refused authored record would change, frozen,
|
|
134
|
+
* by dependent identity, field, path and line: a `@mandate` whose `authority.participant` or `authority.scope`, or a
|
|
135
|
+
* `@workspace` whose `composition.steward`, names, as authored, an authored `@agent` or `@workspace` that failed
|
|
136
|
+
* admission (db `unadmitted`, band 100), matched by word and name, lowercased, so a tie, a schema refusal and a file
|
|
137
|
+
* refused whole all count. Admission drops the refused record, so that reference resolves to nothing, or to a record of
|
|
138
|
+
* another band, and the mandate silently binds no one, governs nowhere, or judges another default actor; the D8 probes
|
|
139
|
+
* showed each lifting a restriction. A reference no authored record answers at all, or one to a record refused in an
|
|
140
|
+
* installed base (band 90), is no dependency: it keeps today's reading. Neither is a refused `@agent` or `@workspace` no
|
|
141
|
+
* admitted mandate or workspace names. Like refusedMandates it reads db's root view, not a scope.
|
|
142
|
+
*/
|
|
143
|
+
export declare function refusedDependencies(reader: ReadHandle): readonly RefusedDependency[];
|
|
144
|
+
/**
|
|
145
|
+
* Review D-R2: whether `error` is the refusal `requireMandatesAdmitted` raises, an authored record a mandate resolution
|
|
146
|
+
* reads having failed admission, so a caller names the admission report and a hand edit, not a governance position
|
|
147
|
+
* (which, for a refused record that shares its identity with an admitted one of another band, would show that one).
|
|
148
|
+
*/
|
|
149
|
+
export declare function isAdmissionRefusal(error: unknown): error is RuntimeError & {
|
|
150
|
+
readonly admission: 'refused';
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Lane D, D2 and D9: IA-RUNTIME-REQUEST-INVALID, marked `admission: 'refused'` (`isAdmissionRefusal`), when any
|
|
154
|
+
* authored `@mandate` failed admission, or any record a mandate resolution depends on did (`refusedDependencies`). The
|
|
155
|
+
* decision reads db's root view, whatever `within` binds; what the error discloses does not (review D-N4, db PT5): through
|
|
156
|
+
* a whole-workspace token (`isCompleteScope`) it names the first refused mandate db identifies, else the first record
|
|
157
|
+
* db cannot identify (`unidentified`, review D2-R2), else the first dependency, the refused
|
|
158
|
+
* record located on the error as `where`, with its admission code and message; through a narrowed token it names no
|
|
159
|
+
* path, record or finding and carries no `where`. Every public resolver that reads a handle (governingMandates,
|
|
160
|
+
* seatedWorkspace and defaultActor) calls it first, after reading its token, so the CLI's profile and the edit guard fail
|
|
161
|
+
* closed rather than read a workspace whose restrictions a broken record may have lifted. An unknown or stale token keeps
|
|
162
|
+
* its database code.
|
|
163
|
+
*/
|
|
164
|
+
export declare function requireMandatesAdmitted(reader: ReadHandle, within: string): void;
|
|
165
|
+
/** Where governingMandates resolves, `workspace` and `path`, and for whom, `actor`. */
|
|
166
|
+
export interface GoverningOptions {
|
|
167
|
+
/**
|
|
168
|
+
* An admitted `@agent` identity: each governing mandate then says whether it `binds` the actor, and the actor's own
|
|
169
|
+
* mandates that state neither `authority.scope` nor `authority.covers` govern wherever it acts.
|
|
170
|
+
*/
|
|
171
|
+
readonly actor?: string;
|
|
172
|
+
/** A workspace-relative path: a mandate whose `authority.covers` selects it governs there (db D02b claimants). */
|
|
173
|
+
readonly path?: string;
|
|
174
|
+
/**
|
|
175
|
+
* An admitted `@workspace` identity: a mandate whose `authority.scope` names it governs there. Its closure is the one
|
|
176
|
+
* read; without it, that of the workspace position seats `path` in, or with no path the repository's own.
|
|
177
|
+
*/
|
|
178
|
+
readonly workspace?: string;
|
|
179
|
+
/**
|
|
180
|
+
* A key applied to `path` and to each `authority.covers` selection before they are matched (db `pathKey`, which the
|
|
181
|
+
* edit guard and the CLI's mandate profile pass): a mandate then claims the path when the G06c dialect selects
|
|
182
|
+
* `fold(path)` with `fold(selection)`. `pathKey` folds case on win32 and darwin whatever the volume, so there
|
|
183
|
+
* `DOCS/x.md` is under `covers ["docs/"]`, and on a case-sensitive directory a sibling spelled in another case is
|
|
184
|
+
* claimed too; on other platforms case is significant. Absent, the claims are db's G06c claimants, matched
|
|
185
|
+
* case-sensitively as the dialect defines them.
|
|
186
|
+
*/
|
|
187
|
+
readonly fold?: (text: string) => string;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* One authored `@mandate` that governs, its authority as mandateAuthorityOf reads it with the references resolved;
|
|
191
|
+
* `moves`, `covers` and `excludedWords` are present exactly when the record states the key (a declared empty list is
|
|
192
|
+
* stated), as the position packet renders them.
|
|
193
|
+
*/
|
|
194
|
+
export interface GoverningMandate {
|
|
195
|
+
readonly identity: string;
|
|
196
|
+
/** Only authored mandates govern. */
|
|
197
|
+
readonly band: 100;
|
|
198
|
+
/** The `@agent` identity `authority.participant` resolves to, or the reference as authored when none answers it. */
|
|
199
|
+
readonly participant?: string;
|
|
200
|
+
/**
|
|
201
|
+
* Present exactly when an `actor` is given: whether the mandate binds it, its participant resolving to the actor or
|
|
202
|
+
* naming none. One that does not governs here for another participant, and profileRefusal leaves it out.
|
|
203
|
+
*/
|
|
204
|
+
readonly binds?: boolean;
|
|
205
|
+
/** `authority.moves`; absent, the mandate restricts no move. */
|
|
206
|
+
readonly moves?: readonly Move[];
|
|
207
|
+
/** `authority.scope`: the `@workspace` identity each reference resolves to, or the reference as authored. */
|
|
208
|
+
readonly scope: readonly string[];
|
|
209
|
+
/** `authority.covers`, the path selections it claims. */
|
|
210
|
+
readonly covers?: readonly string[];
|
|
211
|
+
/** `authority.excluded-words`. */
|
|
212
|
+
readonly excludedWords?: readonly string[];
|
|
213
|
+
}
|
|
214
|
+
/** OD1: the actor a mandate-gated command acts as when none is named. */
|
|
215
|
+
export interface DefaultActor {
|
|
216
|
+
/** The `@agent` identity; absent when OD1 names none. */
|
|
217
|
+
readonly actor?: string;
|
|
218
|
+
/**
|
|
219
|
+
* What named it: the workspace's `composition.steward`, an authored `@agent`, or the one participant the workspace's
|
|
220
|
+
* mandates name.
|
|
221
|
+
*/
|
|
222
|
+
readonly by?: 'steward' | 'participant';
|
|
223
|
+
/**
|
|
224
|
+
* The authored `@agent` records an authored mandate of the workspace's closure scoped to it names as participant, by
|
|
225
|
+
* identity: the participants the position packet lists when K0 seats at the workspace (B3).
|
|
226
|
+
*/
|
|
227
|
+
readonly participants: readonly string[];
|
|
228
|
+
/**
|
|
229
|
+
* The `@agent` identities a command may be told to act as at the workspace, sorted: the participants and, when it is
|
|
230
|
+
* an authored `@agent`, the workspace's `composition.steward`, which may be no participant (review C2-R1).
|
|
231
|
+
*/
|
|
232
|
+
readonly actors: readonly string[];
|
|
233
|
+
/** Present exactly when `actor` is absent: why none is named, and the choice that would name one. */
|
|
234
|
+
readonly reason?: string;
|
|
235
|
+
/**
|
|
236
|
+
* Present exactly when several participants leave the choice open: IA-RUNTIME-MANDATE-ACTOR, which a mandate-gated
|
|
237
|
+
* command returns. With no participant there is none: the command's profile is resolved without an actor, every
|
|
238
|
+
* mandate that governs there judged, and it runs unrestricted, with profileRefusal's notice, only when none governs.
|
|
239
|
+
*/
|
|
240
|
+
readonly refusal?: MandateRefusal;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* What profileRefusal judges of one governing mandate; a GoverningMandate and a MandateAuthority are both one. A
|
|
244
|
+
* mandate whose `binds` is false governs for another participant: it is left out of the judgement, and `participant`
|
|
245
|
+
* names whom it binds. A named participant with no `binds` has no established actor and refuses every mode, even
|
|
246
|
+
* when it is the only participant. `binds: true` records the resolver's established actor binding.
|
|
247
|
+
*/
|
|
248
|
+
export type ProfileMandate = Pick<MandateAuthority, 'identity' | 'participant' | 'moves' | 'excludedWords'> & {
|
|
249
|
+
readonly binds?: boolean;
|
|
250
|
+
};
|
|
251
|
+
/** profileRefusal's verdict: the mode is allowed exactly when it holds no refusal. */
|
|
252
|
+
export interface ProfileVerdict {
|
|
253
|
+
/**
|
|
254
|
+
* Present when the governing mandates bind no actor here or several participants, or refuse the mode's move or a
|
|
255
|
+
* target word.
|
|
256
|
+
*/
|
|
257
|
+
readonly refusal?: MandateRefusal;
|
|
258
|
+
/** Present exactly when no mandate governs: nothing is restricted. */
|
|
259
|
+
readonly notice?: string;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* C1: the authored `@mandate` records that govern through the scope token `within`, by identity (each of band 100, so
|
|
263
|
+
* in C1's band-then-identity order). Only the closure of `workspace` is read, or without it that of the workspace
|
|
264
|
+
* position seats `path` in, or with neither the repository's own `@workspace`'s: another workspace's mandate never
|
|
265
|
+
* governs here. Only that closure is position's: for a path alone, the mandates that govern are those that claim it,
|
|
266
|
+
* not every mandate scoped to the seated workspace that position's location-seat governance also lists. With `workspace` or `path`, a mandate governs when its
|
|
267
|
+
* `authority.scope` names the workspace or its `authority.covers` selects the path (db D02b claimants), either one
|
|
268
|
+
* sufficing. One that states neither key with a value (a declared empty list locates nothing) is located by its participant alone and governs wherever that participant
|
|
269
|
+
* acts: with `actor`, when its participant is the actor; without one, whenever it names a participant. With neither
|
|
270
|
+
* `workspace` nor `path`, every one governs. `actor` drops no mandate that governs the workspace or path: each states
|
|
271
|
+
* whether it `binds` the actor, so profileRefusal judges the actor's own and those naming no participant, and refuses an
|
|
272
|
+
* actor that none of them binds rather than read the location as ungoverned. An `actor` or `workspace` that is not an
|
|
273
|
+
* admitted record of its word, or a governing mandate whose authority mandateAuthorityOf refuses, is
|
|
274
|
+
* IA-RUNTIME-REQUEST-INVALID; a mandate that does not govern is never read, however it is authored.
|
|
275
|
+
*/
|
|
276
|
+
export declare function governingMandates(reader: ReadHandle, within: string, options?: GoverningOptions): readonly GoverningMandate[];
|
|
277
|
+
/**
|
|
278
|
+
* The workspace position seats a workspace-relative `path` in (C1's closure for a path): the workspace whose declared root
|
|
279
|
+
* holds the seat's records, else the repository's own `@workspace`; undefined when no admitted `@workspace` holds it.
|
|
280
|
+
* Reads through the scope token `within`, as `governingMandates` does.
|
|
281
|
+
*/
|
|
282
|
+
export declare function seatedWorkspace(reader: ReadHandle, within: string, path: string): string | undefined;
|
|
283
|
+
/**
|
|
284
|
+
* OD1: the actor a mandate-gated command acts as at `workspace` when none is named. It is the `@agent` the workspace's
|
|
285
|
+
* `composition.steward` resolves to (ia init names its participant there), when that is an authored (band 100) record;
|
|
286
|
+
* failing that, the workspace's one participant, an authored `@agent` that an authored mandate of its closure scoped to
|
|
287
|
+
* it names. An installed steward names no actor, as if none were stated (review C2-R1). With several participants there
|
|
288
|
+
* is none, and the refusal names the choice; with none, there is no actor and no refusal, and the reason says whether
|
|
289
|
+
* the workspace states no steward, one that resolves to no admitted `@agent`, or one that is no authored `@agent`. A
|
|
290
|
+
* `workspace` that is not an admitted `@workspace` of the scope is IA-RUNTIME-REQUEST-INVALID.
|
|
291
|
+
*/
|
|
292
|
+
export declare function defaultActor(reader: ReadHandle, within: string, workspace: string): DefaultActor;
|
|
293
|
+
/**
|
|
294
|
+
* C1: the refusal profile the governing `mandates` give `mode` and its target `words`. A mandate whose `binds` is false
|
|
295
|
+
* governs for another participant and is left out; when every one is, no mandate here binds the actor, and the mode is
|
|
296
|
+
* IA-RUNTIME-MANDATE-ACTOR, naming whom each binds. The rest are never pooled across participants: when they name more
|
|
297
|
+
* than one, as they may without an actor, the mode is IA-RUNTIME-MANDATE-ACTOR too, naming each. A named participant
|
|
298
|
+
* without an established binding (`binds` absent) also refuses every mode, even when it is the only one. Then the move is
|
|
299
|
+
* judged: the mode is allowed when any mandate grants its move, by listing it or by declaring no moves, else
|
|
300
|
+
* IA-RUNTIME-MANDATE-MOVE. Then, only when words are given, a word any mandate excludes is IA-RUNTIME-MANDATE-WORD.
|
|
301
|
+
* Each refusal's `next` is the governance position of the first mandate it names (design §11), a read, which a command
|
|
302
|
+
* gated on this profile must leave ungated so that the refusal can be followed (an actor no mandate binds is refused
|
|
303
|
+
* every mode, read included). With no governing mandate nothing is restricted and the verdict holds a notice instead.
|
|
304
|
+
* An unknown mode, or a declared empty move list on any mandate, is IA-RUNTIME-REQUEST-INVALID.
|
|
305
|
+
*/
|
|
306
|
+
export declare function profileRefusal(mandates: readonly (ProfileMandate | CompiledRecord)[], mode: Mode, words?: readonly string[]): ProfileVerdict;
|
|
60
307
|
//# sourceMappingURL=mandate-modes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mandate-modes.d.ts","sourceRoot":"","s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