@sentropic/artifacts 0.2.13 → 0.2.15

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 (52) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/adapters/local-blob.d.ts +3 -0
  3. package/dist/adapters/local-blob.js +93 -0
  4. package/dist/adapters/postgres-uploads.d.ts +14 -0
  5. package/dist/adapters/postgres-uploads.js +174 -0
  6. package/dist/adapters/s3.js +23 -0
  7. package/dist/adapters/sqlite-activation.d.ts +20 -0
  8. package/dist/adapters/sqlite-activation.js +205 -0
  9. package/dist/adapters/sqlite-commit.d.ts +15 -0
  10. package/dist/adapters/sqlite-commit.js +89 -0
  11. package/dist/adapters/sqlite-management.d.ts +10 -0
  12. package/dist/adapters/sqlite-management.js +60 -0
  13. package/dist/adapters/sqlite-sql.d.ts +32 -0
  14. package/dist/adapters/sqlite-sql.js +36 -0
  15. package/dist/adapters/sqlite-store.d.ts +12 -0
  16. package/dist/adapters/sqlite-store.js +410 -0
  17. package/dist/adapters/sqlite.d.ts +33 -0
  18. package/dist/adapters/sqlite.js +95 -0
  19. package/dist/content/handler.d.ts +5 -0
  20. package/dist/content/handler.js +80 -9
  21. package/dist/http.d.ts +16 -0
  22. package/dist/http.js +435 -97
  23. package/dist/mcp-core.d.ts +3 -3
  24. package/dist/mcp-core.js +43 -4
  25. package/dist/profile/contracts.d.ts +1 -1
  26. package/dist/profile/contracts.js +4 -0
  27. package/dist/profile/index.js +12 -2
  28. package/dist/profile/schemas.js +60 -0
  29. package/dist/profile/validation.js +31 -4
  30. package/dist/server/command-identity.d.ts +1 -1
  31. package/dist/server/command-identity.js +4 -3
  32. package/dist/server/gc.d.ts +28 -3
  33. package/dist/server/gc.js +81 -5
  34. package/dist/server/management.js +10 -5
  35. package/dist/server/metrics.d.ts +21 -0
  36. package/dist/server/metrics.js +6 -0
  37. package/dist/server/ports.d.ts +7 -0
  38. package/dist/server/ports.js +7 -0
  39. package/dist/server/publication-limits.d.ts +8 -0
  40. package/dist/server/publication-limits.js +8 -0
  41. package/dist/server/publication.d.ts +5 -0
  42. package/dist/server/publication.js +6 -0
  43. package/dist/server/source-read.d.ts +12 -9
  44. package/dist/server/source-read.js +17 -5
  45. package/dist/server/upload-page.d.ts +157 -0
  46. package/dist/server/upload-page.js +438 -0
  47. package/dist/server/uploads.d.ts +75 -1
  48. package/dist/server/uploads.js +187 -27
  49. package/migrations/0009_upload_pages.sql +25 -0
  50. package/package.json +13 -1
  51. package/sql/sqlite/0001_artifacts.sql +156 -0
  52. package/sql/sqlite/0002_activation.sql +73 -0
@@ -10,8 +10,8 @@ export { createRadarKeyDerivation } from './server/command-identity.js';
10
10
  export type { ArtifactKeyDerivationBinding } from './server/command-identity.js';
11
11
  export declare const ARTIFACTS_PROVIDER_ID = "sentropic.artifacts";
12
12
  export declare const ARTIFACTS_APP_ID = "sentropic-artifacts";
13
- export declare const ARTIFACTS_PROVIDER_VERSION = "0.2.13";
14
- export declare const ARTIFACTS_TOOL_NAMES: readonly ["artifacts_get_template", "artifacts_get_api_guide", "artifacts_ensure", "artifacts_publish", "artifacts_create_upload", "artifacts_commit_upload", "artifacts_list", "artifacts_get", "artifacts_get_source", "artifacts_fork", "artifacts_set_access", "artifacts_promote", "artifacts_renew", "artifacts_delete", "artifacts_restore", "artifacts_list_versions", "artifacts_revert", "artifacts_lookup_people", "artifacts_list_access", "artifacts_publish_bundle", "artifacts_revoke_reader_consent"];
13
+ export declare const ARTIFACTS_PROVIDER_VERSION = "0.2.15";
14
+ export declare const ARTIFACTS_TOOL_NAMES: readonly ["artifacts_get_template", "artifacts_get_api_guide", "artifacts_ensure", "artifacts_publish", "artifacts_create_upload", "artifacts_commit_upload", "artifacts_list", "artifacts_get", "artifacts_get_source", "artifacts_fork", "artifacts_set_access", "artifacts_promote", "artifacts_renew", "artifacts_delete", "artifacts_restore", "artifacts_list_versions", "artifacts_revert", "artifacts_lookup_people", "artifacts_list_access", "artifacts_publish_bundle", "artifacts_revoke_reader_consent", "artifacts_create_upload_page", "artifacts_list_assets", "artifacts_publish_bundle_v2"];
15
15
  export type ArtifactsToolName = (typeof ARTIFACTS_TOOL_NAMES)[number];
