create-principles-disciple 1.142.0 → 1.142.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/console/dist/ui/api.js +6 -3
- package/console/dist/ui/utils/__tests__/token-storage.test.d.ts +1 -0
- package/console/dist/ui/utils/__tests__/token-storage.test.js +64 -0
- package/console/dist/ui/utils/token-storage.d.ts +22 -0
- package/console/dist/ui/utils/token-storage.js +47 -0
- package/console/dist/web/assets/app.js +34 -4
- package/core/dist/runtime-v2/__tests__/architecture-regression.test.js +144 -0
- package/core/dist/runtime-v2/__tests__/architecture-regression.test.js.map +1 -1
- package/core/dist/runtime-v2/adapter/__tests__/artificer-l2-adapter.test.js +54 -0
- package/core/dist/runtime-v2/adapter/__tests__/artificer-l2-adapter.test.js.map +1 -1
- package/core/dist/runtime-v2/adapter/artificer-l2-adapter.d.ts.map +1 -1
- package/core/dist/runtime-v2/adapter/artificer-l2-adapter.js +53 -1
- package/core/dist/runtime-v2/adapter/artificer-l2-adapter.js.map +1 -1
- package/core/dist/runtime-v2/internalization/__tests__/scribe-intent-contract-normalization.test.d.ts +2 -0
- package/core/dist/runtime-v2/internalization/__tests__/scribe-intent-contract-normalization.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/internalization/__tests__/scribe-intent-contract-normalization.test.js +78 -0
- package/core/dist/runtime-v2/internalization/__tests__/scribe-intent-contract-normalization.test.js.map +1 -0
- package/core/dist/runtime-v2/internalization/scribe-output.d.ts +13 -0
- package/core/dist/runtime-v2/internalization/scribe-output.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/scribe-output.js +32 -0
- package/core/dist/runtime-v2/internalization/scribe-output.js.map +1 -1
- package/core/dist/runtime-v2/internalization/scribe-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/scribe-prompt-builder.js +1 -0
- package/core/dist/runtime-v2/internalization/scribe-prompt-builder.js.map +1 -1
- package/core/dist/runtime-v2/internalization/scribe-runner.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/scribe-runner.js +4 -0
- package/core/dist/runtime-v2/internalization/scribe-runner.js.map +1 -1
- package/core/dist/telemetry-event.d.ts +19 -36
- package/core/dist/telemetry-event.d.ts.map +1 -1
- package/core/dist/telemetry-event.js +256 -59
- package/core/dist/telemetry-event.js.map +1 -1
- package/core/package.json +1 -1
- package/package.json +2 -2
- package/pd-cli/dist/commands/console.d.ts.map +1 -1
- package/pd-cli/dist/commands/console.js +15 -3
- package/pd-cli/dist/commands/console.js.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-rulehost.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js +8 -0
- package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js.map +1 -1
- package/pd-cli/dist/services/console-launcher.d.ts +9 -0
- package/pd-cli/dist/services/console-launcher.d.ts.map +1 -1
- package/pd-cli/dist/services/console-launcher.js +47 -4
- package/pd-cli/dist/services/console-launcher.js.map +1 -1
- package/pd-cli/package.json +1 -1
- package/plugin/dist/bundle.js +460 -454
- package/plugin/dist/core/signal-collector-host.d.ts +6 -0
- package/plugin/dist/core/trajectory.d.ts +8 -0
- package/plugin/dist/governance-audit.js +149 -149
- package/plugin/dist/rulehost-evidence.js +126 -122
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/release-manager/package.json +2 -2
|
@@ -3083,6 +3083,150 @@ describe('PRI-416: barrel cap guards', () => {
|
|
|
3083
3083
|
expect(exportLines.length).toBeLessThanOrEqual(BARREL_MAX_EXPORT_LINES);
|
|
3084
3084
|
});
|
|
3085
3085
|
});
|
|
3086
|
+
// ── PRI-775: Barrel Export Surface Freeze ─────────────────────────────────────
|
|
3087
|
+
//
|
|
3088
|
+
// The two public barrels (src/index.ts, src/runtime-v2/index.ts) are the first
|
|
3089
|
+
// surface every AI task and developer reads; ghost exports accumulate exactly
|
|
3090
|
+
// there (PRI-751 audit section 2). The export-name SET of each barrel is
|
|
3091
|
+
// frozen via snapshot fixtures: adding OR removing a name must update the
|
|
3092
|
+
// fixture with a PRI-tagged reason in the PR. Count-only caps are blind to
|
|
3093
|
+
// delete-one-add-one drift, which is how ghost families regrow.
|
|
3094
|
+
//
|
|
3095
|
+
// The extractor strips comments from captured tokens and validates that every
|
|
3096
|
+
// frozen entry is a real identifier — the snapshot must be a name SET, never
|
|
3097
|
+
// source-text fragments (review finding: 12/1719 comment-polluted entries).
|
|
3098
|
+
// Whitespace variants of the block form are captured, not missed. Wildcard
|
|
3099
|
+
// re-exports, default exports and non-identifier captures fail loud: the
|
|
3100
|
+
// guard refuses to freeze a surface it cannot prove.
|
|
3101
|
+
describe('PRI-775: barrel export surface freeze', () => {
|
|
3102
|
+
const IDENTIFIER_RE = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
3103
|
+
function extractExportNames(src) {
|
|
3104
|
+
if (/^export\s+\*/m.test(src)) {
|
|
3105
|
+
throw new Error('PRI-775: wildcard re-export (`export *`) detected. A name-set snapshot cannot prove '
|
|
3106
|
+
+ 'the surface of a star re-export, so the freeze refuses to guess: enumerate the '
|
|
3107
|
+
+ 'exports explicitly or extend this guard deliberately.');
|
|
3108
|
+
}
|
|
3109
|
+
if (/^export\s+default/m.test(src)) {
|
|
3110
|
+
throw new Error('PRI-775: default export detected. A barrel default export is invisible to the '
|
|
3111
|
+
+ 'name-set snapshot, so the freeze refuses to guess: use a named export or '
|
|
3112
|
+
+ 'extend this guard deliberately.');
|
|
3113
|
+
}
|
|
3114
|
+
const names = new Set();
|
|
3115
|
+
for (const block of src.match(/\bexport\s*(?:type\s*)?\{[^}]*\}/g) ?? []) {
|
|
3116
|
+
// Strip comments BEFORE splitting on commas: a comment that itself
|
|
3117
|
+
// contains a comma would otherwise be cut in half and glue comment
|
|
3118
|
+
// text onto the following real symbol (hit on real barrel source).
|
|
3119
|
+
const inner = block
|
|
3120
|
+
.slice(block.indexOf('{') + 1, block.indexOf('}'))
|
|
3121
|
+
.replace(/\/\*[\s\S]*?\*\//g, '')
|
|
3122
|
+
.replace(/\/\/.*$/gm, '');
|
|
3123
|
+
for (let token of inner.split(',')) {
|
|
3124
|
+
token = token.trim();
|
|
3125
|
+
if (!token)
|
|
3126
|
+
continue;
|
|
3127
|
+
if (token.startsWith('type '))
|
|
3128
|
+
token = token.slice(5).trim();
|
|
3129
|
+
const asIdx = token.indexOf(' as ');
|
|
3130
|
+
if (asIdx !== -1)
|
|
3131
|
+
token = token.slice(asIdx + 4).trim();
|
|
3132
|
+
if (!token)
|
|
3133
|
+
continue;
|
|
3134
|
+
if (!IDENTIFIER_RE.test(token)) {
|
|
3135
|
+
throw new Error(`PRI-775: extractor captured a non-identifier export token ${JSON.stringify(token)}. `
|
|
3136
|
+
+ 'This guard freezes identifier names only; fail loud instead of freezing '
|
|
3137
|
+
+ 'source-text fragments. Fix the extractor or the barrel formatting.');
|
|
3138
|
+
}
|
|
3139
|
+
names.add(token);
|
|
3140
|
+
}
|
|
3141
|
+
}
|
|
3142
|
+
for (const m of src.match(/^export (?:const|function|class|interface|enum|abstract class) [A-Za-z0-9_]+/gm) ?? []) {
|
|
3143
|
+
const decl = m.split(/\s/).pop();
|
|
3144
|
+
if (decl)
|
|
3145
|
+
names.add(decl);
|
|
3146
|
+
}
|
|
3147
|
+
return [...names].sort();
|
|
3148
|
+
}
|
|
3149
|
+
async function readFixture(fixtureFile) {
|
|
3150
|
+
const fsMod = await import('fs'); // eslint-disable-line @typescript-eslint/consistent-type-imports
|
|
3151
|
+
const pathMod = await import('path'); // eslint-disable-line @typescript-eslint/consistent-type-imports
|
|
3152
|
+
return JSON.parse(fsMod.readFileSync(pathMod.resolve(__dirname, 'fixtures', fixtureFile), 'utf-8'));
|
|
3153
|
+
}
|
|
3154
|
+
for (const fixtureFile of ['runtime-v2-barrel-surface.json', 'core-barrel-surface.json']) {
|
|
3155
|
+
it(`${fixtureFile}: export surface matches the frozen snapshot`, async () => {
|
|
3156
|
+
const fsMod = await import('fs'); // eslint-disable-line @typescript-eslint/consistent-type-imports
|
|
3157
|
+
const pathMod = await import('path'); // eslint-disable-line @typescript-eslint/consistent-type-imports
|
|
3158
|
+
const fixture = await readFixture(fixtureFile);
|
|
3159
|
+
const src = fsMod.readFileSync(pathMod.resolve(__dirname, '..', '..', '..', fixture.barrel), 'utf-8');
|
|
3160
|
+
const current = extractExportNames(src);
|
|
3161
|
+
const added = current.filter((n) => !fixture.names.includes(n));
|
|
3162
|
+
const removed = fixture.names.filter((n) => !current.includes(n));
|
|
3163
|
+
const diffMessage = [
|
|
3164
|
+
`${fixture.barrel} export surface drifted from the frozen snapshot (PRI-775):`,
|
|
3165
|
+
...(added.length > 0 ? [` + added (${added.length}): ${added.join(', ')}`] : []),
|
|
3166
|
+
...(removed.length > 0 ? [` - removed (${removed.length}): ${removed.join(', ')}`] : []),
|
|
3167
|
+
'To change the surface intentionally: update __tests__/fixtures/' + fixtureFile,
|
|
3168
|
+
' and state the reason with a PRI tag in the PR description. Ghost exports',
|
|
3169
|
+
' without production consumers are how barrel entropy regrows (PRI-751 audit).',
|
|
3170
|
+
].join('\n');
|
|
3171
|
+
expect(added.length + removed.length, diffMessage).toBe(0);
|
|
3172
|
+
});
|
|
3173
|
+
}
|
|
3174
|
+
it('barrel surface snapshots are self-consistent', async () => {
|
|
3175
|
+
for (const fixtureFile of ['runtime-v2-barrel-surface.json', 'core-barrel-surface.json']) {
|
|
3176
|
+
const fixture = await readFixture(fixtureFile);
|
|
3177
|
+
expect(fixture.names.length, `${fixtureFile}: "count" field is stale`).toBe(fixture.count);
|
|
3178
|
+
expect([...fixture.names].sort(), `${fixtureFile}: names are not sorted/deduped`).toEqual(fixture.names);
|
|
3179
|
+
expect(new Set(fixture.names).size, `${fixtureFile}: duplicate names`).toBe(fixture.names.length);
|
|
3180
|
+
expect(fixture.names.every((n) => IDENTIFIER_RE.test(n)), `${fixtureFile}: snapshot contains non-identifier names (comment/text pollution)`).toBe(true);
|
|
3181
|
+
}
|
|
3182
|
+
});
|
|
3183
|
+
it('extractor contract: comments, aliases, type-only blocks, and fail-loud traps', () => {
|
|
3184
|
+
// Comments inside an export block must never leak into the frozen names.
|
|
3185
|
+
expect(extractExportNames([
|
|
3186
|
+
'export {',
|
|
3187
|
+
' /** @deprecated use Bar instead */',
|
|
3188
|
+
' Foo,',
|
|
3189
|
+
' Bar, // trailing note',
|
|
3190
|
+
"} from './x.js';",
|
|
3191
|
+
].join('\n'))).toEqual(['Bar', 'Foo']);
|
|
3192
|
+
// A comma inside a comment must not split the comment in half and glue
|
|
3193
|
+
// comment text onto the next symbol (hit on real barrel source).
|
|
3194
|
+
expect(extractExportNames([
|
|
3195
|
+
'export {',
|
|
3196
|
+
' // re-exports Foo, not deep imports.',
|
|
3197
|
+
' Foo,',
|
|
3198
|
+
' /* block, comment */ Baz,',
|
|
3199
|
+
"} from './x.js';",
|
|
3200
|
+
].join('\n'))).toEqual(['Baz', 'Foo']);
|
|
3201
|
+
// Aliases freeze the exported (right-hand) name; inline `type` modifier is honored.
|
|
3202
|
+
expect(extractExportNames([
|
|
3203
|
+
'export {',
|
|
3204
|
+
' InternalFoo as Foo,',
|
|
3205
|
+
' type InternalBar as Bar,',
|
|
3206
|
+
"} from './x.js';",
|
|
3207
|
+
].join('\n'))).toEqual(['Bar', 'Foo']);
|
|
3208
|
+
// `export type { ... }` blocks and value declarations are all captured.
|
|
3209
|
+
expect(extractExportNames([
|
|
3210
|
+
'export type { Baz };',
|
|
3211
|
+
'export const QUX = 1;',
|
|
3212
|
+
'export function qux(): void {}',
|
|
3213
|
+
'export class Qux {}',
|
|
3214
|
+
'export interface IQux {}',
|
|
3215
|
+
'export enum QuxKind { A }',
|
|
3216
|
+
'export abstract class BaseQux {}',
|
|
3217
|
+
].join('\n'))).toEqual(['BaseQux', 'Baz', 'IQux', 'QUX', 'Qux', 'QuxKind', 'qux']);
|
|
3218
|
+
// Wildcard re-exports cannot be proven by a name snapshot: refuse.
|
|
3219
|
+
expect(() => extractExportNames("export * from './x.js';")).toThrow(/wildcard/);
|
|
3220
|
+
// Text fragments that never reduce to an identifier fail loud, never freeze.
|
|
3221
|
+
expect(() => extractExportNames('export { 123bad } from "./x.js";')).toThrow(/non-identifier/);
|
|
3222
|
+
// Whitespace variants of the block form are captured, not missed
|
|
3223
|
+
// (`export{Foo}` slipped past the old strict-space regex).
|
|
3224
|
+
expect(extractExportNames("export{NoSpace} from './x.js';")).toEqual(['NoSpace']);
|
|
3225
|
+
expect(extractExportNames("export type{NoSpaceType} from './x.js';")).toEqual(['NoSpaceType']);
|
|
3226
|
+
// A barrel default export is invisible to the name set: refuse.
|
|
3227
|
+
expect(() => extractExportNames("import Foo from './x.js';\nexport default Foo;\n")).toThrow(/default/);
|
|
3228
|
+
});
|
|
3229
|
+
});
|
|
3086
3230
|
// ── PRI-443: Pure module boundary guards ──────────────────────────────────────
|
|
3087
3231
|
//
|
|
3088
3232
|
// Phases 1-3 extracted pure types/codecs/schema out of I/O modules. These guards
|