@astram/guard 0.31.0 → 0.33.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 (38) hide show
  1. package/README.md +25 -0
  2. package/dist/agent/agent-provenance.d.ts +24 -0
  3. package/dist/agent/agent-provenance.d.ts.map +1 -0
  4. package/dist/agent/agent-provenance.js +40 -0
  5. package/dist/authz/manifest-operation-authority-adapter.d.ts +9 -1
  6. package/dist/authz/manifest-operation-authority-adapter.d.ts.map +1 -1
  7. package/dist/authz/manifest-operation-authority-adapter.js +17 -1
  8. package/dist/authz/operation-marker-check.d.ts +12 -1
  9. package/dist/authz/operation-marker-check.d.ts.map +1 -1
  10. package/dist/authz/operation-marker-check.js +13 -1
  11. package/dist/authz/record-share-writer.d.ts +49 -11
  12. package/dist/authz/record-share-writer.d.ts.map +1 -1
  13. package/dist/authz/record-share-writer.js +68 -20
  14. package/dist/authz/wire-record-authorization.d.ts.map +1 -1
  15. package/dist/authz/wire-record-authorization.js +6 -4
  16. package/dist/config/app-config.d.ts +15 -3
  17. package/dist/config/app-config.d.ts.map +1 -1
  18. package/dist/config/app-config.js +12 -3
  19. package/dist/index.d.ts +4 -3
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +18 -4
  22. package/dist/internal.d.ts +6 -0
  23. package/dist/internal.d.ts.map +1 -1
  24. package/dist/internal.js +10 -1
  25. package/dist/module/shield-tokens.d.ts +164 -0
  26. package/dist/module/shield-tokens.d.ts.map +1 -1
  27. package/dist/module/shield-tokens.js +57 -1
  28. package/dist/module/shield.module.d.ts +17 -1
  29. package/dist/module/shield.module.d.ts.map +1 -1
  30. package/dist/module/shield.module.js +2 -2
  31. package/dist/notifications/notification.service.d.ts +2 -0
  32. package/dist/notifications/notification.service.d.ts.map +1 -1
  33. package/dist/notifications/notification.service.js +8 -0
  34. package/dist/storage/storage.providers.d.ts +36 -3
  35. package/dist/storage/storage.providers.d.ts.map +1 -1
  36. package/dist/storage/storage.providers.js +203 -3
  37. package/migrations/1710000000126-AddRecordShareSource.cjs +187 -0
  38. package/package.json +5 -5
package/README.md CHANGED
@@ -96,6 +96,31 @@ Framework code that runs inside a request but has no `req` in hand (for example
96
96
  supply a server-held tenant). Keep connector code in Nest handlers or boot-started jobs.