16
16
  export interface ArtifactsToolDefinition {
17
17
  readonly description: string;
@@ -24,7 +24,7 @@ export interface ArtifactsToolDefinition {
24
24
  /** Static wire definitions for every artifacts tool; identical across deployments and profiles. */
25
25
  export declare const ARTIFACTS_TOOL_DEFINITIONS: Readonly<Record<ArtifactsToolName, ArtifactsToolDefinition>>;
26
26
  export declare const ARTIFACTS_TOOL_SPECS: {
27
- name: "artifacts_get_template" | "artifacts_get_api_guide" | "artifacts_ensure" | "artifacts_publish" | "artifacts_create_upload" | "artifacts_commit_upload" | "artifacts_list" | "artifacts_get" | "artifacts_get_source" | "artifacts_fork" | "artifacts_set_access" | "artifacts_promote" | "artifacts_renew" | "artifacts_delete" | "artifacts_restore" | "artifacts_list_versions" | "artifacts_revert" | "artifacts_lookup_people" | "artifacts_list_access" | "artifacts_publish_bundle" | "artifacts_revoke_reader_consent";
27
+ name: "artifacts_get_template" | "artifacts_get_api_guide" | "artifacts_ensure" | "artifacts_publish" | "artifacts_create_upload" | "artifacts_commit_upload" | "artifacts_list" | "artifacts_get" | "artifacts_get_source" | "artifacts_fork" | "artifacts_set_access" | "artifacts_promote" | "artifacts_renew" | "artifacts_delete" | "artifacts_restore" | "artifacts_list_versions" | "artifacts_revert" | "artifacts_lookup_people" | "artifacts_list_access" | "artifacts_publish_bundle" | "artifacts_revoke_reader_consent" | "artifacts_create_upload_page" | "artifacts_list_assets" | "artifacts_publish_bundle_v2";
28
28
  description: string;
29
29
  mutability: import("@sentropic/mcp-platform").Mutability;
30
30
  }[];
package/dist/mcp-core.js CHANGED
@@ -6,7 +6,7 @@ export * from './profile/index.js';
6
6
  export { createRadarKeyDerivation } from './server/command-identity.js';
7
7
  export const ARTIFACTS_PROVIDER_ID = 'sentropic.artifacts';
8
8
  export const ARTIFACTS_APP_ID = 'sentropic-artifacts';
9
- export const ARTIFACTS_PROVIDER_VERSION = '0.2.13';
9
+ export const ARTIFACTS_PROVIDER_VERSION = '0.2.15';
10
10
  export const ARTIFACTS_TOOL_NAMES = ARTIFACT_CAPABILITY_NAMES;
11
11
  // ---------------------------------------------------------------------------
12
12
  // Byte-stable tool definitions (MCP tool-definition stability rule).
@@ -47,9 +47,10 @@ const idOnly = obj({ artifactId: id }, ['artifactId']);
47
47
  const ARTIFACTS_OUTPUT_SCHEMA = { type: 'object', additionalProperties: true };
48
48
  const READ_ONLY_TOOLS = ['artifacts_list', 'artifacts_get',
49
49
  'artifacts_get_template', 'artifacts_get_api_guide', 'artifacts_get_source', 'artifacts_list_versions',
50
- 'artifacts_lookup_people', 'artifacts_list_access'];
50
+ 'artifacts_lookup_people', 'artifacts_list_access', 'artifacts_list_assets'];
51
51
  const IDEMPOTENT_WRITERS = ['artifacts_ensure', 'artifacts_publish',
52
- 'artifacts_commit_upload', 'artifacts_publish_bundle', 'artifacts_set_access', 'artifacts_delete', 'artifacts_revert',
52
+ 'artifacts_commit_upload', 'artifacts_publish_bundle', 'artifacts_publish_bundle_v2',
53
+ 'artifacts_set_access', 'artifacts_delete', 'artifacts_revert',
53
54
  'artifacts_revoke_reader_consent'];
54
55
  function staticTool(name, inputSchema, description) {
55
56
  return {
@@ -57,7 +58,8 @@ function staticTool(name, inputSchema, description) {
57
58
  inputSchema,
58
59
  outputSchema: ARTIFACTS_OUTPUT_SCHEMA,
59
60
  mutability: READ_ONLY_TOOLS.includes(name) ? 'read-only'
60
- : name === 'artifacts_publish' || name === 'artifacts_publish_bundle' ? 'append' : 'state-transition',
61
+ : name === 'artifacts_publish' || name === 'artifacts_publish_bundle' ||
62
+ name === 'artifacts_publish_bundle_v2' ? 'append' : 'state-transition',
61
63
  idempotency: IDEMPOTENT_WRITERS.includes(name) ? { required: true, scope: 'principal' } : { required: false },
62
64
  gates: { requiresElicitation: false, requiresHumanConfirmation: name === 'artifacts_delete',
63
65
  requiresPrincipalGate: false },
@@ -129,6 +131,34 @@ export const ARTIFACTS_TOOL_DEFINITIONS = {
129
131
  artifacts_revoke_reader_consent: staticTool('artifacts_revoke_reader_consent', obj({ artifactId: id,
130
132
  scope: { type: 'string', minLength: 1, maxLength: 128 }, idempotencyKey }, ['artifactId', 'idempotencyKey']), 'Artifacts revoke reader consent: withdraw persistent consent of the caller for one scope of one artifact, '
131
133
  + 'or for every scope when scope is omitted. Self-revocation only; the next call asks again.'),
134
+ // Files parity LOT 2 — appended last; frozen at birth like every definition above.
135
+ artifacts_create_upload_page: staticTool('artifacts_create_upload_page', obj({ artifactId: id,
136
+ maxFiles: integer(1, 255) }, ['artifactId']), 'Artifacts create upload page: mint a short-lived browser upload page for one artifact. '
137
+ + 'The user provides files from their own disk; bytes travel browser to S3 directly and never cross the model. '
138
+ + 'List staged files with artifacts_list_assets, then publish with artifacts_publish_bundle.'),
139
+ artifacts_list_assets: staticTool('artifacts_list_assets', obj({ artifactId: id, releaseId: id,
140
+ state: { type: 'string', enum: ['staged', 'released', 'all'] }, pageSessionId: id,
141
+ limit: integer(1, 255), cursor: { ...str, maxLength: 4096 } }, ['artifactId']), 'Artifacts list assets: released assets from a manifest, staged assets from committed uploads, '
142
+ + 'optionally filtered by browser upload page. Released listing needs the source read right; '
143
+ + 'staged listing is owner-only.'),
144
+ artifacts_publish_bundle_v2: staticTool('artifacts_publish_bundle_v2', { ...obj({
145
+ artifactId: id, idempotencyKey,
146
+ files: { type: 'array', items: file, minItems: 1,
147
+ description: 'Inline files (bytes travel through the model, inline budget); at least one of files/assets is required.' },
148
+ assets: { type: 'array', minItems: 1,
149
+ items: { oneOf: [
150
+ obj({ path, uploadId: id }, ['path', 'uploadId']),
151
+ obj({ path, digest: { type: 'string', pattern: '^sha256:[0-9a-f]{64}$' }, size: integer(1), mimeType: str }, ['path', 'digest', 'size', 'mimeType']),
152
+ obj({ path, sourceArtifactId: id, sourcePath: path, sourceReleaseId: id }, ['path', 'sourceArtifactId']),
153
+ obj({ path, carryFromReleaseId: id, sourcePath: path }, ['path', 'carryFromReleaseId']),
154
+ ] },
155
+ description: 'Assets whose bytes already left the model: a staged uploadId, a CAS digest, a copy from the same scope, or a carry from a release of this artifact. Set keepUnmodifiedPaths to carry every other path of the expected release.' },
156
+ keepUnmodifiedPaths: { type: 'boolean' },
157
+ expectedCurrentReleaseId, profile: primitiveRecord, ...metadata
158
+ }, ['artifactId', 'idempotencyKey', 'expectedCurrentReleaseId']),
159
+ anyOf: [{ required: ['files'] }, { required: ['assets'] }] }, 'Artifacts publish bundle v2: like artifacts_publish_bundle, plus copies from other artifacts of the same scope '
160
+ + 'and carries from releases of this artifact, with optional keep-unmodified carry. expectedCurrentReleaseId '
161
+ + 'is always required (CAS); null requires an unpublished artifact.'),
132
162
  };
133
163
  export const ARTIFACTS_TOOL_SPECS = ARTIFACTS_TOOL_NAMES.map((name) => ({ name,
134
164
  description: ARTIFACTS_TOOL_DEFINITIONS[name].description,
@@ -187,6 +217,15 @@ export function createArtifactsToolExecutor(deps) {
187
217
  case 'artifacts_publish_bundle':
188
218
  request = { method: 'POST', path: '/publish_bundle', body: args };
189
219
  break;
220
+ case 'artifacts_publish_bundle_v2':
221
+ request = { method: 'POST', path: '/publish_bundle_v2', body: args };
222
+ break;
223
+ case 'artifacts_list_assets':
224
+ request = { method: 'POST', path: '/list_assets', body: args };
225
+ break;
226
+ case 'artifacts_create_upload_page':
227
+ request = { method: 'POST', path: '/uploads/page', body: args };
228
+ break;
190
229
  case 'artifacts_create_upload':
191
230
  request = { method: 'POST', path: '/uploads/create', body: args };
192
231
  break;
@@ -1,7 +1,7 @@
1
1
  import type { JsonValue } from '../contracts.js';
2
2
  import type { EffectiveArtifactCommand } from '../server/command-identity.js';
3
3
  export declare const PROFILE_CONTRACT_VERSION: "artifacts-profile/v1";
4
- export declare const ARTIFACT_CAPABILITY_NAMES: readonly ["artifacts_get_template", "artifacts_get_api_guide", "artifacts_ensure", "artifacts_publish", "artifacts_create_upload", "artifacts_commit_upload", "artifacts_list", "artifacts_get", "artifacts_get_source", "artifacts_fork", "artifacts_set_access", "artifacts_promote", "artifacts_renew", "artifacts_delete", "artifacts_restore", "artifacts_list_versions", "artifacts_revert", "artifacts_lookup_people", "artifacts_list_access", "artifacts_publish_bundle", "artifacts_revoke_reader_consent"];
4
+ export declare const ARTIFACT_CAPABILITY_NAMES: readonly ["artifacts_get_template", "artifacts_get_api_guide", "artifacts_ensure", "artifacts_publish", "artifacts_create_upload", "artifacts_commit_upload", "artifacts_list", "artifacts_get", "artifacts_get_source", "artifacts_fork", "artifacts_set_access", "artifacts_promote", "artifacts_renew", "artifacts_delete", "artifacts_restore", "artifacts_list_versions", "artifacts_revert", "artifacts_lookup_people", "artifacts_list_access", "artifacts_publish_bundle", "artifacts_revoke_reader_consent", "artifacts_create_upload_page", "artifacts_list_assets", "artifacts_publish_bundle_v2"];
5
5
  export type ArtifactCapabilityName = (typeof ARTIFACT_CAPABILITY_NAMES)[number];
6
6
  export type ArtifactSchema = Readonly<Record<string, unknown>>;
7
7
  export interface OperationProfile {
@@ -8,6 +8,10 @@ export const ARTIFACT_CAPABILITY_NAMES = [
8
8
  'artifacts_lookup_people', 'artifacts_list_access',
9
9
  'artifacts_publish_bundle',
10
10
  'artifacts_revoke_reader_consent',
11
+ // Files parity LOT 2 — appended last; frozen at birth like every definition above.
12
+ 'artifacts_create_upload_page',
13
+ 'artifacts_list_assets',
14
+ 'artifacts_publish_bundle_v2',
11
15
  ];
12
16
  /** Projection fields are data-only; invocation correlation is added by L6. */
13
17
  export const PRECONDITION_REQUIRED_MESSAGE = 'expectedCurrentReleaseId is required by the active artifact profile. Re-read this artifact with artifacts_get or artifacts_list, then send expectedCurrentReleaseId using the currentReleaseId returned by that read. Send null only if the read confirms that there is no current release. Before editing an existing release, read it with artifacts_get_source and use that releaseId. The server will not infer this value.';
@@ -1,6 +1,6 @@
1
1
  import { isArtifactId } from '../contracts.js';
2
2
  import { isWithinMimeCeiling } from '../server/mime.js';
3
- import { SERVER_MAX_FILE_BYTES, SERVER_MAX_FILES_PER_RELEASE, SERVER_MAX_TOTAL_BYTES } from '../server/publication-limits.js';
3
+ import { SERVER_MAX_FILE_BYTES, SERVER_MAX_FILES_PER_RELEASE, SERVER_MAX_SOURCE_FILES, SERVER_MAX_SOURCE_INLINE_BYTES, SERVER_MAX_SOURCE_TOTAL_BYTES, SERVER_MAX_TOTAL_BYTES } from '../server/publication-limits.js';
4
4
  import { ARTIFACT_CAPABILITY_NAMES, ArtifactProfileInputError, PROFILE_CONTRACT_VERSION } from './contracts.js';
5
5
  import { copyJson, freezeDeep, isRecord, orderedDigest } from './json.js';
6
6
  import { assertCompleteOperation, capabilitySchema } from './schemas.js';
@@ -73,6 +73,9 @@ export function compileArtifactsProfile(input) {
73
73
  releaseFileBytesMax: SERVER_MAX_FILE_BYTES,
74
74
  maxDecodedTotalBytes: SERVER_MAX_TOTAL_BYTES,
75
75
  releaseTotalBytesMax: SERVER_MAX_TOTAL_BYTES,
76
+ sourceFilesMax: SERVER_MAX_SOURCE_FILES,
77
+ sourceInlineFileBytesMax: SERVER_MAX_SOURCE_INLINE_BYTES,
78
+ sourceTotalBytesMax: SERVER_MAX_SOURCE_TOTAL_BYTES,
76
79
  };
77
80
  for (const [key, ceiling] of Object.entries(limitCeilings)) {
78
81
  if (op.limits[key] !== undefined && op.limits[key] > ceiling) {
@@ -121,7 +124,8 @@ export function compileArtifactsProfile(input) {
121
124
  if (!Object.hasOwn(props, key) || !matchesSchema(value, props[key]))
122
125
  throw new Error('profile/schema default mismatch');
123
126
  }
124
- if (['artifacts_ensure', 'artifacts_publish', 'artifacts_commit_upload', 'artifacts_publish_bundle', 'artifacts_set_access', 'artifacts_delete', 'artifacts_revert'].includes(name)) {
127
+ if (['artifacts_ensure', 'artifacts_publish', 'artifacts_commit_upload', 'artifacts_publish_bundle',
128
+ 'artifacts_publish_bundle_v2', 'artifacts_set_access', 'artifacts_delete', 'artifacts_revert'].includes(name)) {
125
129
  idempotency[name] = { required: true, scope: 'principal' };
126
130
  }
127
131
  }
@@ -148,10 +152,16 @@ export function compileArtifactsProfile(input) {
148
152
  name = 'artifacts_publish';
149
153
  if (method === 'POST' && path === '/publish_bundle')
150
154
  name = 'artifacts_publish_bundle';
155
+ if (method === 'POST' && path === '/publish_bundle_v2')
156
+ name = 'artifacts_publish_bundle_v2';
151
157
  if (method === 'POST' && path === '/uploads/create')
152
158
  name = 'artifacts_create_upload';
153
159
  if (method === 'POST' && path === '/uploads/commit')
154
160
  name = 'artifacts_commit_upload';
161
+ if (method === 'POST' && path === '/uploads/page')
162
+ name = 'artifacts_create_upload_page';
163
+ if (method === 'POST' && path === '/list_assets')
164
+ name = 'artifacts_list_assets';
155
165
  if (method === 'POST' && path === '/list')
156
166
  name = 'artifacts_list';
157
167
  if (method === 'POST' && path === '/get_source')
@@ -27,6 +27,9 @@ export function assertCompleteOperation(config) {
27
27
  list: { limits: ['listLimitMin', 'listLimitMax'], defaults: ['limit', 'offset'] },
28
28
  commit_upload: { limits: ['idempotencyKeyMaxUnits'], defaults: ['profile'] },
29
29
  publish_bundle: { limits: ['idempotencyKeyMaxUnits'], defaults: ['profile'] },
30
+ create_upload_page: { limits: [], defaults: [] },
31
+ list_assets: { limits: ['listAssetsLimitMin', 'listAssetsLimitMax'], defaults: ['limit'] },
32
+ publish_bundle_v2: { limits: ['idempotencyKeyMaxUnits'], defaults: ['profile'] },
30
33
  set_access: { limits: ['idempotencyKeyMaxUnits'], defaults: [] },
31
34
  lookup_people: { limits: ['lookupQueryMinUnits', 'lookupQueryMaxUnits', 'lookupLimitMax'], defaults: ['limit'] },
32
35
  list_access: { limits: [], defaults: [] },
@@ -112,6 +115,17 @@ export function capabilitySchema(name, profile) {
112
115
  case 'get_template': return obj({ templateId: str }, ['templateId']);
113
116
  case 'get_api_guide': return obj({ version: str });
114
117
  case 'create_upload': return obj({ artifactId: id, mimeType: str, maxSize: integer(1) }, ['artifactId', 'mimeType']);
118
+ case 'create_upload_page': return obj({ artifactId: id,
119
+ maxFiles: { type: 'integer', minimum: 1, maximum: 255,
120
+ description: 'Files the page may stage; capped by the release budget (min asked, profile releaseFilesMax).' },
121
+ }, ['artifactId']);
122
+ case 'list_assets': return obj({ artifactId: id, releaseId: id,
123
+ state: { type: 'string', enum: ['staged', 'released', 'all'], default: 'all',
124
+ description: 'Released assets come from the release manifest; staged assets from committed uploads.' },
125
+ pageSessionId: { ...id, description: 'Only staged files committed through this browser page.' },
126
+ limit: { ...integer(limits.listAssetsLimitMin, limits.listAssetsLimitMax), default: config.defaults.limit },
127
+ cursor: { ...str, maxLength: 4096, description: 'Opaque paging cursor from a previous response.' },
128
+ }, ['artifactId']);
115
129
  case 'commit_upload': return obj({ artifactId: id, uploadId: str, path: str, mimeType: str,
116
130
  digest: str, size: integer(0), profile: primitiveRecord, idempotencyKey: key }, ['artifactId', 'uploadId', 'path', 'mimeType', 'digest', 'size', 'idempotencyKey']);
117
131
  case 'publish_bundle': {
@@ -152,6 +166,52 @@ export function capabilitySchema(name, profile) {
152
166
  ...(part1 ? metadata : {}) }, ['artifactId', 'idempotencyKey', 'expectedCurrentReleaseId']),
153
167
  anyOf: [{ required: ['files'] }, { required: ['assets'] }] };
154
168
  }
169
+ case 'publish_bundle_v2': {
170
+ // V2 carries everything v1 has, plus copy/carry asset forms and the
171
+ // keep-unmodified carry of the expected current release. V1 is untouched.
172
+ const publishLimits = profile.operations.find((entry) => entry.operation === 'publish')?.limits;
173
+ const filesMax = publishLimits?.releaseFilesMax ?? publishLimits?.publishFilesMax ?? SERVER_MAX_FILES_PER_RELEASE;
174
+ const fileBytesMax = publishLimits?.releaseFileBytesMax ?? publishLimits?.maxDecodedFileBytes ?? SERVER_MAX_FILE_BYTES;
175
+ const totalBytesMax = publishLimits?.releaseTotalBytesMax ?? publishLimits?.maxDecodedTotalBytes ?? SERVER_MAX_TOTAL_BYTES;
176
+ const inlineFileBytesMax = publishLimits?.maxDecodedFileBytes ?? SERVER_MAX_FILE_BYTES;
177
+ const inlineTotalBytesMax = publishLimits?.maxDecodedTotalBytes ?? SERVER_MAX_TOTAL_BYTES;
178
+ const reserved = profile.rules.reservedFirstSegments.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|');
179
+ const bundlePath = { type: 'string', minLength: 1, maxLength: profile.rules.pathMaxBytes,
180
+ allOf: [{ not: { pattern: profile.rules.forbiddenPathPattern } },
181
+ { not: { pattern: '(^|/)(\\.\\.?|)(/|$)' } },
182
+ { not: { pattern: `^(?:${reserved})(?:/|$)` } }],
183
+ description: `At most ${profile.rules.pathMaxBytes} UTF-8 bytes; no empty/dot segments, colon or DEL.` };
184
+ const inlineFile = { ...obj({ path: bundlePath, mimeType: { type: 'string', enum: profile.rules.mimeTypes },
185
+ text: { type: 'string', maxLength: inlineFileBytesMax, description: 'UTF-8 decoded-byte budget applies.' },
186
+ bytes: { type: 'array', maxItems: inlineFileBytesMax, items: integer(0, 255) } }, ['path', 'mimeType']),
187
+ oneOf: [{ required: ['text'], not: { required: ['bytes'] } },
188
+ { required: ['bytes'], not: { required: ['text'] } }] };
189
+ const uploadAsset = obj({ path: bundlePath, uploadId: id,
190
+ description: 'Staged file committed via artifacts_commit_upload; the server re-reads and re-verifies it.' }, ['path', 'uploadId']);
191
+ const casAsset = obj({ path: bundlePath,
192
+ digest: { type: 'string', pattern: '^sha256:[0-9a-f]{64}$',
193
+ description: 'Canonical sha256:<hex> digest of an already-pinned blob in the same scope.' },
194
+ size: integer(1), mimeType: { type: 'string', enum: profile.rules.mimeTypes } }, ['path', 'digest', 'size', 'mimeType']);
195
+ const copyAsset = obj({ path: bundlePath, sourceArtifactId: id,
196
+ sourcePath: bundlePath, sourceReleaseId: id,
197
+ description: 'Copy one manifest file from another artifact of the same scope (MIME taken from the source manifest).' }, ['path', 'sourceArtifactId']);
198
+ const carryAsset = obj({ path: bundlePath, carryFromReleaseId: id,
199
+ sourcePath: bundlePath,
200
+ description: 'Carry one manifest file from a release of this artifact (defaults to the same path).' }, ['path', 'carryFromReleaseId']);
201
+ return { ...obj({ artifactId: id, idempotencyKey: key,
202
+ files: { type: 'array', items: inlineFile, minItems: 1, maxItems: filesMax,
203
+ description: `Inline files (bytes travel through the model, inline budget ${inlineFileBytesMax}/${inlineTotalBytesMax} bytes); at least one of files/assets is required.` },
204
+ assets: { type: 'array', minItems: 1, maxItems: filesMax,
205
+ items: { oneOf: [uploadAsset, casAsset, copyAsset, carryAsset] },
206
+ description: `Assets whose bytes already left the model: a staged uploadId, a CAS digest, a copy from another artifact of the same scope, or a carry from a release of this artifact. Release budget (max ${filesMax} files, ${fileBytesMax} bytes/file, ${totalBytesMax} bytes total) applies to the union.` },
207
+ expectedCurrentReleaseId: { ...id, type: ['string', 'null'],
208
+ description: 'Compare the current release atomically; null requires an unpublished artifact. Always required for this tool.' },
209
+ keepUnmodifiedPaths: { type: 'boolean', default: false,
210
+ description: 'Carry every path of expectedCurrentReleaseId not overridden by an explicit file or asset.' },
211
+ profile: { ...primitiveRecord, default: config.defaults.profile },
212
+ ...(part1 ? metadata : {}) }, ['artifactId', 'idempotencyKey', 'expectedCurrentReleaseId']),
213
+ anyOf: [{ required: ['files'] }, { required: ['assets'] }] };
214
+ }
155
215
  case 'set_access': return { ...obj({ artifactId: id, action: { type: 'string', enum: ['grant', 'revoke'] },
156
216
  principalId: { ...str, maxLength: 256 }, grant: { type: 'string', enum: ['read'] }, idempotencyKey: key }, ['artifactId', 'action', 'principalId', 'idempotencyKey']), oneOf: [
157
217
  { properties: { action: { enum: ['grant'] } }, required: ['grant'] },
@@ -102,7 +102,8 @@ export function normalizeArguments(profile, name, input, schema, envelopeKey, op
102
102
  const operation = name.slice('artifacts_'.length);
103
103
  const { defaults, limits } = operationProfile(profile, operation);
104
104
  const normalized = { ...copyJson(defaults), ...args };
105
- if (['ensure', 'publish', 'commit_upload', 'publish_bundle', 'set_access', 'delete', 'revert'].includes(operation)) {
105
+ if (['ensure', 'publish', 'commit_upload', 'publish_bundle', 'publish_bundle_v2',
106
+ 'set_access', 'delete', 'revert'].includes(operation)) {
106
107
  const key = args.idempotencyKey;
107
108
  requireInput(typeof key === 'string' && key.trim().length > 0 && key.length <= limits.idempotencyKeyMaxUnits);
108
109
  requireInput(envelopeKey === undefined || envelopeKey === key);
@@ -119,7 +120,8 @@ export function normalizeArguments(profile, name, input, schema, envelopeKey, op
119
120
  requireInput(isArtifactId(args.releaseId));
120
121
  if (Object.hasOwn(args, 'expectedCurrentReleaseId'))
121
122
  requireInput(args.expectedCurrentReleaseId === null || isArtifactId(args.expectedCurrentReleaseId));
122
- if (operation === 'publish' || operation === 'publish_bundle') {
123
+ const isBundle = operation === 'publish_bundle' || operation === 'publish_bundle_v2';
124
+ if (operation === 'publish' || isBundle) {
123
125
  const hasFiles = Object.hasOwn(args, 'files');
124
126
  if (operation === 'publish') {
125
127
  const hasEdits = Object.hasOwn(args, 'edits');
@@ -144,14 +146,14 @@ export function normalizeArguments(profile, name, input, schema, envelopeKey, op
144
146
  requireInput(bytes.length <= inlineFileBytesMax && total <= inlineTotalBytesMax);
145
147
  return { path, mimeType: file.mimeType, bytes };
146
148
  });
147
- if (operation === 'publish_bundle' && Object.hasOwn(args, 'assets')) {
149
+ if (isBundle && Object.hasOwn(args, 'assets')) {
148
150
  // Duplicate path refused across the files/assets union.
149
151
  for (const asset of args.assets) {
150
152
  requireInput(!paths.has(asset.path));
151
153
  }
152
154
  }
153
155
  }
154
- if (operation === 'publish_bundle' && Object.hasOwn(args, 'assets')) {
156
+ if (isBundle && Object.hasOwn(args, 'assets')) {
155
157
  const paths = new Set();
156
158
  if (hasFiles)
157
159
  for (const file of args.files)
@@ -164,6 +166,31 @@ export function normalizeArguments(profile, name, input, schema, envelopeKey, op
164
166
  requireInput(isArtifactId(asset.uploadId));
165
167
  return { path, uploadId: asset.uploadId };
166
168
  }
169
+ // LOT 2 v2 asset forms: copy from another artifact, or carry from a
170
+ // release of this artifact. The MIME type is taken from the source
171
+ // manifest at resolution time, never from the caller.
172
+ if (Object.hasOwn(asset, 'sourceArtifactId')) {
173
+ requireInput(isArtifactId(asset.sourceArtifactId));
174
+ if (Object.hasOwn(asset, 'sourcePath')) {
175
+ requireInput(typeof asset.sourcePath === 'string' &&
176
+ Buffer.byteLength(asset.sourcePath, 'utf8') <= profile.rules.pathMaxBytes);
177
+ }
178
+ if (Object.hasOwn(asset, 'sourceReleaseId')) {
179
+ requireInput(isArtifactId(asset.sourceReleaseId));
180
+ }
181
+ return { path, sourceArtifactId: asset.sourceArtifactId,
182
+ ...(Object.hasOwn(asset, 'sourcePath') ? { sourcePath: asset.sourcePath } : {}),
183
+ ...(Object.hasOwn(asset, 'sourceReleaseId') ? { sourceReleaseId: asset.sourceReleaseId } : {}) };
184
+ }
185
+ if (Object.hasOwn(asset, 'carryFromReleaseId')) {
186
+ requireInput(isArtifactId(asset.carryFromReleaseId));
187
+ if (Object.hasOwn(asset, 'sourcePath')) {
188
+ requireInput(typeof asset.sourcePath === 'string' &&
189
+ Buffer.byteLength(asset.sourcePath, 'utf8') <= profile.rules.pathMaxBytes);
190
+ }
191
+ return { path, carryFromReleaseId: asset.carryFromReleaseId,
192
+ ...(Object.hasOwn(asset, 'sourcePath') ? { sourcePath: asset.sourcePath } : {}) };
193
+ }
167
194
  const digest = asset.digest;
168
195
  requireInput(/^sha256:[0-9a-f]{64}$/.test(digest) && Number.isSafeInteger(asset.size) && asset.size >= 1 &&
169
196
  profile.rules.mimeTypes.includes(asset.mimeType));
@@ -8,7 +8,7 @@ export type CallerIdempotencyKey = string & {
8
8
  export type InternalIdempotencyKey = string & {
9
9
  readonly __brand: 'internal-key';
10
10
  };
11
- export type ArtifactCommandOperation = 'ensure' | 'publish' | 'set_access' | 'delete' | 'revert' | 'commit_upload' | 'publish_bundle';
11
+ export type ArtifactCommandOperation = 'ensure' | 'publish' | 'set_access' | 'delete' | 'revert' | 'commit_upload' | 'publish_bundle' | 'publish_bundle_v2';
12
12
  export interface CommandIdentity {
13
13
  readonly internalKey: InternalIdempotencyKey;
14
14
  readonly commandHash: string;
@@ -21,7 +21,7 @@ export function createRadarKeyDerivation(config) {
21
21
  continue;
22
22
  const [operation, objectId] = other.slice(actor.length + 1).split('|');
23
23
  if ((operation === 'ensure' && objectId === '') ||
24
- (['publish', 'set_access', 'delete', 'revert', 'commit_upload', 'publish_bundle'].includes(operation) && isArtifactId(objectId))) {
24
+ (['publish', 'set_access', 'delete', 'revert', 'commit_upload', 'publish_bundle', 'publish_bundle_v2'].includes(operation) && isArtifactId(objectId))) {
25
25
  throw new Error('ambiguous Radar actor domain');
26
26
  }
27
27
  }
@@ -31,7 +31,7 @@ export function createRadarKeyDerivation(config) {
31
31
  derive(input) {
32
32
  const { storageScopeId, actorId, operation, objectId, callerKey } = input;
33
33
  if (storageScopeId !== scope || !actors.has(actorId) ||
34
- !['ensure', 'publish', 'set_access', 'delete', 'revert', 'commit_upload', 'publish_bundle'].includes(operation) ||
34
+ !['ensure', 'publish', 'set_access', 'delete', 'revert', 'commit_upload', 'publish_bundle', 'publish_bundle_v2'].includes(operation) ||
35
35
  (operation === 'ensure' ? objectId !== '' : !isArtifactId(objectId)))
36
36
  throw new ArtifactProfileInputError();
37
37
  assertWellFormed(callerKey);
@@ -50,7 +50,8 @@ export function createArtifactCommand(profile, name, args, authority, derivation
50
50
  throw new Error('profile/derivation mismatch');
51
51
  const normalized = profile.validate(name, args, envelopeKey, options);
52
52
  if (!['artifacts_ensure', 'artifacts_publish', 'artifacts_set_access', 'artifacts_delete', 'artifacts_revert',
53
- 'artifacts_commit_upload', 'artifacts_publish_bundle'].includes(name))
53
+ 'artifacts_commit_upload', 'artifacts_publish_bundle',
54
+ 'artifacts_publish_bundle_v2'].includes(name))
54
55
  throw new ArtifactProfileInputError(true);
55
56
  const operation = name.slice('artifacts_'.length);
56
57
  const { idempotencyKey, confirmationRef: _proof, ...payload } = normalized;
@@ -1,6 +1,8 @@
1
1
  import type { CommitExecutor, FinalizeTxClient } from './commit/types.js';
2
2
  import { type PublicationBlobStore } from './publication.js';
3
3
  import { type StagingStore, type UploadSessionStore } from './uploads.js';
4
+ import type { ArtifactsMetrics } from './metrics.js';
5
+ import type { UploadPageStore } from './upload-page.js';
4
6
  export interface RefcountStore {
5
7
  addRef(digest: string, holder: string): Promise<void>;
6
8
  releaseRef(digest: string, holder: string): Promise<void>;
@@ -70,13 +72,36 @@ export interface UploadSweepReport {
70
72
  uploadId: string;
71
73
  error: string;
72
74
  }[];
75
+ /** LOT 2 §D.1: staged rows past the staged-file TTL (deleted + unpinned). */
76
+ stagedExpired: string[];
77
+ /** LOT 2 §D.1: digests whose consumed upload pin the sweeper released. */
78
+ unpinned: string[];
79
+ /** LOT 2 §D.1: orphan staging keys deleted past the grace (bounded per run). */
80
+ orphanKeys: string[];
81
+ /** LOT 2 §A.3: page rows past expires_at (flipped to expired, kept for audit). */
82
+ pagesExpired: string[];
73
83
  }
74
84
  export interface UploadSweeper {
75
- sweep(now?: Date): Promise<UploadSweepReport>;
85
+ sweep(now?: Date, options?: {
86
+ scopes?: string[];
87
+ }): Promise<UploadSweepReport>;
76
88
  }
77
- /** Create the enforced staging sweeper over the injected session/staging ports. */
89
+ /**
90
+ * Create the enforced staging sweeper over the injected session/staging
91
+ * ports. LOT 2 adds staged-file TTL, orphan staging keys, page expiry and
92
+ * sweep summaries; refs/pages/metrics are optional (absent ⇒ the pass that
93
+ * needs them is skipped, except summaries which simply have no sink).
94
+ */
78
95
  export declare function createUploadSweeper(deps: {
79
96
  sessions: UploadSessionStore;
80
- staging: Pick<StagingStore, 'delete' | 'listKeys'>;
97
+ staging: Pick<StagingStore, 'delete' | 'listKeys'> & Pick<StagingStore, 'listEntries'>;
98
+ refs?: RefcountStore;
99
+ pages?: UploadPageStore;
100
+ metrics?: ArtifactsMetrics;
101
+ }, options?: {
102
+ now?: () => Date;
103
+ stagedFileTtlMs?: number;
104
+ orphanGraceMs?: number;
105
+ orphanKeyLimit?: number;
81
106
  }): UploadSweeper;
82
107
  export {};
package/dist/server/gc.js CHANGED
@@ -12,7 +12,7 @@
12
12
  */
13
13
  import { createKeyMutex } from './ports.js';
14
14
  import { blobDigestOfKey } from './publication.js';
15
- import { stagingKey } from './uploads.js';
15
+ import { ORPHAN_STAGING_GRACE_MS, ORPHAN_SWEEP_MAX_KEYS, STAGED_FILE_TTL_MAX_MS, STAGED_FILE_TTL_MS, stagingKey, stagingPrefix } from './uploads.js';
16
16
  /** In-memory RefcountStore double (yields mid-update to expose races). */
17
17
  export function createMemoryRefcountStore() {
18
18
  const holders = new Map();
@@ -252,11 +252,28 @@ export function createGcService(refs) {
252
252
  },
253
253
  };
254
254
  }
255
- /** Create the enforced staging sweeper over the injected session/staging ports. */
256
- export function createUploadSweeper(deps) {
255
+ /**
256
+ * Create the enforced staging sweeper over the injected session/staging
257
+ * ports. LOT 2 adds staged-file TTL, orphan staging keys, page expiry and
258
+ * sweep summaries; refs/pages/metrics are optional (absent ⇒ the pass that
259
+ * needs them is skipped, except summaries which simply have no sink).
260
+ */
261
+ export function createUploadSweeper(deps, options) {
262
+ const stagedFileTtlMs = options?.stagedFileTtlMs ?? STAGED_FILE_TTL_MS;
263
+ const orphanGraceMs = options?.orphanGraceMs ?? ORPHAN_STAGING_GRACE_MS;
264
+ const orphanKeyLimit = options?.orphanKeyLimit ?? ORPHAN_SWEEP_MAX_KEYS;
265
+ if (!Number.isSafeInteger(stagedFileTtlMs) || stagedFileTtlMs < 1 ||
266
+ stagedFileTtlMs > STAGED_FILE_TTL_MAX_MS) {
267
+ throw new Error('invalid staged file TTL');
268
+ }
269
+ const emitSummary = (name, value) => {
270
+ if (deps.metrics !== undefined)
271
+ deps.metrics.emit({ name, value });
272
+ };
257
273
  return {
258
- async sweep(at = new Date()) {
259
- const report = { expired: [], deletedKeys: [], failures: [] };
274
+ async sweep(at = options?.now?.() ?? new Date(), sweepOptions) {
275
+ const report = { expired: [], deletedKeys: [], failures: [],
276
+ stagedExpired: [], unpinned: [], orphanKeys: [], pagesExpired: [] };
260
277
  for (const session of await deps.sessions.listExpiredOpen(at)) {
261
278
  const key = stagingKey(session.storageScopeId, session.uploadId);
262
279
  try {
@@ -269,6 +286,65 @@ export function createUploadSweeper(deps) {
269
286
  report.failures.push({ uploadId: session.uploadId, error: String(error) });
270
287
  }
271
288
  }
289
+ // Pass 2: staged files past the TTL. Unpin first, then delete the row;
290
+ // an unpin failure keeps the row for the next run and is reported.
291
+ for (const record of await deps.sessions.listExpiredStaged(at, stagedFileTtlMs)) {
292
+ try {
293
+ if (deps.refs !== undefined) {
294
+ await deps.refs.unpin(record.digest, `upload:${record.uploadId}`);
295
+ report.unpinned.push(record.digest);
296
+ }
297
+ await deps.sessions.deleteStagedFile(record.uploadId);
298
+ report.stagedExpired.push(record.uploadId);
299
+ }
300
+ catch (error) {
301
+ report.failures.push({ uploadId: record.uploadId, error: String(error) });
302
+ }
303
+ }
304
+ emitSummary('staged_files_expired', report.stagedExpired.length);
305
+ // Pass 3: orphan staging keys (no session row in open|committed) past
306
+ // the grace, bounded per run. Stores without listEntries skip the pass.
307
+ if (deps.staging.listEntries !== undefined && sweepOptions?.scopes !== undefined) {
308
+ let remaining = orphanKeyLimit;
309
+ for (const scope of sweepOptions.scopes) {
310
+ if (remaining <= 0)
311
+ break;
312
+ const entries = await deps.staging.listEntries(stagingPrefix(scope));
313
+ for (const entry of entries) {
314
+ if (remaining <= 0)
315
+ break;
316
+ const uploadId = entry.key.slice(entry.key.lastIndexOf('/') + 1);
317
+ const session = await deps.sessions.get(uploadId);
318
+ if (session !== undefined && (session.state === 'open' || session.state === 'committed')) {
319
+ continue;
320
+ }
321
+ if (new Date(entry.lastModified).getTime() + orphanGraceMs > at.getTime())
322
+ continue;
323
+ try {
324
+ await deps.staging.delete(entry.key);
325
+ report.orphanKeys.push(entry.key);
326
+ remaining -= 1;
327
+ }
328
+ catch (error) {
329
+ report.failures.push({ uploadId, error: String(error) });
330
+ }
331
+ }
332
+ }
333
+ }
334
+ emitSummary('staging_orphans_deleted', report.orphanKeys.length);
335
+ // Pass 4: browser pages past expires_at (rows kept for audit).
336
+ if (deps.pages !== undefined) {
337
+ for (const row of await deps.pages.listExpiredPages(at)) {
338
+ try {
339
+ await deps.pages.markExpired(row.pageSessionId);
340
+ report.pagesExpired.push(row.pageSessionId);
341
+ }
342
+ catch (error) {
343
+ report.failures.push({ uploadId: row.pageSessionId, error: String(error) });
344
+ }
345
+ }
346
+ }
347
+ emitSummary('upload_pages_expired', report.pagesExpired.length);
272
348
  return report;
273
349
  },
274
350
  };
@@ -1,5 +1,5 @@
1
1
  import { audienceOf, canManageAccess, PUBLIC_PRINCIPAL } from './access.js';
2
- import { combineSharingPolicy, resolveSharingPolicy } from './ports.js';
2
+ import { combineSharingPolicy, resolveSharingPolicy, UNKNOWN_USER_REF } from './ports.js';
3
3
  import { ArtifactOperationError } from './failures.js';
4
4
  export function confirmationFailure(code, details) {
5
5
  return new ArtifactOperationError('unauthorized_at_commit', { publicDetails: details,
@@ -67,10 +67,14 @@ export async function manageArtifact(deps, invocation, command, proof) {
67
67
  return await deps.directory.resolvePrincipal(invocation.storageScopeId, principalId) ?? principalId;
68
68
  };
69
69
  // Unknown, inactive, unapproved and out-of-scope targets merge into the
70
- // single `person_not_shareable` so no account status can be probed.
70
+ // single `person_not_shareable` so no account status can be probed. R5: the
71
+ // approval gate applies to `grant` only; `revoke` is the expected cleanup
72
+ // step for dormant (suspended or deleted) principals and must stay allowed.
71
73
  const assertShareable = async (internal, action) => {
74
+ if (action !== 'grant')
75
+ return;
72
76
  if (deps.directory === undefined) {
73
- if (action === 'grant' && !await deps.isApprovedPrincipal(internal))
77
+ if (!await deps.isApprovedPrincipal(internal))
74
78
  throw refused('access_denied');
75
79
  return;
76
80
  }
@@ -78,14 +82,15 @@ export async function manageArtifact(deps, invocation, command, proof) {
78
82
  throw shareableRefused();
79
83
  };
80
84
  // The receipt is model-visible: project internal principals to userRefs
81
- // (audit events keep the internal form).
85
+ // (audit events keep the internal form). R1: a missing directory entry
86
+ // projects to the opaque unknown value, never the raw internal id.
82
87
  const projectGrants = async (grants) => {
83
88
  if (deps.directory === undefined)
84
89
  return grants;
85
90
  return Promise.all(grants.map(async (grant) => ({
86
91
  ...grant,
87
92
  principalId: (await deps.directory.describePrincipal(invocation.storageScopeId, grant.principalId))?.userRef
88
- ?? grant.principalId,
93
+ ?? UNKNOWN_USER_REF,
89
94
  })));
90
95
  };
91
96
  const request = {
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Files parity LOT 2 §D.3 — upload/storage metering (signatures; body in Lot 4).
3
+ *
4
+ * Optional `metrics(event)` callback on upload/page/content deps; absent ⇒
5
+ * no-op. No metrics library in the package, no `artifactId` or `ownerId` in
6
+ * labels. Sweep summaries are emitted once per run.
7
+ */
8
+ export interface ArtifactsMetricEvent {
9
+ /** e.g. `upload_sessions_created`; see §D.3 for the closed event set. */
10
+ readonly name: string;
11
+ /** Low-cardinality labels only (channel, result, reason, origin). */
12
+ readonly labels?: Readonly<Record<string, string>>;
13
+ /** Numeric magnitude (e.g. committed bytes); never an identifier. */
14
+ readonly value?: number;
15
+ }
16
+ export interface ArtifactsMetrics {
17
+ emit(event: ArtifactsMetricEvent): void;
18
+ }
19
+ /** No-op sink used when the host wires no metrics port. */
20
+ export declare const NO_METRICS: ArtifactsMetrics;
21
+ export declare function emitMetric(metrics: ArtifactsMetrics | undefined, event: ArtifactsMetricEvent): void;
@@ -0,0 +1,6 @@
1
+ /** No-op sink used when the host wires no metrics port. */
2
+ export const NO_METRICS = { emit: () => undefined };
3
+ export function emitMetric(metrics, event) {
4
+ if (metrics !== undefined)
5
+ metrics.emit(event);
6
+ }
@@ -49,6 +49,13 @@ export interface PrincipalDirectoryPort {
49
49
  /** Inverse projection: internal principal id → directory person (userRef/displayName/email). */
50
50
  describePrincipal(scope: string, principalId: string): Promise<DirectoryPerson | undefined>;
51
51
  }
52
+ /**
53
+ * R1 typed unknown principal (review 1002): every model-visible projection of
54
+ * an internal principal whose directory entry is missing emits this opaque
55
+ * value instead of the raw internal id (`sub`). It never resolves back to a
56
+ * principal, so re-injecting it fails closed with `person_not_shareable`.
57
+ */
58
+ export declare const UNKNOWN_USER_REF = "unknown";
52
59
  /**
53
60
  * Mask an email for model payloads: first local-part character kept, rest of
54
61
  * the local part masked, domain visible — lifts homonyms without disclosing