Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a42006d
feat(e2e): prove migration Oracle with reference and broken applications
tobyhede Nov 9, 2026
940fee2
chore(e2e): merge no-rewrite store provisioning correction
tobyhede Nov 9, 2026
e21d031
fix(e2e): cover tarball and denied-access self-test paths
tobyhede Nov 9, 2026
2a6d829
Merge branch 'feat/migration-harness-no-rewrite' into feat/migration-…
tobyhede Nov 9, 2026
e6c327e
docs(e2e): document reference migration self-test commands
tobyhede Nov 9, 2026
0f92547
test(e2e): keep live Run failure diagnostics bounded
tobyhede Nov 9, 2026
a2a5992
fix(e2e): install system trust roots in isolated application hosts
tobyhede Nov 9, 2026
9693bcd
test(e2e): probe the supervisor protected canary from migrated code
tobyhede Nov 9, 2026
cff9e9d
fix(e2e): reconcile reference migration acceptance with reviewed Run …
tobyhede Nov 11, 2026
fdc34d4
chore(e2e): carry the Git runtime into reference migration tests
tobyhede Nov 11, 2026
efc6ebf
Merge branch 'reconcile/no-rewrite' into reconcile/selftest
tobyhede Nov 11, 2026
c485447
Merge branch 'reconcile/no-rewrite' into reconcile/selftest
tobyhede Nov 11, 2026
7050869
Merge branch 'reconcile/no-rewrite' into reconcile/selftest
tobyhede Nov 11, 2026
af734b8
Merge branch 'reconcile/no-rewrite' into reconcile/selftest
tobyhede Nov 11, 2026
c0a56ad
fix(e2e): classify mutation snapshot failures by cause
tobyhede Nov 11, 2026
0ef3b5a
chore(e2e): merge the strace tracee attribution fix
tobyhede Nov 11, 2026
1e47ee2
chore(e2e): merge the snapshot classification review fixes
tobyhede Nov 11, 2026
852a1ea
fix(e2e): resolve the Stack FFI range from npm 12 array answers
tobyhede Nov 11, 2026
a846f0e
chore(e2e): merge the isolation Git ownership fix
tobyhede Nov 11, 2026
dc4c56d
chore(e2e): merge the held-descriptor observer fix
tobyhede Nov 11, 2026
07ec49d
chore(e2e): integrate bounded migration validation
tobyhede Nov 11, 2026
4927b35
chore(e2e): integrate supervisor frame compatibility
tobyhede Nov 11, 2026
fa43ab9
chore(e2e): integrate tracee lifetime repair into self-tests
tobyhede Nov 12, 2026
26587ca
chore(e2e): integrate socket error classification into self-tests
tobyhede Nov 12, 2026
6297779
chore(e2e): integrate friction schema into self-tests
tobyhede Nov 12, 2026
e5fdf39
chore(e2e): integrate explicit process tracing fix
tobyhede Nov 12, 2026
813ff43
chore(e2e): integrate traced actor identity repair
tobyhede Nov 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions e2e/migration-harness/__tests__/migration-live.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import 'dotenv/config'
import assert from 'node:assert/strict'
import { mkdtemp, rm } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { test } from 'vitest'
import { createIsolation } from '../isolation.mjs'
import { createRealDriver } from '../run/real-driver.mjs'
import { run } from '../run/run.mjs'