97
97
  - In memory only: no database or Redis read is added to the request path (Shield #12).
98
98
 
99
+ ## File-share port token (`SHIELD_FILE_SHARE`, GAPS #57)
100
+
101
+ `src/module/shield-tokens.ts` declares the port so guard never imports identity (ADR-0003);
102
+ `@astram/identity` binds it per request. Spec `docs/features/file-share-port/SPEC.md` v1, ADR-0040
103
+ addendum (2026-11-03).
104
+
105
+ - Exports: `SHIELD_FILE_SHARE` (a `Symbol`, unbound without identity), `FileSharePort`
106
+ (`shareWithRole`, `unshare`, `revokeForParent`, `listForParent`, `reconcileFile`; no actor,
107
+ tenant, owner or company argument), `FileShareParent` (`{ typeKey, id }`), `FileShareResult`
108
+ (`{ created, effective, missing }`), `FileShareError`, `FILE_SHARE_ERROR_CODES`,
109
+ `FileShareErrorCode`.
110
+ - `FileShareError(code)` takes only the code, so its message never carries an id, file name or
111
+ table: `file_share_invalid` 400 `Invalid file share request.`, `file_share_not_found` 404
112
+ `Not found.`, `file_share_denied` 403 `Not permitted.`, `file_share_unavailable` 503
113
+ `File sharing is unavailable.`; an unknown code becomes `file_share_unavailable`.
114
+ - Migration `1710000000126-AddRecordShareSource.cjs` adds the source columns
115
+ (`rs_source_type_key`, `rs_source_record_uuid`, `rs_source_operation`, `''` for owner shares),
116
+ `ck_rs_source_complete`, `uq_rs_grant_source` (replaces `uq_rs_grant`) and `idx_rs_source`;
117
+ `down` refuses while a port row exists.
118
+ - `RecordShareWriter`: owner `unshare` deletes owner-made rows only and refuses a tuple that
119
+ matches only port rows with `ShareNotPermittedError(SHARE_MANAGED_BY_LINKED_RECORD)` (`This
120
+ share is managed by a linked record.`); list rows (`RecordShareRow`) carry the source fields;
121
+ `listSharesForAuthorizedRecord` lists a record's shares without the owner bound, for a caller that
122
+ has already proven authority with `decide()` (identity's stored-file admin listing).
123
+
99
124
  ## Peer dependencies (ADR-0023 §2)
100
125
 
101
126
  `@astram/guard` **peer-depends** on the host runtime so the consumer owns exactly
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Agent provenance (agent-proposals SPEC v7 §5 E, plan D-9): the ONLY way a proposal is recorded
3
+ * as `origin: 'agent'`. Reviewers and audit rely on that label, so trusted app server code must
4
+ * not be able to put it on a person's proposal through the public `SHIELD_PROPOSAL_PORT`.
5
+ *
6
+ * ⛔ UNFORGEABLE, like engine `bindOperation`. A minted provenance lives in a module-private
7
+ * WeakSet keyed by the frozen object {@link mintAgentProvenance} returned. A spread, JSON or
8
+ * structural copy is a different object and carries nothing, so a literal
9
+ * `{ origin: 'agent', taskId, callId }` built by app code is refused by identity's submit
10
+ * (`forbidden`). Exported from `@astram/guard/internal` only, never the guard root barrel: only
11
+ * the agent executor mints; identity reads {@link isMintedAgentProvenance}.
12
+ */
13
+ /** The longest task or call id a provenance carries (identity `proposal.service.ts` `IDS_MAX`). */
14
+ export declare const AGENT_PROVENANCE_ID_MAX = 64;
15
+ export interface AgentProvenance {
16
+ readonly origin: 'agent';
17
+ readonly taskId: string;
18
+ readonly callId: string;
19
+ }
20
+ /** Mint an agent provenance for the executing call. Returns a NEW frozen, registered object. */
21
+ export declare function mintAgentProvenance(taskId: string, callId: string): AgentProvenance;
22
+ /** `true` only for the exact object {@link mintAgentProvenance} returned. */
23
+ export declare function isMintedAgentProvenance(p: unknown): p is AgentProvenance;
24
+ //# sourceMappingURL=agent-provenance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-provenance.d.ts","sourceRoot":"","sources":["../../src/agent/agent-provenance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,mGAAmG;AACnG,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAaD,gGAAgG;AAChG,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,eAAe,CAQnF;AAED,6EAA6E;AAC7E,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,eAAe,CAExE"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ /**
3
+ * Agent provenance (agent-proposals SPEC v7 §5 E, plan D-9): the ONLY way a proposal is recorded
4
+ * as `origin: 'agent'`. Reviewers and audit rely on that label, so trusted app server code must
5
+ * not be able to put it on a person's proposal through the public `SHIELD_PROPOSAL_PORT`.
6
+ *
7
+ * ⛔ UNFORGEABLE, like engine `bindOperation`. A minted provenance lives in a module-private
8
+ * WeakSet keyed by the frozen object {@link mintAgentProvenance} returned. A spread, JSON or
9
+ * structural copy is a different object and carries nothing, so a literal
10
+ * `{ origin: 'agent', taskId, callId }` built by app code is refused by identity's submit
11
+ * (`forbidden`). Exported from `@astram/guard/internal` only, never the guard root barrel: only
12
+ * the agent executor mints; identity reads {@link isMintedAgentProvenance}.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.AGENT_PROVENANCE_ID_MAX = void 0;
16
+ exports.mintAgentProvenance = mintAgentProvenance;
17
+ exports.isMintedAgentProvenance = isMintedAgentProvenance;
18
+ /** The longest task or call id a provenance carries (identity `proposal.service.ts` `IDS_MAX`). */
19
+ exports.AGENT_PROVENANCE_ID_MAX = 64;
20
+ const minted = new WeakSet();
21
+ function requireId(name, value) {
22
+ if (typeof value !== 'string' || value.length === 0 || value.length > exports.AGENT_PROVENANCE_ID_MAX) {
23
+ throw new TypeError(`mintAgentProvenance: ${name} must be a string of 1-${exports.AGENT_PROVENANCE_ID_MAX} characters`);
24
+ }
25
+ return value;
26
+ }
27
+ /** Mint an agent provenance for the executing call. Returns a NEW frozen, registered object. */
28
+ function mintAgentProvenance(taskId, callId) {
29
+ const provenance = Object.freeze({
30
+ origin: 'agent',
31
+ taskId: requireId('taskId', taskId),
32
+ callId: requireId('callId', callId),
33
+ });
34
+ minted.add(provenance);
35
+ return provenance;
36
+ }
37
+ /** `true` only for the exact object {@link mintAgentProvenance} returned. */
38
+ function isMintedAgentProvenance(p) {
39
+ return typeof p === 'object' && p !== null && minted.has(p);
40
+ }
@@ -17,7 +17,8 @@
17
17
  * ── THE MANIFEST: `${operationKey}:${stepKey}` → {@link DelegatedAuthority}. The consumer
18
18
  * DECLARES it by constructing the adapter with a map (or `[key, authority]` entries). An
19
19
  * UNKNOWN key ⇒ `undefined` (pass-through: NO delegation — evaluate under the caller — the
20
- * common case).
20
+ * common case). Plan D-5: that pass-through holds only for an UNBOUND principal; the wired
21
+ * `withOperationMarkerCheck` denies a principal bound to a step {@link declaresStep} rejects.
21
22
  *
22
23
  * ── FAIL-CLOSED ON A MALFORMED / WILDCARD ENTRY. Core's gate-7 overlay re-checks scope with
23
24
  * strict membership, but this adapter NEVER hands back a wildcard or malformed authority: a
@@ -61,5 +62,12 @@ export declare class ManifestOperationAuthorityAdapter implements OperationAutho
61
62
  */
62
63
  constructor(entries?: readonly OperationManifestEntry[]);
63
64
  resolveDelegatedAuthority(operationKey: string, stepKey: string): DelegatedAuthority | undefined;
65
+ /**
66
+ * Agent-proposals plan D-5: whether `operationKey` + `stepKey` is a DECLARED, well-formed step
67
+ * (a dropped wildcard / malformed entry is not). `withOperationMarkerCheck` denies every decision
68
+ * of a principal bound (`bindOperation`) to a step this returns `false` for, so an unknown step,
69
+ * or an undeclared operation, never falls back to the user's own grants at gate 7.
70
+ */
71
+ declaresStep(operationKey: string, stepKey: string): boolean;
64
72
  }
65
73
  //# sourceMappingURL=manifest-operation-authority-adapter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"manifest-operation-authority-adapter.d.ts","sourceRoot":"","sources":["../../src/authz/manifest-operation-authority-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAE/E,yFAAyF;AACzF,eAAO,MAAM,+BAA+B,eAA4C,CAAC;AAEzF;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,kEAAkE;IAClE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,uDAAuD;IACvD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,sEAAsE;IACtE,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CAAC;CACxC;AA6BD,qBAAa,iCAAkC,YAAW,sBAAsB;IAC9E,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkC;IAE3D;;;;;OAKG;gBACS,OAAO,GAAE,SAAS,sBAAsB,EAAO;IAuB3D,yBAAyB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;CAajG"}
