Skip to content

Commit cfb8f30

Browse files
committed
Merge origin/main into claude/project-thread-3giljf
Claude-Session: https://claude.ai/code/session_01QSeKYm8sWjp2Pk76warN7w Co-authored-by: Claude <noreply@anthropic.com>
2 parents 12ee9e5 + 74216b6 commit cfb8f30

13 files changed

Lines changed: 820 additions & 101 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@objectstack/verify': patch
3+
'create-objectstack': patch
4+
---
5+
6+
fix(verify): a passing `os verify` run and a passing starter `pnpm test` no longer print the boot's INFO chatter, the `[Registry] …` lines or warnings about the harness's own secret
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
On the blank starter a passing `os verify` printed 626 lines before its verdict: 346 INFO records, 263 `[Registry] …` lines and four better-auth warnings that the harness's secret was short and low-entropy. A failing run still prints its failure: a boot that fails prints the kernel's ERROR record naming the plugin, and the error reaches the caller.
12+
13+
- **`@objectstack/verify`**: `bootStack` boots at `warn` unless `OS_LOG_LEVEL` (or the legacy `LOG_LEVEL`) names another level, the default `objectstack serve` already uses. The ObjectQL registry's `[Registry] …` lines follow the same level unless `OS_REGISTRY_LOG` is set. To see the whole boot log, run with `OS_LOG_LEVEL=info` or `OS_LOG_LEVEL=debug`. The auth signing secret, when `authSecret` is not passed, is 32 random bytes held in the process's memory for its lifetime, instead of a fixed 25-character string; a restart in the same process over the same database file still accepts the sessions it issued.
14+
- **`create-objectstack`**: the starter's `vitest.config.ts` no longer sets `OS_REGISTRY_LOG`, because the booted stack is quiet by default; its comment names `OS_LOG_LEVEL=info pnpm test` for the whole boot log.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
'@objectstack/service-job': patch
3+
---
4+
5+
fix(service-job): a job run's history row records the trigger of the call that ran it, and a replay is one row
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
`DbJobAdapter` writes one `sys_job_run` row per attempt, and its `trigger` column is documented as `schedule` | `manual` | `replay`. The wrapper that writes the row used to fix that value when the job was scheduled, so every row said `schedule`:
11+
12+
- a manual `trigger(name)` was recorded as a scheduled tick (`trigger: 'schedule'`);
13+
- a `replay(name)` landed two rows for one run: a `replay` row of its own beside the wrapper's `schedule` row.
14+
15+
The value is now read per call: a scheduled fire writes `schedule`, `trigger()` writes `manual`, and `replay()` writes one `replay` row per attempt, settled to the run's real status (`success`, `failed`, `timeout` or `degraded`). The handler's context is unchanged: a replayed handler is still told `trigger: 'manual'`, and its `runId` now names the `replay` row, so a replayed sync-in pull names that row on its `sys_sync_run` record.
16+
17+
What an operator sees: in `sys_job_run`, manual runs now read `manual`, and a replay is one row instead of two, so run counts read from the table no longer count a replay twice. Rows written before this release keep the values they were written with.