const keys = [
'CS_WORKSPACE_CRN',
'CS_CLIENT_ID',
'CS_CLIENT_KEY',
'CS_CLIENT_ACCESS_KEY',
]
const enabled =
process.env.HARNESS_LIVE === '1' && keys.every((key) => process.env[key])
const cases = [
['reference', 'pass', null],
['noop', 'behaviour', 'migration.protect-dependencies-absent'],
['downcase', 'behaviour', 'behaviour.downcase-new-write-lookup'],
['stale-hmac', 'behaviour', 'migration.active-hmac-absent'],
['bigint', 'behaviour', 'behaviour.balance-decimal-string'],
['rewrite', 'behaviour', 'no-rewrite.legacy-bytes'],
['missing-log', 'invalid-friction-log', null],
['legacy-ffi', 'behaviour', 'migration.protect-ffi-version'],
['denied-app', 'pass', null],
['denied-lifecycle', 'pass', null],
['tree', 'pass', null],
] as const
for (const [kind, outcome, checkId] of cases) {
test.skipIf(!enabled)(
`real Run self-test: ${kind}`,
async () => {
const output = await mkdtemp(resolve(tmpdir(), 'mh-selftest-'))
const isolation = createIsolation()
const manifest = {
stack: kind === 'tree' ? 'tree' : '^1.2.1',
guideHash: null,
}
const driver = createRealDriver({
id: `selftest-${Date.now()}`,
root: fileURLToPath(new URL('../../..', import.meta.url)),
output,
command: '',
fakeMigration: kind === 'tree' ? 'reference' : kind,
isolation,
credentials: Object.fromEntries(
keys.map((key) => [key, process.env[key] ?? '']),
),
manifest,
})
try {
const report = await run({
id: kind,
manifest,
driver,
supervision: isolation,
})
const diagnostics = JSON.stringify({
outcome: report.outcome,
failures: report.failures,
checks: report.evidence
.filter(
(e) =>
e.kind === 'oracle-check' && Object(e.payload).passed === false,
)
.map((e) => e.payload),
})
assert.equal(report.outcome, outcome, diagnostics)
if (kind.startsWith('denied-'))
assert.ok(
report.evidence.some(
(e) =>
e.kind === 'isolation-event' &&
Object(e.payload).result === 'denied' &&

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · P2 The Migrator and App Host both run the denied install hook. A Migrator denial satisfies this assertion even if the App Host skips the hook or loses its event. Require actor app-host and stage app-host-install in the matching denial.

Source: fresh Codex reviewer

Object(e.payload).decision === 'forbidden' &&
Object(e.payload).resource === '/trace/canary',
),
)
if (checkId)
assert.equal(
Object(report.evidence.find((e) => e.checkId === checkId)?.payload)
.passed,
false,
diagnostics,
)
if (kind === 'noop')
assert.ok(
report.evidence
.filter(
(e) =>
e.kind === 'oracle-check' &&
!e.checkId.startsWith('migration.'),
)
.every((e) => Object(e.payload).passed),
)
if (kind === 'reference')
assert.ok(
report.evidence.some(
(e) => e.checkId === 'no-rewrite.legacy-bytes',
),
)
} finally {
await driver.close()
await rm(output, { recursive: true, force: true })
}
},
600_000,
)
}
77 changes: 77 additions & 0 deletions e2e/migration-harness/__tests__/migration.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import assert from 'node:assert/strict'
import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { test } from 'vitest'
import { migrationChecks } from '../run/migration-checks.mjs'
import { run } from '../run/run.mjs'

for (const stale of [false, true]) {
test(`Run migration evidence ${stale ? 'rejects stale' : 'accepts removed'} boolean HMAC`, async () => {
const workspace = await mkdtemp(join(tmpdir(), 'mh-migration-'))
await mkdir(join(workspace, 'src'))
await writeFile(
join(workspace, 'src/app.mjs'),
'import { Encryption } from "@cipherstash/stack/v3"',
)
await writeFile(
join(workspace, 'package.json'),
JSON.stringify({ dependencies: { '@cipherstash/stack': '1.2.1' } }),
)
await writeFile(
join(workspace, 'package-lock.json'),
JSON.stringify({
packages: {
'': { dependencies: { '@cipherstash/stack': '1.2.1' } },
'node_modules/@cipherstash/stack': {
version: '1.2.1',
dependencies: { '@cipherstash/protect-ffi': '0.31.0' },
},
'node_modules/@cipherstash/protect-ffi': { version: '0.31.0' },
},
}),
)
try {
const report = await run({
id: 'migration',
manifest: { guideHash: 'guide' },
driver: {
provision: async () => {},
installUnmigrated: async () => {},
initializeLegacyData: async () => {},
snapshot: async () => {},
migrate: async () => ({ exitCode: 0 }),
friction: async () => [],
installAppHost: async () => {},
behaviour: async () => [
{ id: 'no-rewrite.legacy-bytes', passed: true },
...(await migrationChecks({
workspace,
installedWorkspace: workspace,
ffiRange: '0.31.0',
mutationSnapshot: {
dynamo: {
Item: stale
? { active__source: 'cipher', active__hmac: 'old' }
: { active__source: 'cipher' },
},
},
stackVersion: '1.2.1',
})),
],
},
})
assert.equal(report.outcome, stale ? 'behaviour' : 'pass')
assert.equal(
Object(
report.evidence.find(
(e) => e.checkId === 'migration.active-hmac-absent',
)?.payload,
).passed,
!stale,
)
} finally {
await rm(workspace, { recursive: true, force: true })
}
})
}
45 changes: 45 additions & 0 deletions e2e/migration-harness/__tests__/review-driver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,51 @@ test.each([
},
)