1
+ {"version":3,"file":"manifest-operation-authority-adapter.d.ts","sourceRoot":"","sources":["../../src/authz/manifest-operation-authority-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAE/E,yFAAyF;AACzF,eAAO,MAAM,+BAA+B,eAA4C,CAAC;AAEzF;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,kEAAkE;IAClE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,uDAAuD;IACvD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,sEAAsE;IACtE,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CAAC;CACxC;AA6BD,qBAAa,iCAAkC,YAAW,sBAAsB;IAC9E,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkC;IAE3D;;;;;OAKG;gBACS,OAAO,GAAE,SAAS,sBAAsB,EAAO;IAuB3D,yBAAyB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAchG;;;;;OAKG;IACH,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO;CAW7D"}
@@ -18,7 +18,8 @@
18
18
  * ── THE MANIFEST: `${operationKey}:${stepKey}` → {@link DelegatedAuthority}. The consumer
19
19
  * DECLARES it by constructing the adapter with a map (or `[key, authority]` entries). An
20
20
  * UNKNOWN key ⇒ `undefined` (pass-through: NO delegation — evaluate under the caller — the
21
- * common case).
21
+ * common case). Plan D-5: that pass-through holds only for an UNBOUND principal; the wired
22
+ * `withOperationMarkerCheck` denies a principal bound to a step {@link declaresStep} rejects.
22
23
  *
23
24
  * ── FAIL-CLOSED ON A MALFORMED / WILDCARD ENTRY. Core's gate-7 overlay re-checks scope with
24
25
  * strict membership, but this adapter NEVER hands back a wildcard or malformed authority: a
@@ -104,5 +105,20 @@ class ManifestOperationAuthorityAdapter {
104
105
  // absent key ⇒ undefined (pass-through: no delegation, the common case).
105
106
  return this.manifest.get(manifestKey(operationKey, stepKey));
106
107
  }
108
+ /**
109
+ * Agent-proposals plan D-5: whether `operationKey` + `stepKey` is a DECLARED, well-formed step
110
+ * (a dropped wildcard / malformed entry is not). `withOperationMarkerCheck` denies every decision
111
+ * of a principal bound (`bindOperation`) to a step this returns `false` for, so an unknown step,
112
+ * or an undeclared operation, never falls back to the user's own grants at gate 7.
113
+ */
114
+ declaresStep(operationKey, stepKey) {
115
+ if (typeof operationKey !== 'string' ||
116
+ operationKey.length === 0 ||
117
+ typeof stepKey !== 'string' ||
118
+ stepKey.length === 0) {
119
+ return false;
120
+ }
121
+ return this.manifest.has(manifestKey(operationKey, stepKey));
122
+ }
107
123
  }
108
124
  exports.ManifestOperationAuthorityAdapter = ManifestOperationAuthorityAdapter;
@@ -14,7 +14,18 @@
14
14
  * (`isEngineSeparationOfDutiesFacts`, a module-private WeakSet) passes. Any other value is
15
15
  * removed, so a bound action then fails closed (`separation_of_duties_unverified`) instead of a
16
16
  * forged empty set skipping the rule.
