@sentropic/artifacts 0.2.13 → 0.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/dist/adapters/local-blob.d.ts +3 -0
- package/dist/adapters/local-blob.js +93 -0
- package/dist/adapters/postgres-uploads.d.ts +14 -0
- package/dist/adapters/postgres-uploads.js +174 -0
- package/dist/adapters/s3.js +23 -0
- package/dist/adapters/sqlite-activation.d.ts +20 -0
- package/dist/adapters/sqlite-activation.js +205 -0
- package/dist/adapters/sqlite-commit.d.ts +15 -0
- package/dist/adapters/sqlite-commit.js +89 -0
- package/dist/adapters/sqlite-management.d.ts +10 -0
- package/dist/adapters/sqlite-management.js +60 -0
- package/dist/adapters/sqlite-sql.d.ts +32 -0
- package/dist/adapters/sqlite-sql.js +36 -0
- package/dist/adapters/sqlite-store.d.ts +12 -0
- package/dist/adapters/sqlite-store.js +410 -0
- package/dist/adapters/sqlite.d.ts +33 -0
- package/dist/adapters/sqlite.js +95 -0
- package/dist/content/handler.d.ts +5 -0
- package/dist/content/handler.js +80 -9
- package/dist/http.d.ts +16 -0
- package/dist/http.js +371 -82
- package/dist/mcp-core.d.ts +3 -3
- package/dist/mcp-core.js +43 -4
- package/dist/profile/contracts.d.ts +1 -1
- package/dist/profile/contracts.js +4 -0
- package/dist/profile/index.js +12 -2
- package/dist/profile/schemas.js +60 -0
- package/dist/profile/validation.js +31 -4
- package/dist/server/command-identity.d.ts +1 -1
- package/dist/server/command-identity.js +4 -3
- package/dist/server/gc.d.ts +28 -3
- package/dist/server/gc.js +81 -5
- package/dist/server/metrics.d.ts +21 -0
- package/dist/server/metrics.js +6 -0
- package/dist/server/publication-limits.d.ts +8 -0
- package/dist/server/publication-limits.js +8 -0
- package/dist/server/publication.d.ts +5 -0
- package/dist/server/publication.js +6 -0
- package/dist/server/source-read.d.ts +12 -9
- package/dist/server/source-read.js +17 -5
- package/dist/server/upload-page.d.ts +157 -0
- package/dist/server/upload-page.js +438 -0
- package/dist/server/uploads.d.ts +75 -1
- package/dist/server/uploads.js +187 -27
- package/migrations/0009_upload_pages.sql +25 -0
- package/package.json +13 -1
- package/sql/sqlite/0001_artifacts.sql +156 -0
- package/sql/sqlite/0002_activation.sql +73 -0
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.
|
|
9
|
+
export const ARTIFACTS_PROVIDER_VERSION = '0.2.14';
|
|
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', '
|
|
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'
|
|
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.';
|
package/dist/profile/index.js
CHANGED
|
@@ -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',
|
|
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')
|
package/dist/profile/schemas.js
CHANGED
|
@@ -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', '
|
|
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
|
-
|
|
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 (
|
|
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 (
|
|
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'
|
|
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;
|
package/dist/server/gc.d.ts
CHANGED
|
@@ -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
|
|
85
|
+
sweep(now?: Date, options?: {
|
|
86
|
+
scopes?: string[];
|
|
87
|
+
}): Promise<UploadSweepReport>;
|
|
76
88
|
}
|
|
77
|
-
/**
|
|
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
|
-
/**
|
|
256
|
-
|
|
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
|
};
|
|
@@ -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;
|
|
@@ -15,6 +15,14 @@ export declare const SERVER_MAX_FILE_BYTES: number;
|
|
|
15
15
|
export declare const SERVER_MAX_TOTAL_BYTES: number;
|
|
16
16
|
/** Concurrent open upload sessions per principal (leaked-URL DoS bound). */
|
|
17
17
|
export declare const SERVER_MAX_UPLOAD_SESSIONS_PER_PRINCIPAL = 8;
|
|
18
|
+
/**
|
|
19
|
+
* Generic `get_source` server maxima (files parity LOT 2 §B.3): 32 files, 1 MiB
|
|
20
|
+
* per file, 2 MiB total. A profile may only narrow them; the frozen definition
|
|
21
|
+
* caps `paths` at 32, so larger listings belong to `artifacts_list_assets`.
|
|
22
|
+
*/
|
|
23
|
+
export declare const SERVER_MAX_SOURCE_FILES = 32;
|
|
24
|
+
export declare const SERVER_MAX_SOURCE_INLINE_BYTES: number;
|
|
25
|
+
export declare const SERVER_MAX_SOURCE_TOTAL_BYTES: number;
|
|
18
26
|
/** Generic defaults: 255 files, 16 MiB per file, 64 MiB total (files parity LOT 1). */
|
|
19
27
|
export declare const DEFAULT_PUBLICATION_LIMITS: Readonly<PublicationLimits>;
|
|
20
28
|
export declare function publicationLimits(overrides?: Partial<PublicationLimits>): Readonly<PublicationLimits>;
|
|
@@ -9,6 +9,14 @@ export const SERVER_MAX_FILE_BYTES = 16 * 1024 * 1024;
|
|
|
9
9
|
export const SERVER_MAX_TOTAL_BYTES = 64 * 1024 * 1024;
|
|
10
10
|
/** Concurrent open upload sessions per principal (leaked-URL DoS bound). */
|
|
11
11
|
export const SERVER_MAX_UPLOAD_SESSIONS_PER_PRINCIPAL = 8;
|
|
12
|
+
/**
|
|
13
|
+
* Generic `get_source` server maxima (files parity LOT 2 §B.3): 32 files, 1 MiB
|
|
14
|
+
* per file, 2 MiB total. A profile may only narrow them; the frozen definition
|
|
15
|
+
* caps `paths` at 32, so larger listings belong to `artifacts_list_assets`.
|
|
16
|
+
*/
|
|
17
|
+
export const SERVER_MAX_SOURCE_FILES = 32;
|
|
18
|
+
export const SERVER_MAX_SOURCE_INLINE_BYTES = 1024 * 1024;
|
|
19
|
+
export const SERVER_MAX_SOURCE_TOTAL_BYTES = 2 * 1024 * 1024;
|
|
12
20
|
/** Generic defaults: 255 files, 16 MiB per file, 64 MiB total (files parity LOT 1). */
|
|
13
21
|
export const DEFAULT_PUBLICATION_LIMITS = Object.freeze({
|
|
14
22
|
maxFiles: SERVER_MAX_FILES_PER_RELEASE,
|
|
@@ -31,6 +31,11 @@ export interface PublicationStateStore {
|
|
|
31
31
|
export interface PublicationBlobStore {
|
|
32
32
|
putBlob(key: string, bytes: Uint8Array): Promise<void>;
|
|
33
33
|
getBlob(key: string): Promise<Uint8Array | undefined>;
|
|
34
|
+
/**
|
|
35
|
+
* Files parity LOT 2 §B.4: byte-range read (inclusive bounds). Optional:
|
|
36
|
+
* the content handler falls back to getBlob + in-memory slicing.
|
|
37
|
+
*/
|
|
38
|
+
getBlobRange?(key: string, start: number, endInclusive: number): Promise<Uint8Array | undefined>;
|
|
34
39
|
/** List keys under a prefix (orphan enumeration for crash recovery/GC). */
|
|
35
40
|
listKeys(prefix: string): Promise<string[]>;
|
|
36
41
|
/** Delete a key (strict: unknown keys fail so callers notice). */
|
|
@@ -67,6 +67,12 @@ export function createMemoryBlobStore() {
|
|
|
67
67
|
getBlob(key) {
|
|
68
68
|
return Promise.resolve(blobs.get(key));
|
|
69
69
|
},
|
|
70
|
+
getBlobRange(key, start, endInclusive) {
|
|
71
|
+
const bytes = blobs.get(key);
|
|
72
|
+
if (bytes === undefined || start < 0 || endInclusive < start)
|
|
73
|
+
return Promise.resolve(undefined);
|
|
74
|
+
return Promise.resolve(bytes.slice(start, Math.min(endInclusive + 1, bytes.length)));
|
|
75
|
+
},
|
|
70
76
|
async listKeys(prefix) {
|
|
71
77
|
assertBlobPrefix(prefix);
|
|
72
78
|
return [...blobs.keys()].filter((key) => key.startsWith(prefix)).sort();
|
|
@@ -16,7 +16,11 @@ export interface SourceReadPorts {
|
|
|
16
16
|
tool: string;
|
|
17
17
|
version: string;
|
|
18
18
|
};
|
|
19
|
+
/** Data-file slots per call (`sourceFilesMax`, server ceiling 32). */
|
|
19
20
|
maxFiles: number;
|
|
21
|
+
/** Per-file raw-byte budget (`sourceInlineFileBytesMax`, server ceiling 1 MiB). */
|
|
22
|
+
maxInlineBytes: number;
|
|
23
|
+
/** Raw-byte budget for files with data (`sourceTotalBytesMax`, server ceiling 2 MiB). */
|
|
20
24
|
maxTotalBytes: number;
|
|
21
25
|
}
|
|
22
26
|
export interface SourceReadInput {
|
|
@@ -33,20 +37,19 @@ export declare function readArtifactSource(ports: SourceReadPorts, input: Source
|
|
|
33
37
|
digest: string;
|
|
34
38
|
manifest: string;
|
|
35
39
|
files: ({
|
|
36
|
-
text: string;
|
|
37
|
-
encoding: "utf8";
|
|
38
40
|
path: string;
|
|
39
41
|
mimeType: string;
|
|
40
|
-
digest: string;
|
|
41
42
|
size: number;
|
|
43
|
+
digest: string;
|
|
44
|
+
} & ({
|
|
45
|
+
text: string;
|
|
46
|
+
encoding: 'utf8';
|
|
42
47
|
} | {
|
|
43
48
|
base64: string;
|
|
44
|
-
encoding:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
size: number;
|
|
49
|
-
})[];
|
|
49
|
+
encoding: 'base64';
|
|
50
|
+
} | {
|
|
51
|
+
omitted: 'too_large' | 'over_total_budget';
|
|
52
|
+
}))[];
|
|
50
53
|
sourceRef: SourceRef | null;
|
|
51
54
|
guideRef: {
|
|
52
55
|
readonly tool: "artifacts_get_api_guide";
|