@adea-ai/app-framework 0.30.0 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -11
- package/dist/app/application.js +4 -2
- package/dist/app/create-application.js +4 -3
- package/dist/app/serial-queue.d.ts +5 -0
- package/dist/app/serial-queue.js +14 -0
- package/dist/app/value-guards.d.ts +15 -0
- package/dist/app/value-guards.js +29 -0
- package/dist/appearance/appearance-host.js +6 -0
- package/dist/appearance/appearance-preferences.js +6 -2
- package/dist/appearance/composition.d.ts +1 -1
- package/dist/appearance/custom-theme-import.js +12 -19
- package/dist/appearance/custom-theme-library.d.ts +5 -4
- package/dist/appearance/custom-theme-library.js +20 -2
- package/dist/appearance/editor.js +4 -1
- package/dist/appearance/legacy-imported-theme-token-projection.d.ts +84 -0
- package/dist/appearance/legacy-imported-theme-token-projection.js +142 -0
- package/dist/appearance/theme-record-adapter.js +37 -9
- package/dist/ci/toolchain-identity.js +1 -1
- package/dist/desktop/channel-proof.js +2 -1
- package/dist/desktop/client-asset-stream.js +6 -12
- package/dist/desktop/desktop-host.d.ts +25 -5
- package/dist/desktop/desktop-host.js +75 -20
- package/dist/framework-source.json +1 -1
- package/dist/installer/command-artifact.js +4 -3
- package/dist/installer/command-qualification-command.js +6 -5
- package/dist/installer/hosted-runner.d.ts +9 -2
- package/dist/installer/hosted-runner.js +18 -5
- package/dist/installer/installed-payload.js +20 -46
- package/dist/installer/installer-archive.d.ts +33 -0
- package/dist/installer/installer-archive.js +116 -0
- package/dist/installer/installer-ci-bootstrap.js +10 -6
- package/dist/installer/installer-extraction.js +54 -120
- package/dist/installer/installer-identity.js +33 -111
- package/dist/installer/installer-observation.js +3 -2
- package/dist/installer/installer-process-cleanup.js +7 -46
- package/dist/installer/installer-qualification-command.js +6 -5
- package/dist/installer/installer-upgrade-command.js +5 -5
- package/dist/installer/installer-worker-guard.js +2 -1
- package/dist/native/canonical-path.d.ts +5 -0
- package/dist/native/canonical-path.js +10 -0
- package/dist/native/cef-helper.js +5 -4
- package/dist/native/electrobun-source-patch.js +3 -2
- package/dist/native/{directory-exchange.d.ts → native-rename.d.ts} +2 -0
- package/dist/native/native-rename.js +126 -0
- package/dist/native/native-secret-store.js +2 -6
- package/dist/native/native-utilities.js +4 -4
- package/dist/native/posix-launcher-build.js +1 -1
- package/dist/native/posix-tree-removal.js +2 -2
- package/dist/native/windows-process.d.ts +9 -0
- package/dist/native/windows-process.js +60 -0
- package/dist/release/feed-release-cut.js +2 -1
- package/dist/release/framework-package-publish.js +1 -1
- package/dist/release/framework-update-lock.js +2 -1
- package/dist/release/github-cli.d.ts +18 -0
- package/dist/release/github-cli.js +13 -1
- package/dist/release/github-release-cut.js +3 -2
- package/dist/release/github-release-provenance.js +2 -1
- package/dist/release/github-release-publisher.js +2 -1
- package/dist/release/local-provenance.js +3 -2
- package/dist/release/local-release.js +6 -6
- package/dist/release/qualification-run.d.ts +25 -0
- package/dist/release/qualification-run.js +43 -0
- package/dist/release/release-artifact.js +3 -11
- package/dist/release/release-assets-plan.js +16 -6
- package/dist/release/release-config.js +14 -14
- package/dist/release/release-cut-command.js +14 -4
- package/dist/release/release-cut.js +3 -2
- package/dist/release/release-descriptor-staging.js +13 -27
- package/dist/release/release-finalize.js +2 -1
- package/dist/release/release-publication.js +3 -11
- package/dist/release/release-publish-command.js +15 -6
- package/dist/release/release-qualification.js +3 -2
- package/dist/release/retained-release-build.js +12 -12
- package/dist/shell/app-shell.js +76 -48
- package/dist/shell/app-utilities.d.ts +5 -3
- package/dist/shell/app-utilities.js +15 -7
- package/dist/shell/help-shortcuts.d.ts +4 -0
- package/dist/shell/help-shortcuts.js +38 -7
- package/dist/shell/keyboard-target.d.ts +2 -0
- package/dist/shell/keyboard-target.js +54 -0
- package/dist/shell/settings-sections.d.ts +5 -0
- package/dist/shell/settings-shortcuts.d.ts +10 -0
- package/dist/shell/settings-shortcuts.js +67 -0
- package/dist/update-helper.bundle.js +250 -190
- package/dist/updates/desktop-updater.js +53 -58
- package/dist/updates/packaged-launch-admission.js +3 -2
- package/dist/updates/packaged-release-config.js +6 -5
- package/dist/updates/release-feed.js +9 -9
- package/dist/updates/signed-release.js +5 -5
- package/dist/updates/stable-file.d.ts +18 -0
- package/dist/updates/stable-file.js +54 -1
- package/dist/updates/update-adapter.d.ts +2 -13
- package/dist/updates/update-arm.js +7 -5
- package/dist/updates/update-channel-store.js +7 -9
- package/dist/updates/update-discovery.js +30 -34
- package/dist/updates/update-download-cleanup.js +2 -1
- package/dist/updates/update-download.js +2 -4
- package/dist/updates/update-extraction.js +1 -1
- package/dist/updates/update-generation-lease.js +4 -3
- package/dist/updates/update-handoff-plan.js +3 -2
- package/dist/updates/update-helper.js +8 -6
- package/dist/updates/update-instance-lease.js +3 -2
- package/dist/updates/update-launch-gate.js +12 -25
- package/dist/updates/update-launch.js +3 -2
- package/dist/updates/update-lock.js +3 -2
- package/dist/updates/update-marker.js +3 -2
- package/dist/updates/update-process-fence.js +10 -39
- package/dist/updates/update-process-liveness.js +2 -1
- package/dist/updates/update-resume.js +26 -22
- package/dist/updates/update-retention-marker.js +7 -5
- package/dist/updates/update-retention-plan.js +2 -2
- package/dist/updates/update-retirement.js +40 -39
- package/dist/updates/update-state-store.js +29 -37
- package/dist/updates/update-state.d.ts +8 -3
- package/dist/updates/update-swap-stage.js +6 -5
- package/dist/updates/update-swap.d.ts +1 -1
- package/dist/updates/update-swap.js +8 -6
- package/dist/views/app-help.js +2 -1
- package/dist/views/app-settings.js +5 -2
- package/dist/views/appearance-surface.js +33 -19
- package/package.json +7 -13
- package/src/app/application.tsx +3 -1
- package/src/appearance/appearance-host.tsx +6 -0
- package/src/appearance/appearance-preferences.ts +7 -1
- package/src/appearance/composition.ts +3 -1
- package/src/appearance/custom-theme-import.ts +21 -37
- package/src/appearance/custom-theme-library.ts +21 -5
- package/src/appearance/editor.ts +7 -6
- package/src/appearance/legacy-imported-theme-token-projection.ts +51 -0
- package/src/appearance/theme-record-adapter.ts +58 -11
- package/src/desktop/client-asset-stream.ts +6 -12
- package/src/shell/app-shell.tsx +88 -58
- package/src/shell/app-utilities.tsx +29 -17
- package/src/shell/help-shortcuts.ts +77 -6
- package/src/shell/keyboard-target.ts +74 -0
- package/src/shell/settings-sections.ts +5 -0
- package/src/shell/settings-shortcuts.ts +116 -0
- package/src/updates/update-adapter.ts +2 -14
- package/src/updates/update-state.ts +11 -2
- package/src/views/app-settings.tsx +5 -3
- package/src/views/appearance-surface.tsx +63 -27
- package/dist/native/directory-exchange.js +0 -90
- package/dist/native/exclusive-rename.d.ts +0 -2
- package/dist/native/exclusive-rename.js +0 -52
- package/dist/release/retention-dry-run.d.ts +0 -46
- package/dist/release/retention-dry-run.js +0 -94
- package/dist/updates/update-exclusive-rename.d.ts +0 -3
- package/dist/updates/update-exclusive-rename.js +0 -5
|
@@ -2,7 +2,7 @@ import { SettingsLayout } from '@adea-ai/ui/components/composites/settings'
|
|
|
2
2
|
import { ModalDialog } from '@adea-ai/ui/components/ui/modal-dialog'
|
|
3
3
|
import { TabsContent } from '@adea-ai/ui/components/ui/tabs'
|
|
4
4
|
import { Text } from '@adea-ai/ui/components/ui/typography'
|
|
5
|
-
import { For, Show, untrack, type Accessor, type JSX } from 'solid-js'
|
|
5
|
+
import { createMemo, For, Show, untrack, type Accessor, type JSX } from 'solid-js'
|
|
6
6
|
|
|
7
7
|
import { settingsGroups, type ApplicationSettingsSection } from '../shell/settings-sections'
|
|
8
8
|
|
|
@@ -31,8 +31,10 @@ export type ApplicationSettingsPanelProps = {
|
|
|
31
31
|
* settings as a page. `ApplicationSettings` shows the same panel in a dialog.
|
|
32
32
|
*/
|
|
33
33
|
export function ApplicationSettingsPanel(props: ApplicationSettingsPanelProps) {
|
|
34
|
-
const active = () =>
|
|
35
|
-
|
|
34
|
+
const active = createMemo(() => {
|
|
35
|
+
const selected = props.section
|
|
36
|
+
return props.sections.find((section) => section.id === selected) ?? props.sections[0]
|
|
37
|
+
})
|
|
36
38
|
// Panels are keyed by section id, not by section object, so a caller that rebuilds its
|
|
37
39
|
// section list (an inline config read again) keeps the open panel mounted with its state;
|
|
38
40
|
// only the description follows the list. Panels are built inside the layout, whose tabs
|
|
@@ -32,10 +32,18 @@ import { Button } from '@adea-ai/ui/components/ui/button'
|
|
|
32
32
|
import { Input } from '@adea-ai/ui/components/ui/input'
|
|
33
33
|
import { ModalDialog } from '@adea-ai/ui/components/ui/modal-dialog'
|
|
34
34
|
import { Heading } from '@adea-ai/ui/components/ui/typography'
|
|
35
|
-
import {
|
|
35
|
+
import {
|
|
36
|
+
batch,
|
|
37
|
+
createEffect,
|
|
38
|
+
createMemo,
|
|
39
|
+
createSignal,
|
|
40
|
+
For,
|
|
41
|
+
onCleanup,
|
|
42
|
+
onMount,
|
|
43
|
+
Show,
|
|
44
|
+
untrack,
|
|
45
|
+
} from 'solid-js'
|
|
36
46
|
import { MonitorCog } from 'lucide-solid'
|
|
37
|
-
|
|
38
|
-
import { For, Show } from 'solid-js'
|
|
39
47
|
import { themeAccentsForRecords } from '@adea-ai/ui/lib/theme-projection'
|
|
40
48
|
|
|
41
49
|
import { draftVariants } from '../appearance/composition'
|
|
@@ -100,7 +108,6 @@ function AppearanceHost(props: { popover?: AppearanceControlProps }) {
|
|
|
100
108
|
const [accentStatus, setAccentStatus] = createSignal('')
|
|
101
109
|
const [libraryOpen, setLibraryOpen] = createSignal(false)
|
|
102
110
|
|
|
103
|
-
const miniatures = createMemo(() => draftVariants(editor.draft()))
|
|
104
111
|
// Imported themes: refreshed through the registry subscription so the
|
|
105
112
|
// picker and this dialog track imports and removals without prop drilling.
|
|
106
113
|
const [library, setLibrary] = createSignal(readCustomThemeLibrary(defaultPreferenceStorage()))
|
|
@@ -110,12 +117,19 @@ function AppearanceHost(props: { popover?: AppearanceControlProps }) {
|
|
|
110
117
|
subscribeCustomThemes(() => setLibrary(readCustomThemeLibrary(defaultPreferenceStorage())))
|
|
111
118
|
)
|
|
112
119
|
})
|
|
113
|
-
//
|
|
114
|
-
//
|
|
115
|
-
const themes = () => {
|
|
120
|
+
// Imported records are a projection of the library, not of the draft. Keep
|
|
121
|
+
// the catalogue stable while controls update; imports and removals invalidate it.
|
|
122
|
+
const themes = createMemo(() => {
|
|
116
123
|
library()
|
|
117
124
|
return allThemeRecords()
|
|
118
|
-
}
|
|
125
|
+
})
|
|
126
|
+
const lightThemeId = createMemo(() => editor.draft().lightThemeId)
|
|
127
|
+
const darkThemeId = createMemo(() => editor.draft().darkThemeId)
|
|
128
|
+
const miniatures = createMemo(() => {
|
|
129
|
+
// A selected imported theme can arrive, change, or disappear in another context.
|
|
130
|
+
library()
|
|
131
|
+
return draftVariants({ lightThemeId: lightThemeId(), darkThemeId: darkThemeId() })
|
|
132
|
+
})
|
|
119
133
|
const [importStatus, setImportStatus] = createSignal('')
|
|
120
134
|
const [importPending, setImportPending] = createSignal(false)
|
|
121
135
|
const themeActionFence = createThemeLibraryActionFence(setImportStatus)
|
|
@@ -166,10 +180,11 @@ function AppearanceHost(props: { popover?: AppearanceControlProps }) {
|
|
|
166
180
|
}
|
|
167
181
|
|
|
168
182
|
const themeAccentOptions = createMemo(() => {
|
|
169
|
-
const draft = editor.draft()
|
|
170
183
|
const records = themes()
|
|
171
|
-
const
|
|
172
|
-
const
|
|
184
|
+
const lightId = lightThemeId()
|
|
185
|
+
const darkId = darkThemeId()
|
|
186
|
+
const light = records.find((record) => record.id === lightId)
|
|
187
|
+
const dark = records.find((record) => record.id === darkId)
|
|
173
188
|
return light && dark ? themeAccentsForRecords(light, dark) : []
|
|
174
189
|
})
|
|
175
190
|
|
|
@@ -193,9 +208,13 @@ function AppearanceHost(props: { popover?: AppearanceControlProps }) {
|
|
|
193
208
|
const mode = editor.draft().mode
|
|
194
209
|
if (mode === 'light') return variants.light
|
|
195
210
|
if (mode === 'dark') return variants.dark
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
211
|
+
// The document may still show the prior preview during a batched switch
|
|
212
|
+
// to System. Resolve the requested mode the same way the provider does.
|
|
213
|
+
const systemIsDark =
|
|
214
|
+
typeof window !== 'undefined' &&
|
|
215
|
+
typeof window.matchMedia === 'function' &&
|
|
216
|
+
window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
217
|
+
return systemIsDark ? variants.dark : variants.light
|
|
199
218
|
}
|
|
200
219
|
|
|
201
220
|
const preview = () => appearance.preview(editor.draft())
|
|
@@ -214,7 +233,11 @@ function AppearanceHost(props: { popover?: AppearanceControlProps }) {
|
|
|
214
233
|
preview()
|
|
215
234
|
}
|
|
216
235
|
|
|
217
|
-
const setAccent = (value: string) => {
|
|
236
|
+
const setAccent = (value: string, otherChanges: Partial<AppearancePreferencesV2>) => {
|
|
237
|
+
// Apply the other fields first so custom-accent validation uses the theme
|
|
238
|
+
// selected by the same patch. Publish only the resulting combined draft.
|
|
239
|
+
const before = editor.draft()
|
|
240
|
+
editor.set(otherChanges)
|
|
218
241
|
if (value === 'theme' || accentPresetById(value) || isThemeAccentId(value)) {
|
|
219
242
|
setCustomAccent('')
|
|
220
243
|
setRawCustomAccent('')
|
|
@@ -229,6 +252,7 @@ function AppearanceHost(props: { popover?: AppearanceControlProps }) {
|
|
|
229
252
|
// in the controlled published editor for correction and recovery.
|
|
230
253
|
setRawCustomAccent(value)
|
|
231
254
|
setAccentStatus(validation.error ?? 'Invalid custom accent.')
|
|
255
|
+
if (editor.draft() !== before) preview()
|
|
232
256
|
return
|
|
233
257
|
}
|
|
234
258
|
setCustomAccent(validation.value)
|
|
@@ -237,17 +261,21 @@ function AppearanceHost(props: { popover?: AppearanceControlProps }) {
|
|
|
237
261
|
setDraft({ accent: validation.value })
|
|
238
262
|
}
|
|
239
263
|
|
|
240
|
-
const onChange = (patch: Partial<AppearanceDraft>) =>
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
264
|
+
const onChange = (patch: Partial<AppearanceDraft>) =>
|
|
265
|
+
batch(() => {
|
|
266
|
+
const { accent, surface, ...rest } = patch
|
|
267
|
+
const otherChanges: Partial<AppearancePreferencesV2> = {
|
|
268
|
+
...rest,
|
|
269
|
+
...(surface === undefined
|
|
270
|
+
? {}
|
|
271
|
+
: { surface: surface === 'theme' ? 'translucent' : surface }),
|
|
272
|
+
}
|
|
273
|
+
if (accent !== undefined) {
|
|
274
|
+
setAccent(accent, otherChanges)
|
|
275
|
+
return
|
|
276
|
+
}
|
|
277
|
+
setDraft(otherChanges)
|
|
278
|
+
})
|
|
251
279
|
|
|
252
280
|
const save = () => {
|
|
253
281
|
// The embedded section's published action stays disabled until the draft
|
|
@@ -301,7 +329,15 @@ function AppearanceHost(props: { popover?: AppearanceControlProps }) {
|
|
|
301
329
|
return appearanceThemeForPreview(miniatures().dark, editor.draft().accent, editor.draft())
|
|
302
330
|
},
|
|
303
331
|
get resolvedAppearance() {
|
|
304
|
-
|
|
332
|
+
// The editor's `system` draft previews the appearance the provider is
|
|
333
|
+
// currently showing. `resolvedAppearance()` remains committed by contract;
|
|
334
|
+
// older shared UI releases and context mocks do not expose the additive API.
|
|
335
|
+
const shownAppearance = (
|
|
336
|
+
appearance as typeof appearance & {
|
|
337
|
+
shownAppearance?: () => 'light' | 'dark'
|
|
338
|
+
}
|
|
339
|
+
).shownAppearance
|
|
340
|
+
return shownAppearance?.() ?? appearance.resolvedAppearance()
|
|
305
341
|
},
|
|
306
342
|
get themes() {
|
|
307
343
|
return themes()
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
2
|
-
import { isAbsolute, join, resolve } from "node:path";
|
|
3
|
-
import { FFIType, dlopen, ptr } from "bun:ffi";
|
|
4
|
-
import { randomUUID } from "node:crypto";
|
|
5
|
-
// src/native/directory-exchange.ts
|
|
6
|
-
var RENAME_EXCHANGE = 2;
|
|
7
|
-
/** Atomically exchange two existing paths on supported Darwin and Linux filesystems. */
|
|
8
|
-
function exchangeDirectories(source, destination) {
|
|
9
|
-
if (typeof source !== "string" || typeof destination !== "string" || !isAbsolute(source) || !isAbsolute(destination) || resolve(source) !== source || resolve(destination) !== destination || source === destination || source.includes("\0") || destination.includes("\0")) throw new Error("Invalid atomic directory exchange paths");
|
|
10
|
-
if (process.platform === "darwin") {
|
|
11
|
-
const library = dlopen("libSystem.B.dylib", { renamex_np: {
|
|
12
|
-
args: [
|
|
13
|
-
FFIType.ptr,
|
|
14
|
-
FFIType.ptr,
|
|
15
|
-
FFIType.u32
|
|
16
|
-
],
|
|
17
|
-
returns: FFIType.i32
|
|
18
|
-
} });
|
|
19
|
-
try {
|
|
20
|
-
const from = Buffer.from(source + "\0"), to = Buffer.from(destination + "\0");
|
|
21
|
-
if (library.symbols.renamex_np(ptr(from), ptr(to), RENAME_EXCHANGE) !== 0) throw new Error("Atomic directory exchange is unsupported or failed");
|
|
22
|
-
} finally {
|
|
23
|
-
library.close();
|
|
24
|
-
}
|
|
25
|
-
} else if (process.platform === "linux") {
|
|
26
|
-
const library = dlopen("libc.so.6", { renameat2: {
|
|
27
|
-
args: [
|
|
28
|
-
FFIType.i32,
|
|
29
|
-
FFIType.ptr,
|
|
30
|
-
FFIType.i32,
|
|
31
|
-
FFIType.ptr,
|
|
32
|
-
FFIType.u32
|
|
33
|
-
],
|
|
34
|
-
returns: FFIType.i32
|
|
35
|
-
} });
|
|
36
|
-
try {
|
|
37
|
-
const from = Buffer.from(source + "\0"), to = Buffer.from(destination + "\0");
|
|
38
|
-
if (library.symbols.renameat2(-100, ptr(from), -100, ptr(to), RENAME_EXCHANGE) !== 0) throw new Error("Atomic directory exchange is unsupported or failed");
|
|
39
|
-
} finally {
|
|
40
|
-
library.close();
|
|
41
|
-
}
|
|
42
|
-
} else throw new Error("Atomic directory exchange is unsupported on this platform");
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Exercise the actual volume using two disposable directories before exchanging
|
|
46
|
-
* an install tree. This qualifies only that same-volume probe pair; it cannot
|
|
47
|
-
* prove a provider will behave identically for every later object or survive a
|
|
48
|
-
* power failure. The caller also verifies the real trees' versions and inode
|
|
49
|
-
* identities immediately after the exchange.
|
|
50
|
-
*/
|
|
51
|
-
async function probeDirectoryExchange(parent, exchange = exchangeDirectories) {
|
|
52
|
-
if (typeof parent !== "string" || !isAbsolute(parent) || resolve(parent) !== parent || parent.includes("\0")) throw new Error("Invalid directory exchange probe parent");
|
|
53
|
-
const id = randomUUID();
|
|
54
|
-
const first = join(parent, `.framework-exchange-probe-${id}-a`);
|
|
55
|
-
const second = join(parent, `.framework-exchange-probe-${id}-b`);
|
|
56
|
-
const marker = "exchange-probe";
|
|
57
|
-
const firstValue = `${id}:first`;
|
|
58
|
-
const secondValue = `${id}:second`;
|
|
59
|
-
let firstCreated = false;
|
|
60
|
-
let secondCreated = false;
|
|
61
|
-
try {
|
|
62
|
-
await mkdir(first, { mode: 448 });
|
|
63
|
-
firstCreated = true;
|
|
64
|
-
await mkdir(second, { mode: 448 });
|
|
65
|
-
secondCreated = true;
|
|
66
|
-
await writeFile(join(first, marker), firstValue, {
|
|
67
|
-
flag: "wx",
|
|
68
|
-
mode: 384
|
|
69
|
-
});
|
|
70
|
-
await writeFile(join(second, marker), secondValue, {
|
|
71
|
-
flag: "wx",
|
|
72
|
-
mode: 384
|
|
73
|
-
});
|
|
74
|
-
exchange(first, second);
|
|
75
|
-
const [firstAfter, secondAfter] = await Promise.all([readFile(join(first, marker), "utf8"), readFile(join(second, marker), "utf8")]);
|
|
76
|
-
if (firstAfter !== secondValue || secondAfter !== firstValue) throw new Error("Directory exchange did not exchange both probe trees");
|
|
77
|
-
} finally {
|
|
78
|
-
const cleanup = [];
|
|
79
|
-
if (firstCreated) cleanup.push(rm(first, {
|
|
80
|
-
recursive: true,
|
|
81
|
-
force: true
|
|
82
|
-
}));
|
|
83
|
-
if (secondCreated) cleanup.push(rm(second, {
|
|
84
|
-
recursive: true,
|
|
85
|
-
force: true
|
|
86
|
-
}));
|
|
87
|
-
await Promise.all(cleanup);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
export { exchangeDirectories, probeDirectoryExchange };
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { isAbsolute, resolve } from "node:path";
|
|
2
|
-
import { FFIType, dlopen, ptr } from "bun:ffi";
|
|
3
|
-
// src/native/exclusive-rename.ts
|
|
4
|
-
/** Rename without replacing an existing destination on supported desktop platforms. */
|
|
5
|
-
function renameExclusive(source, destination) {
|
|
6
|
-
if (typeof source !== "string" || typeof destination !== "string" || !isAbsolute(source) || !isAbsolute(destination) || resolve(source) !== source || resolve(destination) !== destination || source === destination || source.includes("\0") || destination.includes("\0")) throw new Error("Invalid exclusive rename paths");
|
|
7
|
-
if (process.platform === "darwin") {
|
|
8
|
-
const library = dlopen("libSystem.B.dylib", { renamex_np: {
|
|
9
|
-
args: [
|
|
10
|
-
FFIType.ptr,
|
|
11
|
-
FFIType.ptr,
|
|
12
|
-
FFIType.u32
|
|
13
|
-
],
|
|
14
|
-
returns: FFIType.i32
|
|
15
|
-
} });
|
|
16
|
-
try {
|
|
17
|
-
const from = Buffer.from(source + "\0"), to = Buffer.from(destination + "\0");
|
|
18
|
-
if (library.symbols.renamex_np(ptr(from), ptr(to), 4) !== 0) throw new Error("Exclusive rename failed");
|
|
19
|
-
} finally {
|
|
20
|
-
library.close();
|
|
21
|
-
}
|
|
22
|
-
} else if (process.platform === "linux") {
|
|
23
|
-
const library = dlopen("libc.so.6", { renameat2: {
|
|
24
|
-
args: [
|
|
25
|
-
FFIType.i32,
|
|
26
|
-
FFIType.ptr,
|
|
27
|
-
FFIType.i32,
|
|
28
|
-
FFIType.ptr,
|
|
29
|
-
FFIType.u32
|
|
30
|
-
],
|
|
31
|
-
returns: FFIType.i32
|
|
32
|
-
} });
|
|
33
|
-
try {
|
|
34
|
-
const from = Buffer.from(source + "\0"), to = Buffer.from(destination + "\0");
|
|
35
|
-
if (library.symbols.renameat2(-100, ptr(from), -100, ptr(to), 1) !== 0) throw new Error("Exclusive rename failed");
|
|
36
|
-
} finally {
|
|
37
|
-
library.close();
|
|
38
|
-
}
|
|
39
|
-
} else if (process.platform === "win32") {
|
|
40
|
-
const library = dlopen("kernel32.dll", { MoveFileW: {
|
|
41
|
-
args: [FFIType.ptr, FFIType.ptr],
|
|
42
|
-
returns: FFIType.i32
|
|
43
|
-
} });
|
|
44
|
-
try {
|
|
45
|
-
const from = Buffer.from(source + "\0", "utf16le"), to = Buffer.from(destination + "\0", "utf16le");
|
|
46
|
-
if (library.symbols.MoveFileW(ptr(from), ptr(to)) === 0) throw new Error("Exclusive rename failed");
|
|
47
|
-
} finally {
|
|
48
|
-
library.close();
|
|
49
|
-
}
|
|
50
|
-
} else throw new Error("Unsupported exclusive rename platform");
|
|
51
|
-
}
|
|
52
|
-
export { renameExclusive };
|
|
@@ -1,46 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,94 +0,0 @@
|
|
|
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 };
|