17
+ *
18
+ * Agent-proposals plan D-5 (stricter than SPEC v7): gate 7 overrides only for a step the manifest
19
+ * declares; for any other step it passes through, so the baseline (the user's own grants) would
20
+ * decide. Given `declared` (the wired `ManifestOperationAuthorityAdapter`), a principal BOUND to
21
+ * an operation step the manifest does not declare (an unknown step of a declared operation, or an
22
+ * undeclared operation key) is DENIED here, before the inner `decide()` runs: a fixed, frozen
23
+ * `missing_object_type_grant` / `operation_step_not_declared`, whatever the marker or the grants.
17
24
  */
18
25
  import type { DecisionAuthority } from '@astram/core';
19
- export declare function withOperationMarkerCheck(inner: DecisionAuthority): DecisionAuthority;
26
+ /** The declared steps of every operation (the wired manifest adapter implements it). */
27
+ export interface DeclaredOperationSteps {
28
+ declaresStep(operationKey: string, stepKey: string): boolean;
29
+ }
30
+ export declare function withOperationMarkerCheck(inner: DecisionAuthority, declared?: DeclaredOperationSteps): DecisionAuthority;
20
31
  //# sourceMappingURL=operation-marker-check.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"operation-marker-check.d.ts","sourceRoot":"","sources":["../../src/authz/operation-marker-check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAMtD,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,iBAAiB,GAAG,iBAAiB,CA2BpF"}
1
+ {"version":3,"file":"operation-marker-check.d.ts","sourceRoot":"","sources":["../../src/authz/operation-marker-check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,KAAK,EAAY,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAMhE,wFAAwF;AACxF,MAAM,WAAW,sBAAsB;IACrC,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;CAC9D;AASD,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,iBAAiB,EACxB,QAAQ,CAAC,EAAE,sBAAsB,GAChC,iBAAiB,CAiCnB"}
@@ -4,9 +4,21 @@ exports.withOperationMarkerCheck = withOperationMarkerCheck;
4
4
  const engine_1 = require("@astram/engine");
5
5
  const MARKER = 'shield.delegation';
6
6
  const SOD_FACTS = 'shield.separationOfDuties';
7
- function withOperationMarkerCheck(inner) {
7
+ /** Plan D-5: the one decision for a principal bound to an undeclared operation step. */
8
+ const UNDECLARED_STEP_DENY = Object.freeze({
9
+ effect: 'deny',
10
+ reason: 'missing_object_type_grant',
11
+ detail: 'operation_step_not_declared',
12
+ });
13
+ function withOperationMarkerCheck(inner, declared) {
8
14
  return {
9
15
  decide: (principal, action, resource, context) => {
16
+ if (declared !== undefined) {
17
+ const bound = (0, engine_1.operationOf)(principal);
18
+ if (bound !== undefined && !declared.declaresStep(bound.operationKey, bound.stepKey)) {
19
+ return Promise.resolve(UNDECLARED_STEP_DENY);
20
+ }
21
+ }
10
22
  const attributes = context.attributes;
11
23
  if (attributes === undefined || !(MARKER in attributes || SOD_FACTS in attributes)) {
12
24
  return inner.decide(principal, action, resource, context);
@@ -27,10 +27,12 @@
27
27
  * the request principal, NOT from a user-controlled body field. The writer never
28
28
  * trusts an owner id in `input`; it fetches the owner and compares against `sharerId`.
29
29
  *
30
- * ── ON PASS: an IDEMPOTENT INSERT into `record_share` (the UNIQUE index on
31
- * (tenant, type, record, grantee_kind, grantee_uuid, action) makes a repeat share of the
32
- * same tuple a no-op via `INSERT ... ON DUPLICATE KEY UPDATE`). `unshare` DELETEs the
33
- * matching row(s). Every share/unshare emits an audit event via the injected
30
+ * ── ON PASS: an IDEMPOTENT INSERT into `record_share` (the UNIQUE index `uq_rs_grant_source` on
31
+ * (tenant, type, record, grantee_kind, grantee_uuid, action, source type, source record),
32
+ * migration 126; an owner share leaves the source columns at their `''` default, so a repeat
33
+ * share of the same tuple stays a no-op via `INSERT ... ON DUPLICATE KEY UPDATE`). `unshare`
34
+ * DELETEs the matching OWNER-MADE row(s) only; rows made through the file-share port are
35
+ * read-only here (file-share-port SPEC §5 E). Every share/unshare emits an audit event via the injected
34
36
  * {@link ShareAuditSink} (best-effort; a sink error never fails the operation). NO raw
35
37
  * uuid appears in a human-readable audit MESSAGE — ids ride in structured fields only.
36
38
  *
@@ -117,6 +119,27 @@ export interface ShareInput {
117
119
  */
118
120
  readonly sharerId: string;
119
121
  }
122
+ /**
123
+ * The one fixed text of an owner `unshare` whose tuple matches only rows made through the
124
+ * file-share port (file-share-port SPEC §5 E, §10; supervisor 2026-11-03). It never names or hints
125
+ * at the parent record (type, id or label): the same text for every such tuple.
126
+ */
127
+ export declare const SHARE_MANAGED_BY_LINKED_RECORD = "This share is managed by a linked record.";
128
+ /**
129
+ * One share row as the owner listing returns it. The three source fields are `''` for an
130
+ * owner-made share; a port-made row (file-share-port SPEC §4 A) carries the parent type key, the
131
+ * parent record id and the operation (`shield:file-share`). Identity labels port rows from them and
132
+ * never shows the parent id (SPEC §5 E).
133
+ */
134
+ export interface RecordShareRow {
135
+ readonly granteeKind: ShareGranteeKind;
136
+ readonly granteeUuid: string;
137
+ readonly action: string;
138
+ readonly grantedBy: string;
139
+ readonly sourceTypeKey: string;
140
+ readonly sourceRecordId: string;
141
+ readonly sourceOperation: string;
142
+ }
120
143
  /** Thrown when the who-may-share bound rejects a share/unshare (fail-closed). */
121
144
  export declare class ShareNotPermittedError extends Error {
122
145
  constructor(message: string);
@@ -153,7 +176,13 @@ export declare class RecordShareWriter {
153
176
  /**
154
177
  * Remove a share. The SAME owner bound applies — only the owner of the record may revoke
155
178
  * a share on it (a grantee cannot unshare a record they don't own). DELETEs the matching
156
- * row(s); a no-match delete is a benign no-op. Emits `share.removed` on success.
179
+ * owner-made row(s) only; a no-match delete is a benign no-op. Emits `share.removed` on success.
180
+ *
181
+ * file-share-port SPEC §5 E, §6: rows made through the file-share port (non-empty source) are
182
+ * read-only here. A tuple that matches only port rows is refused with
183
+ * {@link SHARE_MANAGED_BY_LINKED_RECORD} (403 at the route), nothing deleted and nothing
184
+ * audited; when owner and port rows both match, only the owner row is removed. Port rows are
185
+ * removed only through the port.
157
186
  */
158
187
  unshare(input: ShareInput): Promise<void>;
159
188
  /**
@@ -172,12 +201,21 @@ export declare class RecordShareWriter {
172
201
  typeKey: string;
173
202
  recordId: string;
174
203
  sharerId: string;
175
- }): Promise<ReadonlyArray<{
176
- granteeKind: ShareGranteeKind;
177
- granteeUuid: string;
178
- action: string;
179
- grantedBy: string;
180
- }>>;
204
+ }): Promise<ReadonlyArray<RecordShareRow>>;
205
+ /**
206
+ * List the shares on a record WITHOUT the owner bound, for a caller that has already proven its
207
+ * authority over the record with `decide()` (file-share-port SPEC §5 E: identity calls it for a
208
+ * `stored_file` only after `records.authorize('stored_file', id, 'update')` allows — an admin of
209
+ * that file). Tenant + type + record scoped exactly like {@link listSharesForRecord}; never a
210
+ * write. The caller supplies `tenantId` from the request principal, never from input.
211
+ */
212
+ listSharesForAuthorizedRecord(input: {
213
+ tenantId: string;
214
+ typeKey: string;
215
+ recordId: string;
216
+ }): Promise<ReadonlyArray<RecordShareRow>>;
217
+ /** The share rows of one record in one tenant, oldest first, source columns included. */
218
+ private selectShares;
181
219
  /**
182
220
  * Enforce the §6.2 who-may-share bound (steps 1–3) and return the resolved type info.
183
221
  * Fetches the record owner tenant-scoped and proves `sharerId` owns it. Throws
@@ -1 +1 @@
1
- {"version":3,"file":"record-share-writer.d.ts","sourceRoot":"","sources":["../../src/authz/record-share-writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAGxE,8CAA8C;A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c,CAAC;QACvB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,+DAA+D;QAC/D,KAAK,CAAC,EAAE,MAAM,MAAM,CAAC;KACtB;IAUD;;;;;;;;OAQG;IACG,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IA8B7C;;;;;;;;;;OAUG;IACG,OAAO,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAiD/C;;;;;;;;;;OAUG;IACG,mBAAmB,CAAC,KAAK,EAAE;QAC/B,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;IAgB1C;;;;;;OAMG;IACG,6BAA6B,CAAC,KAAK,EAAE;QACzC,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;IAI1C,yFAAyF;YAC3E,YAAY;IA0C1B;;;;OAIG;YACW,cAAc;IAoC5B;;;;OAIG;YACW,sBAAsB;IA6BpC,OAAO,CAAC,cAAc;IAItB,sFAAsF;YACxE,IAAI;CAsBnB"}
@@ -28,10 +28,12 @@
28
28
  * the request principal, NOT from a user-controlled body field. The writer never
29
29
  * trusts an owner id in `input`; it fetches the owner and compares against `sharerId`.
30
30
  *
31
- * ── ON PASS: an IDEMPOTENT INSERT into `record_share` (the UNIQUE index on
32
- * (tenant, type, record, grantee_kind, grantee_uuid, action) makes a repeat share of the
33
- * same tuple a no-op via `INSERT ... ON DUPLICATE KEY UPDATE`). `unshare` DELETEs the
34
- * matching row(s). Every share/unshare emits an audit event via the injected
31
+ * ── ON PASS: an IDEMPOTENT INSERT into `record_share` (the UNIQUE index `uq_rs_grant_source` on
32
+ * (tenant, type, record, grantee_kind, grantee_uuid, action, source type, source record),
33
+ * migration 126; an owner share leaves the source columns at their `''` default, so a repeat
34
+ * share of the same tuple stays a no-op via `INSERT ... ON DUPLICATE KEY UPDATE`). `unshare`
35
+ * DELETEs the matching OWNER-MADE row(s) only; rows made through the file-share port are
36
+ * read-only here (file-share-port SPEC §5 E). Every share/unshare emits an audit event via the injected
35
37
  * {@link ShareAuditSink} (best-effort; a sink error never fails the operation). NO raw
36
38
  * uuid appears in a human-readable audit MESSAGE — ids ride in structured fields only.
37
39
  *
@@ -40,11 +42,17 @@
40
42
  * record outside the sharer's tenant is "not found" ⇒ rejected at step 2.
41
43
  */
42
44
  Object.defineProperty(exports, "__esModule", { value: true });
43
- exports.RecordShareWriter = exports.ShareStoreUnavailableError = exports.ShareNotPermittedError = exports.SHIELD_RECORD_SHARE_WRITER = void 0;
45
+ exports.RecordShareWriter = exports.ShareStoreUnavailableError = exports.ShareNotPermittedError = exports.SHARE_MANAGED_BY_LINKED_RECORD = exports.SHIELD_RECORD_SHARE_WRITER = void 0;
44
46
  const node_crypto_1 = require("node:crypto");
45
47
  const framework_schema_names_js_1 = require("../config/framework-schema-names.js");
46
48
  /** The DI token the writer is bound under. */
47
49
  exports.SHIELD_RECORD_SHARE_WRITER = Symbol('SHIELD_RECORD_SHARE_WRITER');
50
+ /**
51
+ * The one fixed text of an owner `unshare` whose tuple matches only rows made through the
52
+ * file-share port (file-share-port SPEC §5 E, §10; supervisor 2026-11-03). It never names or hints
53
+ * at the parent record (type, id or label): the same text for every such tuple.
54
+ */
55
+ exports.SHARE_MANAGED_BY_LINKED_RECORD = 'This share is managed by a linked record.';
48
56
  /** Thrown when the who-may-share bound rejects a share/unshare (fail-closed). */
49
57
  class ShareNotPermittedError extends Error {
50
58
  constructor(message) {
@@ -113,25 +121,46 @@ class RecordShareWriter {
113
121
  /**
114
122
  * Remove a share. The SAME owner bound applies — only the owner of the record may revoke
115
123
  * a share on it (a grantee cannot unshare a record they don't own). DELETEs the matching
116
- * row(s); a no-match delete is a benign no-op. Emits `share.removed` on success.
124
+ * owner-made row(s) only; a no-match delete is a benign no-op. Emits `share.removed` on success.
125
+ *
126
+ * file-share-port SPEC §5 E, §6: rows made through the file-share port (non-empty source) are
127
+ * read-only here. A tuple that matches only port rows is refused with
128
+ * {@link SHARE_MANAGED_BY_LINKED_RECORD} (403 at the route), nothing deleted and nothing
129
+ * audited; when owner and port rows both match, only the owner row is removed. Port rows are
130
+ * removed only through the port.
117
131
  */
118
132
  async unshare(input) {
119
133
  await this.assertMayShare(input);
134
+ const tuple = [
135
+ input.tenantId,
136
+ input.typeKey,
137
+ input.recordId,
138
+ input.granteeKind,
139
+ input.granteeUuid,
140
+ input.action,
141
+ ];
142
+ const tupleWhere = ` WHERE rs_tenant_uuid = ?` +
143
+ ` AND rs_type_key = ?` +
144
+ ` AND rs_record_uuid = ?` +
145
+ ` AND rs_grantee_kind = ?` +
146
+ ` AND rs_grantee_uuid = ?` +
147
+ ` AND rs_action = ?`;
148
+ let sources;
149
+ try {
150
+ sources = (await this.db.query(`SELECT rs_source_type_key FROM \`${this.schema}\`.\`record_share\`` + tupleWhere, tuple));
151
+ }
152
+ catch (err) {
153
+ throw new ShareStoreUnavailableError(`record_share read failed for ${input.typeKey}: ${err.message}`);
154
+ }
155
+ const rows = Array.isArray(sources) ? sources : [];
156
+ const isPortRow = (r) => typeof r.rs_source_type_key === 'string' && r.rs_source_type_key !== '';
157
+ if (rows.length > 0 && rows.every(isPortRow)) {
158
+ throw new ShareNotPermittedError(exports.SHARE_MANAGED_BY_LINKED_RECORD);
159
+ }
120
160
  try {
121
161
  await this.db.query(`DELETE FROM \`${this.schema}\`.\`record_share\`` +
122
- ` WHERE rs_tenant_uuid = ?` +
123
- ` AND rs_type_key = ?` +
124
- ` AND rs_record_uuid = ?` +
125
- ` AND rs_grantee_kind = ?` +
126
- ` AND rs_grantee_uuid = ?` +
127
- ` AND rs_action = ?`, [
128
- input.tenantId,
129
- input.typeKey,
130
- input.recordId,
131
- input.granteeKind,
132
- input.granteeUuid,
133
- input.action,
134
- ]);
162
+ tupleWhere +
163
+ ` AND rs_source_type_key = ''`, tuple);
135
164
  }
136
165
  catch (err) {
137
166
  throw new ShareStoreUnavailableError(`record_share delete failed for ${input.typeKey}: ${err.message}`);
@@ -162,9 +191,24 @@ class RecordShareWriter {
162
191
  granteeUuid: '',
163
192
  action: '',
164
193
  });
194
+ return this.selectShares(input);
195
+ }
196
+ /**
197
+ * List the shares on a record WITHOUT the owner bound, for a caller that has already proven its
198
+ * authority over the record with `decide()` (file-share-port SPEC §5 E: identity calls it for a
199
+ * `stored_file` only after `records.authorize('stored_file', id, 'update')` allows — an admin of
200
+ * that file). Tenant + type + record scoped exactly like {@link listSharesForRecord}; never a
201
+ * write. The caller supplies `tenantId` from the request principal, never from input.
202
+ */
203
+ async listSharesForAuthorizedRecord(input) {
204
+ return this.selectShares(input);
205
+ }
206
+ /** The share rows of one record in one tenant, oldest first, source columns included. */
207
+ async selectShares(input) {
165
208
  let rows;
166
209
  try {
167
- rows = (await this.db.query(`SELECT rs_grantee_kind, rs_grantee_uuid, rs_action, rs_granted_by` +
210
+ rows = (await this.db.query(`SELECT rs_grantee_kind, rs_grantee_uuid, rs_action, rs_granted_by,` +
211
+ ` rs_source_type_key, rs_source_record_uuid, rs_source_operation` +
168
212
  ` FROM \`${this.schema}\`.\`record_share\`` +
169
213
  ` WHERE rs_tenant_uuid = ? AND rs_type_key = ? AND rs_record_uuid = ?` +
170
214
  ` ORDER BY rs_created_at`, [input.tenantId, input.typeKey, input.recordId]));
@@ -172,11 +216,15 @@ class RecordShareWriter {
172
216
  catch (err) {
173
217
  throw new ShareStoreUnavailableError(`record_share list failed for ${input.typeKey}: ${err.message}`);
174
218
  }
219
+ const text = (v) => (typeof v === 'string' ? v : '');
175
220
  return rows.map((r) => ({
176
221
  granteeKind: r.rs_grantee_kind === 'role' ? 'role' : 'user',
177
222
  granteeUuid: r.rs_grantee_uuid,
178
223
  action: r.rs_action,
179
224
  grantedBy: r.rs_granted_by,
225
+ sourceTypeKey: text(r.rs_source_type_key),
226
+ sourceRecordId: text(r.rs_source_record_uuid),
227
+ sourceOperation: text(r.rs_source_operation),
180
228
  }));
181
229
  }
182
230
  // --- the bound -------------------------------------------------------------
@@ -1 +1 @@
1
- {"version":3,"file":"wire-record-authorization.d.ts","sourceRoot":"","sources":["../../src/authz/wire-record-authorization.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,KAAK,EACV,iBAAiB,EAEjB,cAAc,EAEd,mBAAmB,EACnB,SAAS,EAET,kBAAkB,EACnB,MAAM,cAAc,CAAC;AAMtB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,kCAAkC,CAAC;AAO1C,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,2CAA2C,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,uFAAuF;IACvF,QAAQ,CAAC,eAAe,EAAE,mBAAmB,CAAC;IAC9C,6FAA6F;IAC7F,QAAQ,CAAC,YAAY,EAAE,kBAAkB,CAAC;IAC1C,6GAA6G;IAC7G,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC;;;;;OAKG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,sBAAsB,EAAE,CAAC;IAC/D;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,oBAAoB,CAAC;CACzC;AAOD;;;;;GAKG;AACH;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,mBAAmB,EACzB,KAAK,EAAE,uBAAuB,GAC7B,mBAAmB,CA2BrB;AAED,6EAA6E;AAC7E,MAAM,WAAW,+BAA+B;IAC9C;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,uBAAuB,CAAC;CACjD;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,yBAAyB,EACjC,OAAO,GAAE,+BAAoC,GAC5C,iBAAiB,CA8BnB;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,WAAW,GAAG,CACxB,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,MAAM,KACX,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,EAAE,CAAA;CAAE,CAAC,CAAC;AAEjD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,yBAAyB,GAAG,WAAW,CA2F/E"}
1
+ {"version":3,"file":"wire-record-authorization.d.ts","sourceRoot":"","sources":["../../src/authz/wire-record-authorization.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,KAAK,EACV,iBAAiB,EAEjB,cAAc,EAEd,mBAAmB,EACnB,SAAS,EAET,kBAAkB,EACnB,MAAM,cAAc,CAAC;AAMtB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,kCAAkC,CAAC;AAO1C,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,2CAA2C,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,uFAAuF;IACvF,QAAQ,CAAC,eAAe,EAAE,mBAAmB,CAAC;IAC9C,6FAA6F;IAC7F,QAAQ,CAAC,YAAY,EAAE,kBAAkB,CAAC;IAC1C,6GAA6G;IAC7G,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC;;;;;OAKG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,sBAAsB,EAAE,CAAC;IAC/D;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,oBAAoB,CAAC;CACzC;AAOD;;;;;GAKG;AACH;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,mBAAmB,EACzB,KAAK,EAAE,uBAAuB,GAC7B,mBAAmB,CA2BrB;AAED,6EAA6E;AAC7E,MAAM,WAAW,+BAA+B;IAC9C;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,uBAAuB,CAAC;CACjD;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,yBAAyB,EACjC,OAAO,GAAE,+BAAoC,GAC5C,iBAAiB,CAiCnB;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,WAAW,GAAG,CACxB,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,MAAM,KACX,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,EAAE,CAAA;CAAE,CAAC,CAAC;AAEjD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,yBAAyB,GAAG,WAAW,CA2F/E"}
@@ -74,6 +74,10 @@ function buildRecordAuthorization(inputs, options = {}) {
74
74
  ? withRedisPermissionVersion(inputs.permissionFacts, options.versionCache)
75
75
  : inputs.permissionFacts;
76
76
  const schema = authzSchemaOf(inputs);
77
+ // Delegation / trusted-operation authority over the DECLARED manifest (no DB). Empty ⇒
78
+ // pass-through. The app supplies the entries; the framework owns the adapter. The marker check
79
+ // also uses it (plan D-5): a principal bound to an undeclared step is denied outright.
80
+ const operationAuthority = new manifest_operation_authority_adapter_js_1.ManifestOperationAuthorityAdapter(inputs.operationManifest ?? []);
77
81
  return (0, operation_marker_check_js_1.withOperationMarkerCheck)((0, core_1.createWiredDecisionAuthority)({
78
82
  registry: inputs.registry,
79
83
  // The app-owned port, wrapped so a gate-5 reload inside an enforcement request notifies the
@@ -92,10 +96,8 @@ function buildRecordAuthorization(inputs, options = {}) {
92
96
  // Cross-tenant consented grants over `shield_authz.cross_tenant_grant`. No active
93
97
  // grant ⇒ null (deny-by-default for the cross-tenant reach).
94
98
  crossTenantGrant: new mariadb_cross_tenant_grant_adapter_js_1.MariaDbCrossTenantGrantAdapter(inputs.pool, { schema }),
95
- // Delegation / trusted-operation authority over the DECLARED manifest (no DB).
96
- // Empty ⇒ pass-through. The app supplies the entries; the framework owns the adapter.
97
- operationAuthority: new manifest_operation_authority_adapter_js_1.ManifestOperationAuthorityAdapter(inputs.operationManifest ?? []),
98
- }));
99
+ operationAuthority,
100
+ }), operationAuthority);
99
101
  }
100
102
  /**
101
103
  * Construct the engine-facing {@link ListScopeFn} — the LIST-form sibling to
@@ -11,7 +11,8 @@
11
11
  *
12
12
  * ─────────────────────────────────────────────────────────────────────────────
13
13
  * ADR-0018 budget (the invariant this config feeds):
14
- * workers × (Σ(per-account RUNTIME pool max) + 1 audit sealer) + headroom ≤ maxConnections
14
+ * workers × (Σ(per-account RUNTIME pool max) + 1 audit sealer + 2 engine lock probe) + headroom
15
+ * ≤ maxConnections
15
16
  *
16
17
  * "Runtime" pools are the pools each PM2 cluster worker holds open: shield_core,
17
18
  * shield_app_crud, shield_schema_svc. The deploy/ops accounts (migrate, backup,
@@ -20,7 +21,9 @@
20
21
  *
21
22
  * Defaults below agree byte-for-byte with infra/mariadb/conf.d/my.cnf
22
23
  * (max_connections=250) and the local docker-compose substrate:
23
- * 8 × (12 + 8 + 1 + 1 sealer) + 40 = 216 ≤ 250 ✓ (G-026: the sealer's own 1-connection pool)
24
+ * 8 × (12 + 8 + 1 + 1 sealer + 2 lock probe) + 40 = 232 ≤ 250 ✓ (G-026: the sealer's own
25
+ * 1-connection pool; agent-proposals SPEC §5 J: the engine lock-probe pool's 2)
26
+ * Single layout defaults: 8 × (12 + 10 + 4 + 1 + 2) + 40 = 272 > 250 (size the host's budget).
24
27
  * ─────────────────────────────────────────────────────────────────────────────
25
28
  */
26
29
  import type { FrameworkSchemas, SecretsProvider } from '@astram/core';
@@ -261,6 +264,12 @@ export declare function poolTuningOf(config: Pick<AppConfig, 'poolTuning'>): Poo
261
264
  * in the budget (5.F), whether or not `auth: true` starts the sealer.
262
265
  */
263
266
  export declare const AUDIT_SEALER_POOL_CONNECTIONS = 1;
267
+ /**
268
+ * The engine lock-probe pool (agent-proposals SPEC §5 J, FW-R1/1): two connections per worker on
269
+ * the engine's runtime account (same config as the engine pool), always counted in the budget in
270
+ * both layouts, next to the sealer's. Must equal `@astram/engine`'s `LOCK_PROBE_POOL_CONNECTIONS`.
271
+ */
272
+ export declare const ENGINE_LOCK_PROBE_POOL_CONNECTIONS = 2;
264
273
  /**
265
274
  * Build the {@link PoolBudgetConfig} from env with documented defaults.
266
275
  * Field ↔ env name:
@@ -441,7 +450,10 @@ export declare const DEFAULT_OBJECT_STORAGE_MAX_BYTES: number;
441
450
  export declare function loadObjectStorageConfig(env?: NodeJS.ProcessEnv, options?: LoadObjectStorageConfigOptions): ObjectStorageConfig | undefined;
442
451
  /** Result of evaluating a {@link PoolBudgetConfig} against the ADR-0018 budget. */
443
452
  export interface PoolBudgetEvaluation {
444
- /** Σ(per-account runtime pool max) + the audit sealer's 1, for a single worker. */
453
+ /**
454
+ * Σ(per-account runtime pool max) + the audit sealer's 1 + the engine lock-probe pool's 2, for a
455
+ * single worker.
456
+ */
445
457
  readonly perWorkerConnections: number;
446
458
  /** workers × perWorkerConnections — total runtime connections at full load. */
447
459
  readonly runtimeConnections: number;
@@ -1 +1 @@
1
- {"version":3,"file":"app-config.d.ts","sourceRoot":"","sources":["../../src/config/app-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAWtE,MAAM,WAAW,SAAS;IACxB,yCAAyC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,QAAQ,CAAC,WAAW,EAAE,aAAa,GAAG,MAAM,GAAG,YAAY,CAAC;IAC5D,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAGhC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,EAAE,wBAAwB,CAAC;IAC7C;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAC3C;;;;;OAKG;IACH,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IACxC;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IACpC;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;CAClC;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,GAAG,gBAAgB,CAEvF;AAED,2FAA2F;AAC3F,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,sEAAsE;AAC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
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_OBJECT_STORAGE_MAX_BYTES = exports.DEFAULT_REDIS_URL = exports.DEFAULT_DB_CONFIG = exports.AUDIT_SEALER_POOL_CONNECTIONS = exports.DEFAULT_POOL_IDLE_TIMEOUT_S = exports.DEFAULT_POOL_MIN_IDLE = exports.SCHEMA_SVC_POOL_HARD_CAP = exports.DEFAULT_POOL_BUDGET = exports.DEFAULT_REDIS_COMMAND_TIMEOUT_MS = exports.DEFAULT_LOGIN_IP_LIMIT = void 0;
3
+ exports.DEFAULT_OBJECT_STORAGE_MAX_BYTES = exports.DEFAULT_REDIS_URL = exports.DEFAULT_DB_CONFIG = exports.ENGINE_LOCK_PROBE_POOL_CONNECTIONS = exports.AUDIT_SEALER_POOL_CONNECTIONS = exports.DEFAULT_POOL_IDLE_TIMEOUT_S = exports.DEFAULT_POOL_MIN_IDLE = exports.SCHEMA_SVC_POOL_HARD_CAP = exports.DEFAULT_POOL_BUDGET = exports.DEFAULT_REDIS_COMMAND_TIMEOUT_MS = exports.DEFAULT_LOGIN_IP_LIMIT = void 0;
4
4
  exports.frameworkSchemasOf = frameworkSchemasOf;
5
5
  exports.isDevOrTestNodeEnv = isDevOrTestNodeEnv;
6
6
  exports.loadPoolTuning = loadPoolTuning;
@@ -146,6 +146,12 @@ function poolTuningOf(config) {
146
146
  * in the budget (5.F), whether or not `auth: true` starts the sealer.
147
147
  */
148
148
  exports.AUDIT_SEALER_POOL_CONNECTIONS = 1;
149
+ /**
150
+ * The engine lock-probe pool (agent-proposals SPEC §5 J, FW-R1/1): two connections per worker on
151
+ * the engine's runtime account (same config as the engine pool), always counted in the budget in
152
+ * both layouts, next to the sealer's. Must equal `@astram/engine`'s `LOCK_PROBE_POOL_CONNECTIONS`.
153
+ */
154
+ exports.ENGINE_LOCK_PROBE_POOL_CONNECTIONS = 2;
149
155
  /**
150
156
  * Build the {@link PoolBudgetConfig} from env with documented defaults.
151
157
  * Field ↔ env name:
@@ -528,12 +534,15 @@ function parseStorageMaxBytes(raw) {
528
534
  */
529
535
  function evaluatePoolBudget(cfg) {
530
536
  // Single layout (AC-12): one account opens core + engine + authz; app_crud/schema_svc are never opened.
531
- // Both layouts add the audit sealer's own pool (G-026 spec 5.F: 1 per worker, always counted).
537
+ // Both layouts add the audit sealer's own pool (G-026 spec 5.F: 1 per worker, always counted) and
538
+ // the engine lock-probe pool (agent-proposals SPEC §5 J: 2 per worker, always counted).
532
539
  const perWorkerConnections = (cfg.layout === 'single'
533
540
  ? cfg.perAccountMax.shield_core + (cfg.engineMax ?? 10) + (cfg.authzMax ?? 4)
534
541
  : cfg.perAccountMax.shield_core +
535
542
  cfg.perAccountMax.shield_app_crud +
536
- cfg.perAccountMax.shield_schema_svc) + exports.AUDIT_SEALER_POOL_CONNECTIONS;
543
+ cfg.perAccountMax.shield_schema_svc) +
544
+ exports.AUDIT_SEALER_POOL_CONNECTIONS +
545
+ exports.ENGINE_LOCK_PROBE_POOL_CONNECTIONS;
537
546
  const runtimeConnections = cfg.workers * perWorkerConnections;
538
547
  const requiredConnections = runtimeConnections + cfg.headroom;
539
548
  const slack = cfg.maxConnections - requiredConnections;