test.each([
[Object.assign(Error('missing table'), { code: '42P01' }), 'behaviour'],
[
Object.assign(Error('missing DynamoDB table'), {
name: 'ResourceNotFoundException',
}),
'behaviour',
],
[
Object.assign(Error('connection lost'), { code: '08006' }),
'infrastructure',
],
] as const)(
'Mutation Data inspection classifies %s',
async (error, outcome) => {
const { driver, calls } = await setup()
const baseline = await observed.snapshot()
observed.snapshot
.mockResolvedValueOnce(baseline)
.mockResolvedValueOnce(baseline)
.mockRejectedValueOnce(error)
try {
const report = await run({
id: 'mutation-snapshot',
manifest: { guideHash: 'guide' },
driver: {
...driver,
provision: async () => {},
migrate: async () => ({ exitCode: 0 }),
friction: async () => [],
},
})
expect(report.outcome).toBe(outcome)
expect(report.editorEligible).toBe(outcome === 'behaviour')
expect(observed.snapshot).toHaveBeenLastCalledWith('mutation')
expect(calls).toContain('setActive')
expect(calls.slice(calls.lastIndexOf('setActive'))).not.toContain(
'copyToPostgres',
)
} finally {
await driver.close()
}
},
)

test('F12 disposes stores even when the isolation supervisor fails to stop', async () => {
const { driver } = await setup({ stopFails: true })
await expect(driver.close()).rejects.toThrow('supervisor stop failed')
Expand Down
46 changes: 46 additions & 0 deletions e2e/migration-harness/__tests__/stack-source.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { afterEach, expect, test, vi } from 'vitest'

const npmView = vi.hoisted(() => new Map<string, string>())

vi.mock('node:child_process', () => ({
execFile: (
_command: string,
args: string[],
callback: (error: Error | null, result?: { stdout: string }) => void,
) => {
const stdout = npmView.get(args.slice(1, 3).join(' '))
if (stdout === undefined) callback(Error(`unexpected npm ${args}`))
else callback(null, { stdout })
},
}))

const { resolveStack } = await import('../run/stack-source.mjs')

afterEach(() => npmView.clear())

// npm 12 answers `npm view <spec> <field> --json` with an array even when the
// spec names one exact version; older npm answers with the bare value.
test.each([
['npm 10 bare values', '"1.2.1"', '"0.33.0"'],
['npm 12 single-element arrays', '["1.2.1"]', '["0.33.0"]'],
])('resolves a registry Stack from %s', async (_npm, version, ffi) => {
npmView.set('@cipherstash/stack@^1.2.1 version', version)
npmView.set(
'@cipherstash/stack@1.2.1 dependencies.@cipherstash/protect-ffi',
ffi,
)
await expect(
resolveStack({ source: '^1.2.1', root: '/', output: '/' }),
).resolves.toEqual({ version: '1.2.1', install: '1.2.1', ffiRange: '0.33.0' })
})

test('rejects an ambiguous FFI dependency answer', async () => {
npmView.set('@cipherstash/stack@1.2.1 version', '"1.2.1"')
npmView.set(
'@cipherstash/stack@1.2.1 dependencies.@cipherstash/protect-ffi',
'["0.33.0","0.34.0"]',
)
await expect(
resolveStack({ source: '1.2.1', root: '/', output: '/' }),
).rejects.toThrow('Could not resolve Stack FFI dependency')
})
2 changes: 1 addition & 1 deletion e2e/migration-harness/isolation/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM node:22-bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends strace socat python3 util-linux git && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates strace socat python3 util-linux git && rm -rf /var/lib/apt/lists/*
# A bind mount's root can appear root-owned (Colima virtiofs on macOS) while the
# actor runs as the host uid; Git would then refuse /workspace as dubious ownership.
RUN git config --system --add safe.directory /workspace
Expand Down
Loading
Loading