‎packages/cli/test/verify-json-stdout.test.ts‎

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131
* run really reached the stage whose boot writes the lines;
3232
* - the diagnostics are moved, never destroyed: stderr carries the kernel
3333
* logger's records, WARN among them, and the registry's `console.log`
34-
* lines. Silencing the logger would make stdout parse too, and go red here;
34+
* lines. Silencing the logger would make stdout parse too, and go red here.
35+
* The run restates `OS_LOG_LEVEL=info` and `OS_REGISTRY_LOG=info` (the
36+
* harness boots at `warn` by default since #32154), and the WARN comes
37+
* from a plugin of the fixture's own (`WARN_PLUGIN_SOURCE`);
3538
* - the text face is unchanged: without `--json`, the kernel logger's
3639
* records still go to stdout beside the report.
3740
*
@@ -48,7 +51,7 @@ import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
4851
import { tmpdir } from 'node:os';
4952
import { join } from 'node:path';
5053
import { CLI, childEnv } from './helpers/serve-process.js';
51-
import { defineStackSource, linkSpec } from './helpers/define-stack-fixture.js';
54+
import { defineStackSourceFromLiteral, linkSpec } from './helpers/define-stack-fixture.js';
5255

5356
/** A stack the author-time rules pass, so `os verify` reaches the runtime stage. */
5457
const STACK = {
@@ -78,6 +81,21 @@ const STACK = {
7881
const LOGGER_RECORD = /^\d{4}-\d{2}-\d{2}T[\d:.]+Z\s+(DEBUG|INFO|WARN)\b/m;
7982
const LOGGER_WARN_RECORD = /^\d{4}-\d{2}-\d{2}T[\d:.]+Z\s+WARN\b/m;
8083

84+
/**
85+
* [#32154] The WARN record the boot writes on purpose: a plugin of the stack's
86+
* own, writing one through the kernel logger it is handed. A clean boot no
87+
* longer writes any WARN of its own (the harness's short auth secret drew the
88+
* last ones), and the routing of a WARN is what the stderr case pins, so the
89+
* fixture supplies the record rather than the pin depending on a defect.
90+
*/
91+
const WARN_PLUGIN_SOURCE = `{
92+
name: 'com.example.verify-json-stdout.warn',
93+
version: '0.0.1',
94+
async init(ctx) {
95+
ctx.logger.warn('verify-json-stdout fixture: a WARN record this boot writes on purpose');
96+
},
97+
}`;
98+
8199
/** The second writer: a `console.log` in the ObjectQL registry, outside the kernel logger. */
82100
const REGISTRY_CONSOLE_LINE = '[Registry] Installed package';
83101

@@ -100,8 +118,11 @@ function runCli(dir: string, args: string[]): Run {
100118
// workers and the child would inherit it: at `warn` the registry's
101119
// `console.log` — the writer a logger-level fix cannot reach — never speaks,
102120
// and the pin would hold over one writer instead of the three an operator's
103-
// run has.
104-
env: childEnv({ NO_COLOR: '1', OS_REGISTRY_LOG: 'info' }),
121+
// run has. `OS_LOG_LEVEL: 'info'` restates the kernel writer the same way
122+
// (#32154): `bootStack` boots at `warn` unless told otherwise, and at `warn`
123+
// a clean stack's kernel logger has next to nothing to route. What this file
124+
// pins is where each writer's lines GO, not how many there are by default.
125+
env: childEnv({ NO_COLOR: '1', OS_REGISTRY_LOG: 'info', OS_LOG_LEVEL: 'info' }),
105126
maxBuffer: 64 * 1024 * 1024,
106127
});
107128
return { status: r.status, stdout: r.stdout ?? '', stderr: r.stderr ?? '' };
@@ -114,7 +135,10 @@ describe('os verify --json on a stack that reaches the runtime stage (#21324)',
114135

115136
beforeAll(() => {
116137
dir = mkdtempSync(join(tmpdir(), 'os-verify-json-stdout-'));
117-
writeFileSync(join(dir, 'objectstack.config.mjs'), defineStackSource(STACK));
138+
writeFileSync(
139+
join(dir, 'objectstack.config.mjs'),
140+
defineStackSourceFromLiteral(`{ ...${JSON.stringify(STACK)}, plugins: [${WARN_PLUGIN_SOURCE}] }`),
141+
);
118142
linkSpec(dir);
119143
json = runCli(dir, ['verify', '--json']);
120144
text = runCli(dir, ['verify']);
@@ -143,6 +167,7 @@ describe('os verify --json on a stack that reaches the runtime stage (#21324)',
143167
it('moves the diagnostics to stderr instead of destroying them — WARN records included', () => {
144168
expect(json.stderr).toMatch(LOGGER_RECORD);
145169
expect(json.stderr).toMatch(LOGGER_WARN_RECORD);
170+
expect(json.stderr).toContain('a WARN record this boot writes on purpose');
146171
expect(json.stderr).toContain(REGISTRY_CONSOLE_LINE);
147172
});
148173

‎packages/create-objectstack/src/templates/blank/vitest.config.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ export default defineConfig({
1313
// every test passed. Printing logs straight to the terminal, instead of
1414
// through vitest's console capture, removes that failure.
1515
disableConsoleIntercept: true,
16-
// At its default level the engine logs one `[Registry]` line for every
17-
// item it registers while booting, over a hundred for this starter alone.
18-
// `warn` keeps the engine's warnings and errors and drops that chatter.
19-
env: { OS_REGISTRY_LOG: 'warn' },
16+
// A booted stack logs at `warn`: its warnings and errors print, its
17+
// per-item boot chatter does not, and a failing test still prints its
18+
// failure. To see the whole boot log, run `OS_LOG_LEVEL=info pnpm test`
19+
// (or `debug`).
2020
},
2121
});

‎packages/qa/dogfood/vitest.config.ts‎

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,29 @@
5252
// strict env mode would not hand one to `@objectstack/dogfood#test` anyway
5353
// (its task `env` declares only `OS_TEST_TIERS` / `OS_TEST_SHARD`), so the
5454
// run declares it here, per project, beside `OS_REGISTRY_LOG`.
55+
//
56+
// ── #32154: this suite boots its stacks at `info`, DECLARATIVELY ────────────
57+
//
58+
// `bootStack` boots the kernel logger at `warn` unless `OS_LOG_LEVEL` names a
59+
// level (`packages/verify/src/boot-log-level.ts`), so that a project's
60+
// `pnpm test` and `os verify` print only warnings and errors on a run that
61+
// passed. This suite is a different reader: some of its files read the kernel
62+
// log off the process streams and judge INFO lines in it. Measured on one full
63+
// run with the level unset (8 tests in 6 files, every one an INFO reading):
64+
// a hook's `ctx.log.info` line a test waits for (both object-hook-lifecycle
65+
// files: timeouts), an INFO line a file keeps as the positive control for an
66+
// absence (`org-change-slug-bound-action`, `record-view-read-audit`,
67+
// `sys-migration-boot-ledger-once`), and a boot report printed at INFO
68+
// (`security-catalog-one-holder-http`). Those controls are why the drop was
69+
// loud; an absence read WITHOUT such a control would have stayed green at
70+
// `warn` while measuring nothing.
71+
//
72+
// So the suite asks for the level it has always booted at, per project for the
73+
// same measured reason as the keys beside it: a file's log reading must not
74+
// depend on which of the two projects lists it. ⛔ This is the suite's request,
75+
// not a change to `bootStack`'s default. The registry stays at `warn`:
76+
// `OS_REGISTRY_LOG` is its own variable, and `bootStack` leaves a value the
77+
// caller set alone.
5578
import { defineConfig } from 'vitest/config';
5679
import path from 'path';
5780
import { parseCLI, type TestUserConfig } from 'vitest/node';
@@ -182,7 +205,8 @@ export default defineConfig({
182205
// engine's own `OS_REGISTRY_LOG` seam, not a change to its shipped
183206
// default. Header docblock carries the measurement and the rationale.
184207
// PER PROJECT for the same measured reason as the line above.
185-
env: { OS_REGISTRY_LOG: 'warn', OS_CLOUD_URL: 'off' },
208+
// #32154: `OS_LOG_LEVEL: 'info'` because files read INFO lines (header).
209+
env: { OS_REGISTRY_LOG: 'warn', OS_CLOUD_URL: 'off', OS_LOG_LEVEL: 'info' },
186210
name: 'shared-showcase',
187211
include: SHARED_SHOWCASE,
188212
isolate: false,
@@ -375,7 +399,8 @@ export default defineConfig({
375399
// engine's own `OS_REGISTRY_LOG` seam, not a change to its shipped
376400
// default. Header docblock carries the measurement and the rationale.
377401
// PER PROJECT for the same measured reason as the line above.
378-
env: { OS_REGISTRY_LOG: 'warn', OS_CLOUD_URL: 'off' },
402+
// #32154: `OS_LOG_LEVEL: 'info'` because files read INFO lines (header).
403+
env: { OS_REGISTRY_LOG: 'warn', OS_CLOUD_URL: 'off', OS_LOG_LEVEL: 'info' },
379404
name: 'isolated',
380405
include: ['test/**/*.test.ts'],
381406
exclude: SHARED_SHOWCASE,

‎packages/services/service-job/src/db-job-adapter.degraded-outcome.test.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,24 +194,24 @@ describe('DbJobAdapter — the three-outcome handler table (#5548)', () => {
194194
expect(runRows()[0].status).toBe('degraded');
195195
});
196196

197-
it('replay of a degraded job writes BOTH rows as degraded — no success row alongside', async () => {
197+
it('replay of a degraded job writes its one row as degraded — no success row alongside', async () => {
198198
await adapter.schedule('wake', CRON, async (): Promise<JobRunOutcome> => ({
199199
outcome: 'degraded',
200200
reason: 'STORE_UNAVAILABLE',
201201
}));
202202
await adapter.replay('wake');
203203

204-
// One synthetic `replay` row + one wrapped row, and they must agree.
205-
expect(runRows().map((r) => r.trigger).sort()).toEqual(['replay', 'schedule']);
206-
expect(runRows().map((r) => r.status)).toEqual(['degraded', 'degraded']);
207-
expect(runRows().map((r) => r.error)).toEqual(['STORE_UNAVAILABLE', 'STORE_UNAVAILABLE']);
204+
// One run, one row, tagged `replay`.
205+
expect(runRows().map((r) => r.trigger)).toEqual(['replay']);
206+
expect(runRows().map((r) => r.status)).toEqual(['degraded']);
207+
expect(runRows().map((r) => r.error)).toEqual(['STORE_UNAVAILABLE']);
208208
});
209209

210210
it('replay of an ordinary job still writes success rows (the replay path stays additive too)', async () => {
211211
await adapter.schedule('plain', CRON, async () => {});
212212
await adapter.replay('plain');
213213

214-
expect(runRows().map((r) => r.status)).toEqual(['success', 'success']);
214+
expect(runRows().map((r) => r.status)).toEqual(['success']);
215215
});
216216
});
217217

0 commit comments

Comments
 (0)