@adea-ai/app-framework 0.28.1 → 0.28.2
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/dist/framework-source.json +1 -1
- package/dist/installer/command-artifact.d.ts +6 -0
- package/dist/installer/command-artifact.js +11 -3
- package/dist/release/local-provenance.d.ts +5 -1
- package/dist/release/local-provenance.js +11 -4
- package/dist/release/retention-dry-run.d.ts +46 -0
- package/dist/release/retention-dry-run.js +94 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.28.
|
|
1
|
+
{"version":"0.28.2","commit":"467eed71bb6f007ae6c25caae2e28534622a2b7d"}
|
|
@@ -23,6 +23,12 @@ export declare function readCommandArtifact(options: {
|
|
|
23
23
|
entries: number;
|
|
24
24
|
bytes: number;
|
|
25
25
|
}>;
|
|
26
|
+
/**
|
|
27
|
+
* Whether a failed signal to a process group means no live process remains in it. macOS answers
|
|
28
|
+
* EPERM, not ESRCH, while the group holds only unreaped zombies. The qualification service runs
|
|
29
|
+
* as this user, so EPERM there does not mean a live process this user may not signal.
|
|
30
|
+
*/
|
|
31
|
+
export declare function processGroupIsGone(code: string | undefined, platform?: NodeJS.Platform): boolean;
|
|
26
32
|
/** The bounded result of qualifying one extracted command artifact. */
|
|
27
33
|
export type CommandQualification = {
|
|
28
34
|
installed: true;
|
|
@@ -133,12 +133,20 @@ async function exitedWithin(child, milliseconds) {
|
|
|
133
133
|
clearTimeout(timer);
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Whether a failed signal to a process group means no live process remains in it. macOS answers
|
|
138
|
+
* EPERM, not ESRCH, while the group holds only unreaped zombies. The qualification service runs
|
|
139
|
+
* as this user, so EPERM there does not mean a live process this user may not signal.
|
|
140
|
+
*/
|
|
141
|
+
function processGroupIsGone(code, platform = process.platform) {
|
|
142
|
+
return code === "ESRCH" || platform === "darwin" && code === "EPERM";
|
|
143
|
+
}
|
|
136
144
|
/** Signal remaining processes in the detached Unix qualification service's group. */
|
|
137
145
|
function signalProcessGroup(pid, signal) {
|
|
138
146
|
try {
|
|
139
147
|
process.kill(-pid, signal);
|
|
140
148
|
} catch (error) {
|
|
141
|
-
if (error.code
|
|
149
|
+
if (!processGroupIsGone(error.code)) throw error;
|
|
142
150
|
}
|
|
143
151
|
}
|
|
144
152
|
async function serviceExitStatus(path) {
|
|
@@ -168,7 +176,7 @@ async function processGroupExited(pid, milliseconds) {
|
|
|
168
176
|
try {
|
|
169
177
|
process.kill(-pid, 0);
|
|
170
178
|
} catch (error) {
|
|
171
|
-
if (error.code
|
|
179
|
+
if (processGroupIsGone(error.code)) return true;
|
|
172
180
|
throw error;
|
|
173
181
|
}
|
|
174
182
|
if (process.platform === "linux" && await linuxProcessGroupIsExited(pid)) return true;
|
|
@@ -358,4 +366,4 @@ async function qualifyCommandArtifact(options) {
|
|
|
358
366
|
if (!qualification) throw new Error("Command artifact qualification did not complete");
|
|
359
367
|
return qualification;
|
|
360
368
|
}
|
|
361
|
-
export { commandArtifactRoot, packCommandArtifact, qualifyCommandArtifact, readCommandArtifact };
|
|
369
|
+
export { commandArtifactRoot, packCommandArtifact, processGroupIsGone, qualifyCommandArtifact, readCommandArtifact };
|
|
@@ -6,7 +6,11 @@ export declare function gitCli(): GitRun;
|
|
|
6
6
|
export declare function gitIsAncestor(git: GitRun, older: string, newer: string): Promise<boolean>;
|
|
7
7
|
/** The released version in the source manifest at the exact source commit. */
|
|
8
8
|
export declare function readSourceVersion(git: GitRun, sourceSha: string, path: string): Promise<string>;
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* The checkout's origin as `owner/name`, as descriptors record it. A GitLab project keeps that
|
|
11
|
+
* two-part form whatever groups it sits in (`adea-ai/ade/adea` is `adea-ai/adea`), so moving forge
|
|
12
|
+
* does not change the identity recorded in new descriptors or in installed apps' feeds.
|
|
13
|
+
*/
|
|
10
14
|
export declare function originRepository(git: GitRun): Promise<string>;
|
|
11
15
|
/**
|
|
12
16
|
* Local release provenance, replacing a trusted workflow run: the working tree is a clean
|
|
@@ -32,16 +32,23 @@ async function readSourceVersion(git, sourceSha, path) {
|
|
|
32
32
|
if (typeof manifest !== "object" || manifest === null || Array.isArray(manifest) || typeof manifest.version !== "string") throw new Error("Invalid source version manifest");
|
|
33
33
|
return manifest.version;
|
|
34
34
|
}
|
|
35
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* The checkout's origin as `owner/name`, as descriptors record it. A GitLab project keeps that
|
|
37
|
+
* two-part form whatever groups it sits in (`adea-ai/ade/adea` is `adea-ai/adea`), so moving forge
|
|
38
|
+
* does not change the identity recorded in new descriptors or in installed apps' feeds.
|
|
39
|
+
*/
|
|
36
40
|
async function originRepository(git) {
|
|
37
41
|
const url = await git([
|
|
38
42
|
"remote",
|
|
39
43
|
"get-url",
|
|
40
44
|
"origin"
|
|
41
45
|
]);
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
const part = "[A-Za-z0-9_.-]+";
|
|
47
|
+
const github = new RegExp(`^(?:https://github\\.com/|git@github\\.com:)(${part}/${part}?)(?:\\.git)?/?$`).exec(url);
|
|
48
|
+
const gitlab = new RegExp(`^(?:https://gitlab\\.com/|git@gitlab\\.com:)(${part})/(?:${part}/)*(${part}?)(?:\\.git)?/?$`).exec(url);
|
|
49
|
+
const repository = github ? github[1] : gitlab ? `${gitlab[1]}/${gitlab[2]}` : void 0;
|
|
50
|
+
if (!repository || repository.split("/").some((segment) => segment === "." || segment === "..")) throw new Error("Origin is not a GitHub or GitLab repository");
|
|
51
|
+
return repository;
|
|
45
52
|
}
|
|
46
53
|
/**
|
|
47
54
|
* Local release provenance, replacing a trusted workflow run: the working tree is a clean
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type FeedChannel } from '../updates/release-feed';
|
|
2
|
+
/** An inventory item from an independent, complete object listing. */
|
|
3
|
+
export type RetentionObject = Readonly<{
|
|
4
|
+
key: string;
|
|
5
|
+
version: string;
|
|
6
|
+
size: number;
|
|
7
|
+
sha256: string;
|
|
8
|
+
modifiedAt: string;
|
|
9
|
+
role: 'payload' | 'provenance';
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* Offline evidence for an advisory report. Completeness must be established by the
|
|
13
|
+
* caller; this module does not fetch, authenticate, lock, or delete any object.
|
|
14
|
+
*/
|
|
15
|
+
export type RetentionEvidence = Readonly<{
|
|
16
|
+
feed: unknown;
|
|
17
|
+
ledger: unknown;
|
|
18
|
+
releases: readonly unknown[];
|
|
19
|
+
pointers: Readonly<Record<FeedChannel, unknown | null>>;
|
|
20
|
+
objects: readonly RetentionObject[];
|
|
21
|
+
protectedTags: Readonly<{
|
|
22
|
+
rollback: readonly string[];
|
|
23
|
+
qualification: readonly string[];
|
|
24
|
+
promotion: readonly string[];
|
|
25
|
+
inFlight: readonly string[];
|
|
26
|
+
}>;
|
|
27
|
+
/** Latest time each unprotected release could have been exposed to a reader. */
|
|
28
|
+
lastExposedAt: Readonly<Record<string, string>>;
|
|
29
|
+
/** All sources must cover the complete namespace and all reference classes. */
|
|
30
|
+
complete: boolean;
|
|
31
|
+
now: string;
|
|
32
|
+
discoveryGraceMs: number;
|
|
33
|
+
}>;
|
|
34
|
+
/** Advisory only: returned object identities are not a deletion authorization. */
|
|
35
|
+
export declare function planRetentionDryRun(input: RetentionEvidence): {
|
|
36
|
+
mode: 'advisory-only';
|
|
37
|
+
review: Readonly<{
|
|
38
|
+
key: string;
|
|
39
|
+
version: string;
|
|
40
|
+
size: number;
|
|
41
|
+
sha256: string;
|
|
42
|
+
modifiedAt: string;
|
|
43
|
+
role: 'payload' | 'provenance';
|
|
44
|
+
}>[];
|
|
45
|
+
protectedTags: string[];
|
|
46
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { feedAssetKey, parseFeedRelease, parseReleaseFeed, parseReleaseLedger } from "../updates/release-feed.js";
|
|
2
|
+
import { versionLessThan } from "../updates/release-version.js";
|
|
3
|
+
// src/release/retention-dry-run.ts
|
|
4
|
+
var DAY = 864e5;
|
|
5
|
+
var channels = [
|
|
6
|
+
"dev",
|
|
7
|
+
"daily",
|
|
8
|
+
"stable"
|
|
9
|
+
];
|
|
10
|
+
function time(value) {
|
|
11
|
+
const parsed = Date.parse(value);
|
|
12
|
+
if (!Number.isFinite(parsed) || new Date(parsed).toISOString().replace(".000Z", "Z") !== value.replace(".000Z", "Z")) throw new Error("Invalid retention timestamp");
|
|
13
|
+
return parsed;
|
|
14
|
+
}
|
|
15
|
+
/** Advisory only: returned object identities are not a deletion authorization. */
|
|
16
|
+
function planRetentionDryRun(input) {
|
|
17
|
+
if (input.complete !== true) throw new Error("Incomplete retention evidence");
|
|
18
|
+
const feed = parseReleaseFeed(input.feed);
|
|
19
|
+
const ledger = parseReleaseLedger(input.ledger, feed.app);
|
|
20
|
+
const now = time(input.now);
|
|
21
|
+
if (!Number.isSafeInteger(input.discoveryGraceMs) || input.discoveryGraceMs < DAY || input.discoveryGraceMs > 7 * DAY) throw new Error("Invalid discovery grace");
|
|
22
|
+
const releases = new Map(input.releases.map((value) => {
|
|
23
|
+
const release = parseFeedRelease(value);
|
|
24
|
+
return [release.tag, release];
|
|
25
|
+
}));
|
|
26
|
+
if (releases.size !== input.releases.length || releases.size !== ledger.releases.length) throw new Error("Release inventory does not match ledger");
|
|
27
|
+
const protectedTags = /* @__PURE__ */ new Set();
|
|
28
|
+
for (const key of [
|
|
29
|
+
"rollback",
|
|
30
|
+
"qualification",
|
|
31
|
+
"promotion",
|
|
32
|
+
"inFlight"
|
|
33
|
+
]) {
|
|
34
|
+
const list = input.protectedTags?.[key];
|
|
35
|
+
if (!Array.isArray(list)) throw new Error("Incomplete protection references");
|
|
36
|
+
for (const tag of list) protectedTags.add(tag);
|
|
37
|
+
}
|
|
38
|
+
for (const channel of channels) {
|
|
39
|
+
if (!Object.hasOwn(input.pointers, channel)) throw new Error("Missing channel pointer");
|
|
40
|
+
const value = input.pointers[channel];
|
|
41
|
+
const kinds = channel === "dev" ? ["dev"] : channel === "stable" ? ["stable"] : ["daily", "stable"];
|
|
42
|
+
if (value === null) {
|
|
43
|
+
if (ledger.releases.some((entry) => kinds.includes(entry.kind))) throw new Error("Missing active channel");
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const pointer = parseFeedRelease(value);
|
|
47
|
+
const newest = ledger.releases.filter((item) => kinds.includes(item.kind)).reduce((best, item) => !best || versionLessThan(best.tag, item.tag) ? item : best, void 0);
|
|
48
|
+
const release = releases.get(pointer.tag);
|
|
49
|
+
const entry = ledger.releases.find((item) => item.tag === pointer.tag);
|
|
50
|
+
if (!release || !entry || newest?.tag !== pointer.tag || pointer.channel !== channel || !kinds.includes(entry.kind) || pointer.publishedAt !== release.publishedAt || JSON.stringify(pointer.assets) !== JSON.stringify(release.assets) || channel === "stable" && JSON.stringify(pointer.missingPlatforms) !== JSON.stringify(release.missingPlatforms)) throw new Error("Inconsistent channel pointer");
|
|
51
|
+
protectedTags.add(pointer.tag);
|
|
52
|
+
}
|
|
53
|
+
for (const tag of protectedTags) if (!releases.has(tag)) throw new Error("Missing protected release");
|
|
54
|
+
const objects = /* @__PURE__ */ new Map();
|
|
55
|
+
for (const item of input.objects) {
|
|
56
|
+
if (objects.has(item.key) || !["payload", "provenance"].includes(item.role) || typeof item.version !== "string" || !item.version || !Number.isSafeInteger(item.size) || item.size < 1 || !/^[a-f0-9]{64}$/.test(item.sha256) || time(item.modifiedAt) > now) throw new Error("Invalid object identity");
|
|
57
|
+
objects.set(item.key, item);
|
|
58
|
+
}
|
|
59
|
+
const review = [];
|
|
60
|
+
let unprotectedDailyCount = 0;
|
|
61
|
+
for (const entry of ledger.releases) {
|
|
62
|
+
const release = releases.get(entry.tag);
|
|
63
|
+
if (!release || release.channel !== entry.kind || release.publishedAt !== entry.publishedAt) throw new Error("Inconsistent release ledger");
|
|
64
|
+
if (entry.kind === "dev" || entry.kind === "stable") protectedTags.add(entry.tag);
|
|
65
|
+
const releaseTime = Math.max(time(entry.publishedAt), entry.promotedAt ? time(entry.promotedAt) : 0);
|
|
66
|
+
if (releaseTime > now) throw new Error("Future release");
|
|
67
|
+
const releaseObjects = [];
|
|
68
|
+
for (const asset of release.assets) {
|
|
69
|
+
const key = feedAssetKey(feed, entry.tag, asset.name);
|
|
70
|
+
const item = objects.get(key);
|
|
71
|
+
if (!item || item.size !== asset.size || item.sha256 !== asset.sha256) throw new Error("Missing or inconsistent asset identity");
|
|
72
|
+
objects.delete(key);
|
|
73
|
+
releaseObjects.push(item);
|
|
74
|
+
}
|
|
75
|
+
if (!protectedTags.has(entry.tag)) {
|
|
76
|
+
unprotectedDailyCount++;
|
|
77
|
+
const lastChange = Math.max(releaseTime, ...releaseObjects.map((item) => time(item.modifiedAt)));
|
|
78
|
+
if (!input.lastExposedAt || !Object.hasOwn(input.lastExposedAt, entry.tag)) throw new Error("Missing last-exposure evidence");
|
|
79
|
+
const exposure = input.lastExposedAt[entry.tag];
|
|
80
|
+
if (typeof exposure !== "string") throw new Error("Missing last-exposure evidence");
|
|
81
|
+
const lastExposed = time(exposure);
|
|
82
|
+
if (lastExposed < releaseTime || lastExposed > now) throw new Error("Invalid last-exposure evidence");
|
|
83
|
+
const age = now - lastChange;
|
|
84
|
+
if (age >= input.discoveryGraceMs && now - lastExposed >= input.discoveryGraceMs && (age >= 7 * DAY || unprotectedDailyCount > 20)) review.push(...releaseObjects.filter((item) => item.role === "payload").map((item) => ({ ...item })));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (objects.size) throw new Error("Unaccounted release asset");
|
|
88
|
+
return {
|
|
89
|
+
mode: "advisory-only",
|
|
90
|
+
review,
|
|
91
|
+
protectedTags: [...protectedTags].toSorted()
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export { planRetentionDryRun };
|