cabloy 5.1.219 → 5.1.220
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/.cabloy-version +1 -1
- package/.github/workflows/create-cabloy.yml +1 -1
- package/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/package.json +1 -1
- package/repo-docs/fullstack/quickstart.md +3 -3
- package/repo-docs/reference/repo-scripts.md +12 -0
- package/scripts/generateOpenapiIsolated.test.ts +25 -0
- package/scripts/generateOpenapiIsolated.ts +28 -11
- package/scripts/runIsolatedTest.test.ts +157 -45
- package/scripts/runIsolatedTest.ts +30 -6
- package/scripts/strictGenerationStartup.test.ts +212 -0
- package/vona/packages-cli/cli/package.json +1 -1
- package/vona/packages-cli/cli-set-api/package.json +1 -1
- package/vona/packages-vona/vona/package.json +1 -1
- package/vona/packages-vona/vona-core/package.json +1 -1
- package/vona/packages-vona/vona-core/src/lib/bean/beanBase.ts +4 -0
- package/vona/packages-vona/vona-core/src/lib/core/asyncLocalStorage.ts +84 -12
- package/vona/packages-vona/vona-core/src/lib/core/index.ts +14 -0
- package/vona/packages-vona/vona-core/src/lib/core/logger/appLogger.ts +11 -3
- package/vona/packages-vona/vona-core/src/lib/core/logger/diagnosticLogger.test.ts +146 -0
- package/vona/packages-vona/vona-core/src/lib/core/logger/diagnosticLogger.ts +138 -0
- package/vona/packages-vona/vona-core/src/lib/core/logger/index.ts +1 -0
- package/vona/packages-vona/vona-core/src/lib/core/logger/utils.ts +25 -5
- package/vona/packages-vona/vona-core/src/lib/core/requestBoundary.ts +89 -0
- package/vona/packages-vona/vona-core/src/lib/core/testFreshness.test.ts +379 -0
- package/vona/packages-vona/vona-core/src/lib/core/testFreshness.ts +238 -0
- package/vona/packages-vona/vona-core/src/lib/framework/start.test.ts +4 -3
- package/vona/packages-vona/vona-core/src/lib/framework/start.ts +2 -0
- package/vona/packages-vona/vona-mock/package.json +1 -1
- package/vona/pnpm-lock.yaml +154 -125
- package/vona/src/suite-vendor/a-vona/modules/a-core/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-executor/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-executor/src/bean/bean.executor.ts +111 -60
- package/vona/src/suite-vendor/a-vona/modules/a-executor/src/service/executor.ts +6 -6
- package/vona/src/suite-vendor/a-vona/modules/a-executor/src/types/executor.ts +13 -1
- package/vona/src/suite-vendor/a-vona/modules/a-jwt/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-jwt/src/lib/jwtClientLogging.test.ts +182 -0
- package/vona/src/suite-vendor/a-vona/modules/a-jwt/src/service/jwtClient.ts +2 -8
- package/vona/src/suite-vendor/a-vona/modules/a-logger/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-logger/src/bean/aopMethod.log.ts +4 -1
- package/vona/src/suite-vendor/a-vona/modules/a-logger/src/bean/bean.logger.ts +9 -0
- package/vona/src/suite-vendor/a-vona/modules/a-logger/src/bean/middlewareSystem.httpLog.ts +27 -14
- package/vona/src/suite-vendor/a-vona/modules/a-logger/src/lib/redactHttpLog.test.ts +207 -0
- package/vona/src/suite-vendor/a-vona/modules/a-logger/src/lib/redactHttpLog.ts +30 -0
- package/vona/src/suite-vendor/a-vona/modules/a-logger/test/middlewareSystem.httpLog.test.ts +33 -1
- package/vona/src/suite-vendor/a-vona/modules/a-startup/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-startup/src/service/startup.ts +6 -0
- package/vona/src/suite-vendor/a-vona/modules/a-startup/test/devSeed.test.ts +2 -2
- package/vona/src/suite-vendor/a-vona/modules/a-telemetry/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-telemetry/src/bean/bean.telemetry.ts +8 -1
- package/vona/src/suite-vendor/a-vona/modules/a-telemetry/src/bean/middlewareSystem.trace.ts +9 -14
- package/vona/src/suite-vendor/a-vona/modules/a-telemetry/src/lib/spanDiagnostics.ts +70 -0
- package/vona/src/suite-vendor/a-vona/modules/a-telemetry/src/service/telemetry.ts +37 -23
- package/vona/src/suite-vendor/a-vona/modules/a-version/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-version/src/service/database.ts +31 -4
- package/vona/src/suite-vendor/a-vona/package.json +2 -2
- package/zova/packages-cli/cli/package.json +2 -2
- package/zova/packages-cli/cli-set-front/package.json +1 -1
- package/zova/packages-cli/cli-set-front/src/lib/bean/cli.bin.buildRest.ts +11 -101
- package/zova/packages-cli/cli-set-front/src/lib/common/restDependencies.ts +78 -0
- package/zova/packages-cli/cli-set-front/src/lib/common/restDependencyVersions.ts +231 -0
- package/zova/packages-cli/cli-set-front/test/restDependencies.test.ts +431 -0
package/.cabloy-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
5.1.
|
|
1
|
+
5.1.220
|
|
@@ -97,7 +97,7 @@ jobs:
|
|
|
97
97
|
if (Test-Path $log) { Get-Content $log }
|
|
98
98
|
throw 'Redis did not become ready'
|
|
99
99
|
- name: create project
|
|
100
|
-
run: npm create cabloy cabloy-app
|
|
100
|
+
run: npm create cabloy@latest cabloy-app
|
|
101
101
|
- name: verify project initialization
|
|
102
102
|
working-directory: cabloy-app
|
|
103
103
|
run: >-
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.1.220
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- Add request boundary lifecycle support and diagnostic suppression.
|
|
8
|
+
|
|
9
|
+
### Improvements
|
|
10
|
+
|
|
11
|
+
- Speed up REST declaration builds with oxc.
|
|
12
|
+
- Enhance the REST build process.
|
|
13
|
+
- Update setup documentation to use `npm create cabloy@latest`.
|
|
14
|
+
|
|
3
15
|
## 5.1.219
|
|
4
16
|
|
|
5
17
|
### Improvements
|
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ Learn more about [Vona + Zova Integration](https://cabloy.com/fullstack/vona-zov
|
|
|
27
27
|
Create a new Cabloy Basic project:
|
|
28
28
|
|
|
29
29
|
```bash
|
|
30
|
-
npm create cabloy
|
|
30
|
+
npm create cabloy@latest
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
For Cabloy Start, clone the [Cabloy Start repository](https://github.com/cabloy/cabloy-start) and run `npm run init` from its root. See the [Fullstack Quickstart](https://cabloy.com/fullstack/quickstart) for prerequisites and development commands.
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@ Before creating a new Cabloy project, make sure your environment has:
|
|
|
21
21
|
## 2. Create a new project
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
npm create cabloy
|
|
24
|
+
npm create cabloy@latest
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
The generated project includes `repo-agent-governance/` plus committed adapters for Claude Code, Codex, and Cursor. This path creates a Cabloy Basic project baseline. Open it in a supported coding agent and start with the project-specific guidance; regenerate adapters from the canonical governance source rather than editing generated files directly.
|
|
@@ -52,13 +52,13 @@ npm create cabloy
|
|
|
52
52
|
#### Windows Command Prompt
|
|
53
53
|
|
|
54
54
|
```cmd
|
|
55
|
-
set pnpm_config_minimum_release_age=0 && npm create cabloy
|
|
55
|
+
set pnpm_config_minimum_release_age=0 && npm create cabloy@latest
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
#### macOS / Linux
|
|
59
59
|
|
|
60
60
|
```bash
|
|
61
|
-
pnpm_config_minimum_release_age=0 npm create cabloy
|
|
61
|
+
pnpm_config_minimum_release_age=0 npm create cabloy@latest
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
## 3. Start Vona integrated SSR
|
|
@@ -82,6 +82,18 @@ A process-list match or a free port alone is not proof of either a conflict or s
|
|
|
82
82
|
|
|
83
83
|
`npm run contract:generate:isolated -- <module-name>` starts a fresh test-mode Vona service on a run-owned loopback port, verifies its signed readiness response, fetches the Swagger document, and invokes the existing Zova OpenAPI generator without Playwright. The run owns its disposable test resources and claim-backed local roots; successful runs clean them after the service drains, while failures retain the claim and evidence for inspection. The generated SDK files under `zova/src/**` remain shared checkout output, so serialize concurrent generation for the same workspace/module and do not treat this command as an automatic rollback boundary.
|
|
84
84
|
|
|
85
|
+
For an explicitly authorized contract-generation run that must not reap historical claims, Cabloy Basic and Cabloy Start support this opt-in form:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
npm run contract:generate:isolated -- <module-name> --skip-expired-claim-reaping
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The wrapper consumes this standalone flag rather than forwarding it to Zova; `--skip-expired-claim-reaping=...` is rejected. Without the flag, contract generation retains normal historical-claim reaping. Unit, coverage and E2E defaults are unchanged; the runner rejects their use of this opt-out.
|
|
92
|
+
|
|
93
|
+
The opt-in lane requires strict freshness after application configuration and before module loading: run-owned public/runtime/SQLite directories must be absent or empty, shared and static-isolate database namespaces must be absent, and persistent Redis namespaces must be empty. Read-only discovery failures or preexisting resources fail closed rather than authorizing deletion. Startup requires per-application freshness proof to bypass normal test clearing; database preparation rechecks the namespace, never drops existing databases in this lane, and reuses only a database creation recorded by that application.
|
|
94
|
+
|
|
95
|
+
This still loads environment configuration, initializes newly allocated test databases and Redis/runtime resources, and runs normal module seeds. Successful runs clean only their inventoried current-run resources after verified shutdown; failed runs retain their claim/resources, without automatic generation retry or fallback. Generated consumers remain shared checkout writes. Freshness is a snapshot, **not an exclusive lease**, zero-mutation mode, network sandbox, blanket log-redaction guarantee, or authorization to contact a Provider. Independently configured external resources and Provider operations retain their separate ownership and approval requirements. This shared flag does not extend Basic's separately scoped Windows verification to Start.
|
|
96
|
+
|
|
85
97
|
For Vona integrated SSR, the allocated E2E origin is supplied to Zova at runtime as server `SSR_API_BASE_URL` and browser `API_BASE_URL`. Do not edit Zova `.env` files or rebuild solely to match the test port. The current root `npm run test:e2e` consumes prebuilt frontend artifacts; refresh affected SSR/REST output and synchronize dependencies when their inputs change. See [Runtime API origins in Vona integrated SSR](/fullstack/ssr-entry-modes#runtime-api-origins-in-vona-integrated-ssr) for configuration overrides and scope.
|
|
86
98
|
|
|
87
99
|
For deliberate **dev-mode** database preparation, `npm run db:reset` is a separate, destructive command: in a single process, it clears validated application-owned Redis keys, drops and recreates managed disposable development databases, reruns migrations and instance initialization, then runs module `seed()` hooks. It requires `database.testDatabase: true` in the dev configuration and a connection outside the disposable database. Ordinary `npm run dev` and `npm run dev:one` only reuse existing managed databases; if any required target is missing, startup fails promptly with an instruction to run `npm run db:reset`. They do not create databases, perform creation-time Redis cleanup, or seed. Never run `db:reset` against development data you need to retain. Upgrades do not reset existing development data or repeat its seeds. See [Development database preparation](#development-database-preparation) and [Migration and Changes](/backend/migration-and-changes#local-development-workflow).
|
|
@@ -9,10 +9,35 @@ import type { GuardianResult, OwnedProcess } from './runIsolatedTest.ts';
|
|
|
9
9
|
import {
|
|
10
10
|
getOpenapiGeneratorCommand,
|
|
11
11
|
getOpenapiSource,
|
|
12
|
+
parseIsolatedOpenapiArgs,
|
|
12
13
|
validateOpenapiSource,
|
|
13
14
|
} from './generateOpenapiIsolated.ts';
|
|
14
15
|
import { getIsolatedVonaCommand, ROOT_DIR, withIsolatedVona } from './runIsolatedTest.ts';
|
|
15
16
|
|
|
17
|
+
test('contract reaping opt-out is explicit and removed from generator arguments', () => {
|
|
18
|
+
const original = ['training-student', '--skip-expired-claim-reaping', '--nometadata'];
|
|
19
|
+
const parsed = parseIsolatedOpenapiArgs(original);
|
|
20
|
+
assert.deepEqual(parsed, {
|
|
21
|
+
generatorArgs: ['training-student', '--nometadata'],
|
|
22
|
+
skipExpiredClaimReaping: true,
|
|
23
|
+
});
|
|
24
|
+
assert.deepEqual(original, ['training-student', '--skip-expired-claim-reaping', '--nometadata']);
|
|
25
|
+
assert.equal(
|
|
26
|
+
getOpenapiGeneratorCommand(parsed.generatorArgs).args.includes('--skip-expired-claim-reaping'),
|
|
27
|
+
false,
|
|
28
|
+
);
|
|
29
|
+
assert.deepEqual(parseIsolatedOpenapiArgs(['training-student']), {
|
|
30
|
+
generatorArgs: ['training-student'],
|
|
31
|
+
skipExpiredClaimReaping: false,
|
|
32
|
+
});
|
|
33
|
+
for (const value of ['true', 'false', '']) {
|
|
34
|
+
assert.throws(
|
|
35
|
+
() => parseIsolatedOpenapiArgs([`--skip-expired-claim-reaping=${value}`]),
|
|
36
|
+
/standalone flag/,
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
16
41
|
test('builds the isolated Swagger source from the allocated port', () => {
|
|
17
42
|
assert.equal(getOpenapiSource(7123), 'http://127.0.0.1:7123/swagger/json?version=V31');
|
|
18
43
|
});
|
|
@@ -15,6 +15,17 @@ export function getOpenapiSource(port: number) {
|
|
|
15
15
|
return `http://127.0.0.1:${port}/swagger/json?version=${OPENAPI_VERSION}`;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
export function parseIsolatedOpenapiArgs(args: string[]) {
|
|
19
|
+
const flag = '--skip-expired-claim-reaping';
|
|
20
|
+
if (args.some(arg => arg.startsWith(`${flag}=`))) {
|
|
21
|
+
throw new Error(`${flag} is a standalone flag`);
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
generatorArgs: args.filter(arg => arg !== flag),
|
|
25
|
+
skipExpiredClaimReaping: args.includes(flag),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
18
29
|
export function getOpenapiGeneratorCommand(args: string[]) {
|
|
19
30
|
if (args.some(arg => /^--projectPath(?:=|$)/.test(arg))) {
|
|
20
31
|
throw new Error(
|
|
@@ -67,23 +78,29 @@ export async function validateOpenapiSource(source: string) {
|
|
|
67
78
|
}
|
|
68
79
|
|
|
69
80
|
export async function generateOpenapiIsolated(args: string[]) {
|
|
70
|
-
const
|
|
81
|
+
const { generatorArgs, skipExpiredClaimReaping } = parseIsolatedOpenapiArgs(args);
|
|
82
|
+
const command = getOpenapiGeneratorCommand(generatorArgs);
|
|
71
83
|
if (process.env.E2E_BASE_URL !== undefined) {
|
|
72
84
|
throw new Error(
|
|
73
85
|
'E2E_BASE_URL is unsupported; isolated OpenAPI generation manages a local test-mode target.',
|
|
74
86
|
);
|
|
75
87
|
}
|
|
76
|
-
return await withIsolatedRun(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
await
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
88
|
+
return await withIsolatedRun(
|
|
89
|
+
'contract',
|
|
90
|
+
async ({ env, port }) => {
|
|
91
|
+
const source = getOpenapiSource(port);
|
|
92
|
+
await withIsolatedVona(port, env, async () => {
|
|
93
|
+
await validateOpenapiSource(source);
|
|
94
|
+
await runIsolatedProcess(command.command, command.args, command.cwd, {
|
|
95
|
+
...env,
|
|
96
|
+
OPENAPI_SOURCE_URL: source,
|
|
97
|
+
VONA_TEST_READY_KEY: undefined,
|
|
98
|
+
});
|
|
84
99
|
});
|
|
85
|
-
}
|
|
86
|
-
|
|
100
|
+
},
|
|
101
|
+
ROOT_DIR,
|
|
102
|
+
{ skipExpiredClaimReaping },
|
|
103
|
+
);
|
|
87
104
|
}
|
|
88
105
|
|
|
89
106
|
if (process.argv[1] && fileURLToPath(import.meta.url) === resolve(process.argv[1])) {
|
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
createTestRunId,
|
|
34
34
|
getUnitTestCommands,
|
|
35
35
|
reserveTestRun,
|
|
36
|
+
reapBeforeIsolatedRun,
|
|
36
37
|
resolveNpmCli,
|
|
37
38
|
resolveCabloyEdition,
|
|
38
39
|
ROOT_DIR,
|
|
@@ -51,6 +52,97 @@ const isolationSource = resolve(
|
|
|
51
52
|
'vona/packages-vona/vona-core/src/lib/core/testIsolation.ts',
|
|
52
53
|
);
|
|
53
54
|
|
|
55
|
+
test('claim reaping defaults remain enabled and contract opt-out never calls the reaper', async () => {
|
|
56
|
+
const calls: string[] = [];
|
|
57
|
+
const reap = async (projectPath: string) => {
|
|
58
|
+
calls.push(projectPath);
|
|
59
|
+
return [];
|
|
60
|
+
};
|
|
61
|
+
for (const kind of ['unit', 'cov', 'e2e', 'contract'] as const) {
|
|
62
|
+
await reapBeforeIsolatedRun(kind, '/synthetic/vona', {}, reap);
|
|
63
|
+
}
|
|
64
|
+
assert.deepEqual(calls, [
|
|
65
|
+
'/synthetic/vona',
|
|
66
|
+
'/synthetic/vona',
|
|
67
|
+
'/synthetic/vona',
|
|
68
|
+
'/synthetic/vona',
|
|
69
|
+
]);
|
|
70
|
+
await reapBeforeIsolatedRun(
|
|
71
|
+
'contract',
|
|
72
|
+
'/synthetic/vona',
|
|
73
|
+
{ skipExpiredClaimReaping: true },
|
|
74
|
+
async () => {
|
|
75
|
+
throw new Error('historical reaper must not run');
|
|
76
|
+
},
|
|
77
|
+
);
|
|
78
|
+
for (const kind of ['unit', 'cov', 'e2e'] as const) {
|
|
79
|
+
await assert.rejects(
|
|
80
|
+
reapBeforeIsolatedRun(kind, '/synthetic/vona', { skipExpiredClaimReaping: true }, reap),
|
|
81
|
+
/supported only for contract generation/,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
assert.equal(calls.length, 4);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test('public test entrypoints reject contract-only flags before claim reaping', () => {
|
|
88
|
+
const runnerUrl = new URL('./runIsolatedTest.ts', import.meta.url).href;
|
|
89
|
+
const source = `
|
|
90
|
+
import assert from 'node:assert/strict';
|
|
91
|
+
import { registerHooks } from 'node:module';
|
|
92
|
+
globalThis.cleanupCalls = [];
|
|
93
|
+
registerHooks({ resolve(specifier, context, nextResolve) {
|
|
94
|
+
if (context.parentURL === ${JSON.stringify(runnerUrl)} && specifier === './testClaimCleanup.ts') {
|
|
95
|
+
const source = \`
|
|
96
|
+
export function parseTestClaimTtlSeconds() { return 1; }
|
|
97
|
+
export async function reapExpiredTestClaims() {
|
|
98
|
+
globalThis.cleanupCalls.push('reap');
|
|
99
|
+
throw new Error('unexpected claim reaping');
|
|
100
|
+
}
|
|
101
|
+
export async function cleanTestClaim() {
|
|
102
|
+
globalThis.cleanupCalls.push('clean');
|
|
103
|
+
throw new Error('unexpected claim cleanup');
|
|
104
|
+
}
|
|
105
|
+
\`;
|
|
106
|
+
return { url: 'data:text/javascript,' + encodeURIComponent(source), shortCircuit: true };
|
|
107
|
+
}
|
|
108
|
+
return nextResolve(specifier, context);
|
|
109
|
+
} });
|
|
110
|
+
const { runIsolatedTest } = await import(${JSON.stringify(runnerUrl)});
|
|
111
|
+
for (const [kind, args] of [['unit', []], ['unit', ['--coverage']], ['e2e', []]]) {
|
|
112
|
+
for (const suffix of ['', '=true', '=false', '=']) {
|
|
113
|
+
await assert.rejects(
|
|
114
|
+
runIsolatedTest(kind, [...args, '--skip-expired-claim-reaping' + suffix]),
|
|
115
|
+
/--skip-expired-claim-reaping is supported only for contract generation/,
|
|
116
|
+
);
|
|
117
|
+
assert.deepEqual(globalThis.cleanupCalls, []);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
await assert.rejects(runIsolatedTest('unit', []), /unexpected claim reaping/);
|
|
121
|
+
assert.deepEqual(globalThis.cleanupCalls, ['reap']);
|
|
122
|
+
`;
|
|
123
|
+
const result = spawnSync(process.execPath, ['--input-type=module', '-e', source], {
|
|
124
|
+
cwd: ROOT_DIR,
|
|
125
|
+
env: { ...process.env, E2E_BASE_URL: undefined },
|
|
126
|
+
encoding: 'utf8',
|
|
127
|
+
timeout: 10_000,
|
|
128
|
+
});
|
|
129
|
+
assert.equal(result.error, undefined);
|
|
130
|
+
assert.equal(result.status, 0, result.stderr);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test('claim reaping errors propagate without retries', async () => {
|
|
134
|
+
const error = new Error('synthetic reaper failure');
|
|
135
|
+
let calls = 0;
|
|
136
|
+
await assert.rejects(
|
|
137
|
+
reapBeforeIsolatedRun('contract', '/synthetic/vona', {}, async () => {
|
|
138
|
+
calls++;
|
|
139
|
+
throw error;
|
|
140
|
+
}),
|
|
141
|
+
value => value === error,
|
|
142
|
+
);
|
|
143
|
+
assert.equal(calls, 1);
|
|
144
|
+
});
|
|
145
|
+
|
|
54
146
|
test('public test scripts delegate to the isolated runner without recursion', () => {
|
|
55
147
|
const root = JSON.parse(readFileSync(resolve(ROOT_DIR, 'package.json'), 'utf8'));
|
|
56
148
|
const original = JSON.parse(
|
|
@@ -223,51 +315,71 @@ test('creates exclusive manifest claims and refuses stale or symlinked roots', a
|
|
|
223
315
|
}
|
|
224
316
|
});
|
|
225
317
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
318
|
+
for (const marker of ['__CABLOY_BASIC__', '__CABLOY_START__']) {
|
|
319
|
+
test(
|
|
320
|
+
`contract runs clean owned roots on success and retain failed-run evidence for ${marker}`,
|
|
321
|
+
{ concurrency: false },
|
|
322
|
+
async () => {
|
|
323
|
+
const root = mkdtempSync(join(realpathSync(tmpdir()), 'cabloy-contract-run-'));
|
|
324
|
+
mkdirSync(join(root, 'vona'));
|
|
325
|
+
writeFileSync(join(root, marker), '');
|
|
326
|
+
let claimPath = '';
|
|
327
|
+
let dataRoot = '';
|
|
328
|
+
let generatedRoot = '';
|
|
329
|
+
const previous = process.env.VONA_TEST_REQUIRE_FRESH_RESOURCES;
|
|
330
|
+
try {
|
|
331
|
+
process.env.VONA_TEST_REQUIRE_FRESH_RESOURCES = 'true';
|
|
332
|
+
await withIsolatedRun(
|
|
333
|
+
'contract',
|
|
334
|
+
async context => {
|
|
335
|
+
assert.equal(context.env.VONA_TEST_REQUIRE_FRESH_RESOURCES, undefined);
|
|
336
|
+
},
|
|
337
|
+
root,
|
|
338
|
+
);
|
|
339
|
+
assert.equal(
|
|
340
|
+
await withIsolatedRun(
|
|
341
|
+
'contract',
|
|
342
|
+
async context => {
|
|
343
|
+
({ claimPath, dataRoot, generatedRoot } = context);
|
|
344
|
+
assert.equal((await loadTestClaim(claimPath)).kind, 'contract');
|
|
345
|
+
assert.equal(context.env.META_MODE, 'test');
|
|
346
|
+
assert.equal(context.env.VONA_DB_RESET, undefined);
|
|
347
|
+
assert.equal(context.env.VONA_TEST_READY_KEY, undefined);
|
|
348
|
+
assert.equal(context.env.VONA_TEST_REQUIRE_FRESH_RESOURCES, 'true');
|
|
349
|
+
assert.ok(existsSync(join(dataRoot, '.vona-test-owner')));
|
|
350
|
+
return 'generated';
|
|
351
|
+
},
|
|
352
|
+
root,
|
|
353
|
+
{ skipExpiredClaimReaping: true },
|
|
354
|
+
),
|
|
355
|
+
'generated',
|
|
356
|
+
);
|
|
357
|
+
assert.equal(existsSync(claimPath), false);
|
|
358
|
+
assert.equal(existsSync(dataRoot), false);
|
|
359
|
+
assert.equal(existsSync(generatedRoot), false);
|
|
360
|
+
await assert.rejects(
|
|
361
|
+
withIsolatedRun(
|
|
362
|
+
'contract',
|
|
363
|
+
async context => {
|
|
364
|
+
({ claimPath, dataRoot, generatedRoot } = context);
|
|
365
|
+
throw new Error('generator failed');
|
|
366
|
+
},
|
|
367
|
+
root,
|
|
368
|
+
{ skipExpiredClaimReaping: true },
|
|
369
|
+
),
|
|
370
|
+
/generator failed/,
|
|
371
|
+
);
|
|
372
|
+
assert.equal((await loadTestClaim(claimPath)).status, 'failed');
|
|
373
|
+
assert.equal(existsSync(dataRoot), true);
|
|
374
|
+
assert.equal(existsSync(generatedRoot), true);
|
|
375
|
+
} finally {
|
|
376
|
+
if (previous === undefined) delete process.env.VONA_TEST_REQUIRE_FRESH_RESOURCES;
|
|
377
|
+
else process.env.VONA_TEST_REQUIRE_FRESH_RESOURCES = previous;
|
|
378
|
+
rmSync(root, { recursive: true, force: true });
|
|
379
|
+
}
|
|
380
|
+
},
|
|
381
|
+
);
|
|
382
|
+
}
|
|
271
383
|
|
|
272
384
|
test('readiness retries signed not-ready responses and rejects server exit or timeout', async () => {
|
|
273
385
|
const key = 'a'.repeat(64);
|
|
@@ -546,19 +546,39 @@ export interface IsolatedRunContext {
|
|
|
546
546
|
env: NodeJS.ProcessEnv;
|
|
547
547
|
}
|
|
548
548
|
|
|
549
|
+
export interface IsolatedRunOptions {
|
|
550
|
+
skipExpiredClaimReaping?: boolean;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
export async function reapBeforeIsolatedRun(
|
|
554
|
+
kind: 'unit' | 'cov' | 'e2e' | 'contract',
|
|
555
|
+
vonaDir: string,
|
|
556
|
+
options: IsolatedRunOptions = {},
|
|
557
|
+
reap: typeof reapExpiredTestClaims = reapExpiredTestClaims,
|
|
558
|
+
): Promise<void> {
|
|
559
|
+
if (options.skipExpiredClaimReaping) {
|
|
560
|
+
if (kind !== 'contract') {
|
|
561
|
+
throw new Error('Skipping expired claim reaping is supported only for contract generation');
|
|
562
|
+
}
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
await reap(vonaDir, {
|
|
566
|
+
ttlSeconds: parseTestClaimTtlSeconds(),
|
|
567
|
+
now: Date.now(),
|
|
568
|
+
isInactive: claim => isTestClaimInactive(claim),
|
|
569
|
+
warn: message => console.error(message),
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
|
|
549
573
|
export async function withIsolatedRun<T>(
|
|
550
574
|
kind: 'unit' | 'cov' | 'e2e' | 'contract',
|
|
551
575
|
callback: (context: IsolatedRunContext) => Promise<T>,
|
|
552
576
|
rootDir = ROOT_DIR,
|
|
577
|
+
options: IsolatedRunOptions = {},
|
|
553
578
|
): Promise<T> {
|
|
554
579
|
resolveCabloyEdition(rootDir);
|
|
555
580
|
const vonaDir = resolve(rootDir, 'vona');
|
|
556
|
-
await
|
|
557
|
-
ttlSeconds: parseTestClaimTtlSeconds(),
|
|
558
|
-
now: Date.now(),
|
|
559
|
-
isInactive: claim => isTestClaimInactive(claim),
|
|
560
|
-
warn: message => console.error(message),
|
|
561
|
-
});
|
|
581
|
+
await reapBeforeIsolatedRun(kind, vonaDir, options);
|
|
562
582
|
const runId = createTestRunId();
|
|
563
583
|
const dataRoot = resolve(vonaDir, `.app-test-${runId}`);
|
|
564
584
|
const generatedRoot = resolve(vonaDir, `.vona-test-${runId}`);
|
|
@@ -580,6 +600,7 @@ export async function withIsolatedRun<T>(
|
|
|
580
600
|
META_MODE: 'test',
|
|
581
601
|
VONA_DB_RESET: undefined,
|
|
582
602
|
VONA_TEST_RUN_ID: runId,
|
|
603
|
+
VONA_TEST_REQUIRE_FRESH_RESOURCES: options.skipExpiredClaimReaping ? 'true' : undefined,
|
|
583
604
|
VONA_TEST_READY_KEY: undefined,
|
|
584
605
|
VONA_TEST_SERVER_ORIGIN: undefined,
|
|
585
606
|
APP_NAME: `cabtest${runId}`,
|
|
@@ -631,6 +652,9 @@ export async function withIsolatedRun<T>(
|
|
|
631
652
|
}
|
|
632
653
|
|
|
633
654
|
export async function runIsolatedTest(kind: 'unit' | 'e2e', args: string[]) {
|
|
655
|
+
if (args.some(arg => /^--skip-expired-claim-reaping(?:=|$)/.test(arg))) {
|
|
656
|
+
throw new Error('--skip-expired-claim-reaping is supported only for contract generation');
|
|
657
|
+
}
|
|
634
658
|
if (process.env.E2E_BASE_URL !== undefined) {
|
|
635
659
|
throw new Error(
|
|
636
660
|
'E2E_BASE_URL is unsupported; the E2E runner manages a local test-mode target.',
|