@principles/pd-cli 1.73.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 +90 -0
- package/dist/commands/artifact.d.ts +14 -0
- package/dist/commands/artifact.d.ts.map +1 -0
- package/dist/commands/artifact.js +67 -0
- package/dist/commands/artifact.js.map +1 -0
- package/dist/commands/candidate.d.ts +83 -0
- package/dist/commands/candidate.d.ts.map +1 -0
- package/dist/commands/candidate.js +891 -0
- package/dist/commands/candidate.js.map +1 -0
- package/dist/commands/central-sync.d.ts +10 -0
- package/dist/commands/central-sync.d.ts.map +1 -0
- package/dist/commands/central-sync.js +32 -0
- package/dist/commands/central-sync.js.map +1 -0
- package/dist/commands/console.d.ts +9 -0
- package/dist/commands/console.d.ts.map +1 -0
- package/dist/commands/console.js +114 -0
- package/dist/commands/console.js.map +1 -0
- package/dist/commands/context.d.ts +7 -0
- package/dist/commands/context.d.ts.map +1 -0
- package/dist/commands/context.js +55 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/demo-story-a.d.ts +12 -0
- package/dist/commands/demo-story-a.d.ts.map +1 -0
- package/dist/commands/demo-story-a.js +175 -0
- package/dist/commands/demo-story-a.js.map +1 -0
- package/dist/commands/diagnose.d.ts +35 -0
- package/dist/commands/diagnose.d.ts.map +1 -0
- package/dist/commands/diagnose.js +390 -0
- package/dist/commands/diagnose.js.map +1 -0
- package/dist/commands/evolution-tasks-list.d.ts +15 -0
- package/dist/commands/evolution-tasks-list.d.ts.map +1 -0
- package/dist/commands/evolution-tasks-list.js +34 -0
- package/dist/commands/evolution-tasks-list.js.map +1 -0
- package/dist/commands/evolution-tasks-show.d.ts +14 -0
- package/dist/commands/evolution-tasks-show.d.ts.map +1 -0
- package/dist/commands/evolution-tasks-show.js +52 -0
- package/dist/commands/evolution-tasks-show.js.map +1 -0
- package/dist/commands/flow.d.ts +7 -0
- package/dist/commands/flow.d.ts.map +1 -0
- package/dist/commands/flow.js +57 -0
- package/dist/commands/flow.js.map +1 -0
- package/dist/commands/health.d.ts +16 -0
- package/dist/commands/health.d.ts.map +1 -0
- package/dist/commands/health.js +150 -0
- package/dist/commands/health.js.map +1 -0
- package/dist/commands/history.d.ts +11 -0
- package/dist/commands/history.d.ts.map +1 -0
- package/dist/commands/history.js +50 -0
- package/dist/commands/history.js.map +1 -0
- package/dist/commands/legacy-cleanup.d.ts +27 -0
- package/dist/commands/legacy-cleanup.d.ts.map +1 -0
- package/dist/commands/legacy-cleanup.js +171 -0
- package/dist/commands/legacy-cleanup.js.map +1 -0
- package/dist/commands/legacy-import.d.ts +7 -0
- package/dist/commands/legacy-import.d.ts.map +1 -0
- package/dist/commands/legacy-import.js +86 -0
- package/dist/commands/legacy-import.js.map +1 -0
- package/dist/commands/pain-record.d.ts +10 -0
- package/dist/commands/pain-record.d.ts.map +1 -0
- package/dist/commands/pain-record.js +162 -0
- package/dist/commands/pain-record.js.map +1 -0
- package/dist/commands/proven-channel-baseline.d.ts +12 -0
- package/dist/commands/proven-channel-baseline.d.ts.map +1 -0
- package/dist/commands/proven-channel-baseline.js +97 -0
- package/dist/commands/proven-channel-baseline.js.map +1 -0
- package/dist/commands/remediation-output.d.ts +40 -0
- package/dist/commands/remediation-output.d.ts.map +1 -0
- package/dist/commands/remediation-output.js +23 -0
- package/dist/commands/remediation-output.js.map +1 -0
- package/dist/commands/run.d.ts +10 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +68 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/runtime-activation.d.ts +11 -0
- package/dist/commands/runtime-activation.d.ts.map +1 -0
- package/dist/commands/runtime-activation.js +150 -0
- package/dist/commands/runtime-activation.js.map +1 -0
- package/dist/commands/runtime-canary.d.ts +30 -0
- package/dist/commands/runtime-canary.d.ts.map +1 -0
- package/dist/commands/runtime-canary.js +343 -0
- package/dist/commands/runtime-canary.js.map +1 -0
- package/dist/commands/runtime-diagnostics-export.d.ts +20 -0
- package/dist/commands/runtime-diagnostics-export.d.ts.map +1 -0
- package/dist/commands/runtime-diagnostics-export.js +177 -0
- package/dist/commands/runtime-diagnostics-export.js.map +1 -0
- package/dist/commands/runtime-features.d.ts +26 -0
- package/dist/commands/runtime-features.d.ts.map +1 -0
- package/dist/commands/runtime-features.js +70 -0
- package/dist/commands/runtime-features.js.map +1 -0
- package/dist/commands/runtime-gfi-snapshot.d.ts +7 -0
- package/dist/commands/runtime-gfi-snapshot.d.ts.map +1 -0
- package/dist/commands/runtime-gfi-snapshot.js +101 -0
- package/dist/commands/runtime-gfi-snapshot.js.map +1 -0
- package/dist/commands/runtime-health-snapshot.d.ts +7 -0
- package/dist/commands/runtime-health-snapshot.d.ts.map +1 -0
- package/dist/commands/runtime-health-snapshot.js +93 -0
- package/dist/commands/runtime-health-snapshot.js.map +1 -0
- package/dist/commands/runtime-idle-trigger.d.ts +12 -0
- package/dist/commands/runtime-idle-trigger.d.ts.map +1 -0
- package/dist/commands/runtime-idle-trigger.js +102 -0
- package/dist/commands/runtime-idle-trigger.js.map +1 -0
- package/dist/commands/runtime-internalization-enqueue-successors.d.ts +9 -0
- package/dist/commands/runtime-internalization-enqueue-successors.d.ts.map +1 -0
- package/dist/commands/runtime-internalization-enqueue-successors.js +393 -0
- package/dist/commands/runtime-internalization-enqueue-successors.js.map +1 -0
- package/dist/commands/runtime-internalization-integrity-repair.d.ts +9 -0
- package/dist/commands/runtime-internalization-integrity-repair.d.ts.map +1 -0
- package/dist/commands/runtime-internalization-integrity-repair.js +54 -0
- package/dist/commands/runtime-internalization-integrity-repair.js.map +1 -0
- package/dist/commands/runtime-internalization-integrity.d.ts +7 -0
- package/dist/commands/runtime-internalization-integrity.d.ts.map +1 -0
- package/dist/commands/runtime-internalization-integrity.js +53 -0
- package/dist/commands/runtime-internalization-integrity.js.map +1 -0
- package/dist/commands/runtime-internalization-queue.d.ts +7 -0
- package/dist/commands/runtime-internalization-queue.d.ts.map +1 -0
- package/dist/commands/runtime-internalization-queue.js +85 -0
- package/dist/commands/runtime-internalization-queue.js.map +1 -0
- package/dist/commands/runtime-internalization-run-once.d.ts +12 -0
- package/dist/commands/runtime-internalization-run-once.d.ts.map +1 -0
- package/dist/commands/runtime-internalization-run-once.js +546 -0
- package/dist/commands/runtime-internalization-run-once.js.map +1 -0
- package/dist/commands/runtime-internalization-wake-once.d.ts +8 -0
- package/dist/commands/runtime-internalization-wake-once.d.ts.map +1 -0
- package/dist/commands/runtime-internalization-wake-once.js +72 -0
- package/dist/commands/runtime-internalization-wake-once.js.map +1 -0
- package/dist/commands/runtime-pain-flood-simulation.d.ts +10 -0
- package/dist/commands/runtime-pain-flood-simulation.d.ts.map +1 -0
- package/dist/commands/runtime-pain-flood-simulation.js +104 -0
- package/dist/commands/runtime-pain-flood-simulation.js.map +1 -0
- package/dist/commands/runtime-pruning.d.ts +45 -0
- package/dist/commands/runtime-pruning.d.ts.map +1 -0
- package/dist/commands/runtime-pruning.js +355 -0
- package/dist/commands/runtime-pruning.js.map +1 -0
- package/dist/commands/runtime-recovery.d.ts +9 -0
- package/dist/commands/runtime-recovery.d.ts.map +1 -0
- package/dist/commands/runtime-recovery.js +94 -0
- package/dist/commands/runtime-recovery.js.map +1 -0
- package/dist/commands/runtime-synthetic-baseline.d.ts +7 -0
- package/dist/commands/runtime-synthetic-baseline.d.ts.map +1 -0
- package/dist/commands/runtime-synthetic-baseline.js +59 -0
- package/dist/commands/runtime-synthetic-baseline.js.map +1 -0
- package/dist/commands/runtime-uat.d.ts +52 -0
- package/dist/commands/runtime-uat.d.ts.map +1 -0
- package/dist/commands/runtime-uat.js +274 -0
- package/dist/commands/runtime-uat.js.map +1 -0
- package/dist/commands/runtime.d.ts +20 -0
- package/dist/commands/runtime.d.ts.map +1 -0
- package/dist/commands/runtime.js +256 -0
- package/dist/commands/runtime.js.map +1 -0
- package/dist/commands/samples-list.d.ts +11 -0
- package/dist/commands/samples-list.d.ts.map +1 -0
- package/dist/commands/samples-list.js +37 -0
- package/dist/commands/samples-list.js.map +1 -0
- package/dist/commands/samples-review.d.ts +14 -0
- package/dist/commands/samples-review.d.ts.map +1 -0
- package/dist/commands/samples-review.js +22 -0
- package/dist/commands/samples-review.js.map +1 -0
- package/dist/commands/task.d.ts +14 -0
- package/dist/commands/task.d.ts.map +1 -0
- package/dist/commands/task.js +92 -0
- package/dist/commands/task.js.map +1 -0
- package/dist/commands/trace.d.ts +19 -0
- package/dist/commands/trace.d.ts.map +1 -0
- package/dist/commands/trace.js +154 -0
- package/dist/commands/trace.js.map +1 -0
- package/dist/commands/trajectory.d.ts +11 -0
- package/dist/commands/trajectory.d.ts.map +1 -0
- package/dist/commands/trajectory.js +47 -0
- package/dist/commands/trajectory.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +736 -0
- package/dist/index.js.map +1 -0
- package/dist/legacy/legacy-import.d.ts +15 -0
- package/dist/legacy/legacy-import.d.ts.map +1 -0
- package/dist/legacy/legacy-import.js +141 -0
- package/dist/legacy/legacy-import.js.map +1 -0
- package/dist/legacy/session-history-import.d.ts +26 -0
- package/dist/legacy/session-history-import.d.ts.map +1 -0
- package/dist/legacy/session-history-import.js +151 -0
- package/dist/legacy/session-history-import.js.map +1 -0
- package/dist/principle-tree-ledger-adapter.d.ts +12 -0
- package/dist/principle-tree-ledger-adapter.d.ts.map +1 -0
- package/dist/principle-tree-ledger-adapter.js +12 -0
- package/dist/principle-tree-ledger-adapter.js.map +1 -0
- package/dist/resolve-workspace.d.ts +12 -0
- package/dist/resolve-workspace.d.ts.map +1 -0
- package/dist/resolve-workspace.js +20 -0
- package/dist/resolve-workspace.js.map +1 -0
- package/dist/services/demo-story-a-runner.d.ts +8 -0
- package/dist/services/demo-story-a-runner.d.ts.map +1 -0
- package/dist/services/demo-story-a-runner.js +369 -0
- package/dist/services/demo-story-a-runner.js.map +1 -0
- package/dist/services/feature-flag-loader.d.ts +6 -0
- package/dist/services/feature-flag-loader.d.ts.map +1 -0
- package/dist/services/feature-flag-loader.js +54 -0
- package/dist/services/feature-flag-loader.js.map +1 -0
- package/dist/services/pain-flood-simulation-runner.d.ts +10 -0
- package/dist/services/pain-flood-simulation-runner.d.ts.map +1 -0
- package/dist/services/pain-flood-simulation-runner.js +289 -0
- package/dist/services/pain-flood-simulation-runner.js.map +1 -0
- package/dist/services/proven-channel-baseline-runner.d.ts +12 -0
- package/dist/services/proven-channel-baseline-runner.d.ts.map +1 -0
- package/dist/services/proven-channel-baseline-runner.js +114 -0
- package/dist/services/proven-channel-baseline-runner.js.map +1 -0
- package/dist/services/synthetic-baseline-runner.d.ts +8 -0
- package/dist/services/synthetic-baseline-runner.d.ts.map +1 -0
- package/dist/services/synthetic-baseline-runner.js +251 -0
- package/dist/services/synthetic-baseline-runner.js.map +1 -0
- package/package.json +35 -0
- package/src/commands/artifact.ts +82 -0
- package/src/commands/candidate.ts +1117 -0
- package/src/commands/central-sync.ts +44 -0
- package/src/commands/console.ts +121 -0
- package/src/commands/context.ts +72 -0
- package/src/commands/demo-story-a.ts +195 -0
- package/src/commands/diagnose.ts +452 -0
- package/src/commands/evolution-tasks-list.ts +44 -0
- package/src/commands/evolution-tasks-show.ts +60 -0
- package/src/commands/flow.ts +60 -0
- package/src/commands/health.ts +189 -0
- package/src/commands/history.ts +63 -0
- package/src/commands/legacy-cleanup.ts +206 -0
- package/src/commands/legacy-import.ts +104 -0
- package/src/commands/pain-record.ts +167 -0
- package/src/commands/proven-channel-baseline.ts +113 -0
- package/src/commands/remediation-output.ts +66 -0
- package/src/commands/run.ts +89 -0
- package/src/commands/runtime-activation.ts +176 -0
- package/src/commands/runtime-canary.ts +371 -0
- package/src/commands/runtime-diagnostics-export.ts +229 -0
- package/src/commands/runtime-features.ts +103 -0
- package/src/commands/runtime-gfi-snapshot.ts +135 -0
- package/src/commands/runtime-health-snapshot.ts +106 -0
- package/src/commands/runtime-internalization-enqueue-successors.ts +479 -0
- package/src/commands/runtime-internalization-integrity-repair.ts +69 -0
- package/src/commands/runtime-internalization-integrity.ts +63 -0
- package/src/commands/runtime-internalization-queue.ts +106 -0
- package/src/commands/runtime-internalization-run-once.ts +658 -0
- package/src/commands/runtime-internalization-wake-once.ts +87 -0
- package/src/commands/runtime-pain-flood-simulation.ts +121 -0
- package/src/commands/runtime-pruning.ts +438 -0
- package/src/commands/runtime-recovery.ts +107 -0
- package/src/commands/runtime-synthetic-baseline.ts +70 -0
- package/src/commands/runtime-uat.ts +339 -0
- package/src/commands/runtime.ts +281 -0
- package/src/commands/samples-list.ts +43 -0
- package/src/commands/samples-review.ts +32 -0
- package/src/commands/task.ts +130 -0
- package/src/commands/trace.ts +174 -0
- package/src/commands/trajectory.ts +64 -0
- package/src/index.ts +829 -0
- package/src/legacy/legacy-import.ts +179 -0
- package/src/legacy/session-history-import.ts +231 -0
- package/src/principle-tree-ledger-adapter.ts +13 -0
- package/src/resolve-workspace.ts +20 -0
- package/src/services/demo-story-a-runner.ts +472 -0
- package/src/services/feature-flag-loader.ts +73 -0
- package/src/services/pain-flood-simulation-runner.ts +354 -0
- package/src/services/proven-channel-baseline-runner.ts +150 -0
- package/src/services/synthetic-baseline-runner.ts +291 -0
- package/tests/commands/candidate-audit-repair.test.ts +338 -0
- package/tests/commands/candidate-intake.test.ts +589 -0
- package/tests/commands/candidate-internalization-backfill.test.ts +480 -0
- package/tests/commands/candidate-internalize.test.ts +272 -0
- package/tests/commands/candidate-route.test.ts +328 -0
- package/tests/commands/candidate-show.test.ts +95 -0
- package/tests/commands/cli-command-tree.test.ts +64 -0
- package/tests/commands/context.test.ts +114 -0
- package/tests/commands/demo-story-a.test.ts +255 -0
- package/tests/commands/diagnose.test.ts +792 -0
- package/tests/commands/health.test.ts +330 -0
- package/tests/commands/pain-record.test.ts +316 -0
- package/tests/commands/plugin-config-resolution-cutover.test.ts +220 -0
- package/tests/commands/proven-channel-baseline.test.ts +441 -0
- package/tests/commands/runtime-activation.test.ts +168 -0
- package/tests/commands/runtime-canary.test.ts +369 -0
- package/tests/commands/runtime-diagnostics-export.test.ts +170 -0
- package/tests/commands/runtime-features.test.ts +114 -0
- package/tests/commands/runtime-health-snapshot.test.ts +357 -0
- package/tests/commands/runtime-internalization-enqueue-successors.test.ts +803 -0
- package/tests/commands/runtime-internalization-integrity-repair.test.ts +169 -0
- package/tests/commands/runtime-internalization-integrity.test.ts +102 -0
- package/tests/commands/runtime-internalization-queue.test.ts +252 -0
- package/tests/commands/runtime-internalization-run-once.test.ts +1318 -0
- package/tests/commands/runtime-internalization-wake-once.test.ts +170 -0
- package/tests/commands/runtime-internalization.test.ts +52 -0
- package/tests/commands/runtime-pain-flood-simulation.test.ts +418 -0
- package/tests/commands/runtime-pruning.test.ts +693 -0
- package/tests/commands/runtime-recovery.test.ts +96 -0
- package/tests/commands/runtime-synthetic-baseline.test.ts +249 -0
- package/tests/commands/runtime-uat.test.ts +397 -0
- package/tests/commands/runtime.test.ts +262 -0
- package/tests/commands/trace.test.ts +314 -0
- package/tests/e2e/candidate-intake-e2e.test.ts +316 -0
- package/tests/services/feature-flag-loader.test.ts +207 -0
- package/tests/services/proven-channel-baseline-runner.test.ts +30 -0
- package/tsconfig.json +26 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import * as fs from 'node:fs';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import * as os from 'node:os';
|
|
5
|
+
import {
|
|
6
|
+
loadEffectiveFeatureFlags,
|
|
7
|
+
getFeatureFlagsConfigPath,
|
|
8
|
+
FEATURE_FLAGS_CONFIG_FILENAME,
|
|
9
|
+
FEATURE_FLAGS_CONFIG_DIR,
|
|
10
|
+
} from '../../src/services/feature-flag-loader.js';
|
|
11
|
+
|
|
12
|
+
function createTempWorkspace(): string {
|
|
13
|
+
return fs.mkdtempSync(path.join(os.tmpdir(), 'pd-ffl-test-'));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function writeConfig(tmpDir: string, content: string): void {
|
|
17
|
+
const configDir = path.join(tmpDir, FEATURE_FLAGS_CONFIG_DIR);
|
|
18
|
+
fs.mkdirSync(configDir, { recursive: true });
|
|
19
|
+
fs.writeFileSync(path.join(configDir, FEATURE_FLAGS_CONFIG_FILENAME), content, 'utf8');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function cleanup(tmpDir: string): void {
|
|
23
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
describe('feature-flag-loader', () => {
|
|
27
|
+
describe('getFeatureFlagsConfigPath', () => {
|
|
28
|
+
it('should return path under .pd/feature-flags.yaml', () => {
|
|
29
|
+
const result = getFeatureFlagsConfigPath('/workspace/project');
|
|
30
|
+
expect(result).toBe(path.join('/workspace/project', '.pd', 'feature-flags.yaml'));
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('should use FEATURE_FLAGS_CONFIG_DIR and FEATURE_FLAGS_CONFIG_FILENAME constants', () => {
|
|
34
|
+
const result = getFeatureFlagsConfigPath('/root');
|
|
35
|
+
expect(result).toContain(FEATURE_FLAGS_CONFIG_DIR);
|
|
36
|
+
expect(result).toContain(FEATURE_FLAGS_CONFIG_FILENAME);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('loadEffectiveFeatureFlags', () => {
|
|
41
|
+
it('should return defaults when config file does not exist', () => {
|
|
42
|
+
const tmpDir = createTempWorkspace();
|
|
43
|
+
try {
|
|
44
|
+
const result = loadEffectiveFeatureFlags(tmpDir);
|
|
45
|
+
expect(result.source).toBe('defaults');
|
|
46
|
+
expect(result.warnings).toEqual([]);
|
|
47
|
+
} finally {
|
|
48
|
+
cleanup(tmpDir);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('should return defaults with YAML parse error warning for malformed YAML', () => {
|
|
53
|
+
const tmpDir = createTempWorkspace();
|
|
54
|
+
writeConfig(tmpDir, 'gfi: [unterminated');
|
|
55
|
+
try {
|
|
56
|
+
const result = loadEffectiveFeatureFlags(tmpDir);
|
|
57
|
+
expect(result.warnings.some(w => w.includes('YAML parse error'))).toBe(true);
|
|
58
|
+
} finally {
|
|
59
|
+
cleanup(tmpDir);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('should return defaults with mapping warning when YAML contains an array', () => {
|
|
64
|
+
const tmpDir = createTempWorkspace();
|
|
65
|
+
writeConfig(tmpDir, '- item1\n- item2\n');
|
|
66
|
+
try {
|
|
67
|
+
const result = loadEffectiveFeatureFlags(tmpDir);
|
|
68
|
+
expect(result.warnings.some(w => w.includes('expected a mapping'))).toBe(true);
|
|
69
|
+
} finally {
|
|
70
|
+
cleanup(tmpDir);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('should return defaults with mapping warning when YAML contains null', () => {
|
|
75
|
+
const tmpDir = createTempWorkspace();
|
|
76
|
+
writeConfig(tmpDir, '---\nnull\n');
|
|
77
|
+
try {
|
|
78
|
+
const result = loadEffectiveFeatureFlags(tmpDir);
|
|
79
|
+
expect(result.warnings.some(w => w.includes('expected a mapping'))).toBe(true);
|
|
80
|
+
} finally {
|
|
81
|
+
cleanup(tmpDir);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('should return defaults with mapping warning when YAML is undefined after parse', () => {
|
|
86
|
+
const tmpDir = createTempWorkspace();
|
|
87
|
+
writeConfig(tmpDir, '---\n');
|
|
88
|
+
try {
|
|
89
|
+
const result = loadEffectiveFeatureFlags(tmpDir);
|
|
90
|
+
expect(result.source).toBe('defaults');
|
|
91
|
+
expect(result.warnings.some(w => w.includes('expected a mapping'))).toBe(true);
|
|
92
|
+
} finally {
|
|
93
|
+
cleanup(tmpDir);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should return defaults with mapping warning when YAML contains a scalar string', () => {
|
|
98
|
+
const tmpDir = createTempWorkspace();
|
|
99
|
+
writeConfig(tmpDir, 'just a string\n');
|
|
100
|
+
try {
|
|
101
|
+
const result = loadEffectiveFeatureFlags(tmpDir);
|
|
102
|
+
expect(result.warnings.some(w => w.includes('expected a mapping'))).toBe(true);
|
|
103
|
+
} finally {
|
|
104
|
+
cleanup(tmpDir);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('should return defaults with mapping warning when YAML contains a number', () => {
|
|
109
|
+
const tmpDir = createTempWorkspace();
|
|
110
|
+
writeConfig(tmpDir, '42\n');
|
|
111
|
+
try {
|
|
112
|
+
const result = loadEffectiveFeatureFlags(tmpDir);
|
|
113
|
+
expect(result.warnings.some(w => w.includes('expected a mapping'))).toBe(true);
|
|
114
|
+
} finally {
|
|
115
|
+
cleanup(tmpDir);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('should reject __proto__ dangerous key', () => {
|
|
120
|
+
const tmpDir = createTempWorkspace();
|
|
121
|
+
writeConfig(tmpDir, '"__proto__":\n enabled: true\n');
|
|
122
|
+
try {
|
|
123
|
+
const result = loadEffectiveFeatureFlags(tmpDir);
|
|
124
|
+
expect(result.warnings.some(w => w.includes("dangerous key '__proto__' rejected"))).toBe(true);
|
|
125
|
+
expect(Object.hasOwn(result.flags, '__proto__')).toBe(false);
|
|
126
|
+
} finally {
|
|
127
|
+
cleanup(tmpDir);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('should reject constructor dangerous key', () => {
|
|
132
|
+
const tmpDir = createTempWorkspace();
|
|
133
|
+
writeConfig(tmpDir, 'constructor:\n enabled: true\n');
|
|
134
|
+
try {
|
|
135
|
+
const result = loadEffectiveFeatureFlags(tmpDir);
|
|
136
|
+
expect(result.warnings.some(w => w.includes("dangerous key 'constructor' rejected"))).toBe(true);
|
|
137
|
+
expect(Object.hasOwn(result.flags, 'constructor')).toBe(false);
|
|
138
|
+
} finally {
|
|
139
|
+
cleanup(tmpDir);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('should reject prototype dangerous key', () => {
|
|
144
|
+
const tmpDir = createTempWorkspace();
|
|
145
|
+
writeConfig(tmpDir, 'prototype:\n enabled: true\n');
|
|
146
|
+
try {
|
|
147
|
+
const result = loadEffectiveFeatureFlags(tmpDir);
|
|
148
|
+
expect(result.warnings.some(w => w.includes("dangerous key 'prototype' rejected"))).toBe(true);
|
|
149
|
+
expect(Object.hasOwn(result.flags, 'prototype')).toBe(false);
|
|
150
|
+
} finally {
|
|
151
|
+
cleanup(tmpDir);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('should allow valid keys while rejecting dangerous ones', () => {
|
|
156
|
+
const tmpDir = createTempWorkspace();
|
|
157
|
+
writeConfig(tmpDir, 'gfi:\n enabled: true\nprototype:\n enabled: true\n');
|
|
158
|
+
try {
|
|
159
|
+
const result = loadEffectiveFeatureFlags(tmpDir);
|
|
160
|
+
expect(result.warnings.some(w => w.includes("dangerous key 'prototype' rejected"))).toBe(true);
|
|
161
|
+
expect(result.flags.gfi).toBeDefined();
|
|
162
|
+
if (result.flags.gfi) {
|
|
163
|
+
expect(result.flags.gfi.enabled).toBe(true);
|
|
164
|
+
}
|
|
165
|
+
} finally {
|
|
166
|
+
cleanup(tmpDir);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('should parse valid YAML config and set source to workspace_file', () => {
|
|
171
|
+
const tmpDir = createTempWorkspace();
|
|
172
|
+
writeConfig(tmpDir, 'gfi:\n enabled: true\n');
|
|
173
|
+
try {
|
|
174
|
+
const result = loadEffectiveFeatureFlags(tmpDir);
|
|
175
|
+
expect(result.source).toBe('workspace_file');
|
|
176
|
+
expect(result.flags.gfi).toBeDefined();
|
|
177
|
+
if (result.flags.gfi) {
|
|
178
|
+
expect(result.flags.gfi.enabled).toBe(true);
|
|
179
|
+
}
|
|
180
|
+
} finally {
|
|
181
|
+
cleanup(tmpDir);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('should handle empty YAML mapping with defaults source', () => {
|
|
186
|
+
const tmpDir = createTempWorkspace();
|
|
187
|
+
writeConfig(tmpDir, '{}\n');
|
|
188
|
+
try {
|
|
189
|
+
const result = loadEffectiveFeatureFlags(tmpDir);
|
|
190
|
+
expect(result.source).toBe('defaults');
|
|
191
|
+
expect(result.warnings).toEqual([]);
|
|
192
|
+
} finally {
|
|
193
|
+
cleanup(tmpDir);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('should include configPath in result', () => {
|
|
198
|
+
const tmpDir = createTempWorkspace();
|
|
199
|
+
try {
|
|
200
|
+
const result = loadEffectiveFeatureFlags(tmpDir);
|
|
201
|
+
expect(result.configPath).toContain(FEATURE_FLAGS_CONFIG_FILENAME);
|
|
202
|
+
} finally {
|
|
203
|
+
cleanup(tmpDir);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import * as os from 'os';
|
|
4
|
+
import { isProductionWorkspace } from '../../src/services/proven-channel-baseline-runner.js';
|
|
5
|
+
|
|
6
|
+
describe('isProductionWorkspace (real implementation)', () => {
|
|
7
|
+
it('blocks exact production workspace path', () => {
|
|
8
|
+
const homedirWorkspace = path.join(os.homedir(), '.openclaw', 'workspace');
|
|
9
|
+
expect(isProductionWorkspace(homedirWorkspace)).toBe(true);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('blocks descendant of production workspace', () => {
|
|
13
|
+
const homedirWorkspace = path.join(os.homedir(), '.openclaw', 'workspace', 'my-project');
|
|
14
|
+
expect(isProductionWorkspace(homedirWorkspace)).toBe(true);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('does NOT block sibling path with different prefix', () => {
|
|
18
|
+
const sibling = path.join(os.homedir(), '.openclaw', 'workspace-extra');
|
|
19
|
+
expect(isProductionWorkspace(sibling)).toBe(false);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('does NOT block unrelated path', () => {
|
|
23
|
+
expect(isProductionWorkspace('C:\\Users\\test\\project')).toBe(false);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('does NOT block temp directory', () => {
|
|
27
|
+
const tmp = os.tmpdir();
|
|
28
|
+
expect(isProductionWorkspace(tmp)).toBe(false);
|
|
29
|
+
});
|
|
30
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"lib": ["ES2022"],
|
|
7
|
+
"rootDir": "./src",
|
|
8
|
+
"outDir": "./dist",
|
|
9
|
+
"declaration": true,
|
|
10
|
+
"declarationMap": true,
|
|
11
|
+
"sourceMap": true,
|
|
12
|
+
"strict": true,
|
|
13
|
+
"noImplicitOverride": true,
|
|
14
|
+
"noUncheckedIndexedAccess": false,
|
|
15
|
+
"esModuleInterop": true,
|
|
16
|
+
"skipLibCheck": true,
|
|
17
|
+
"forceConsistentCasingInFileNames": true,
|
|
18
|
+
"resolveJsonModule": true,
|
|
19
|
+
"types": ["node"],
|
|
20
|
+
"paths": {
|
|
21
|
+
"@principles/core/runtime-v2/*": ["../principles-core/dist/runtime-v2/*"]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"include": ["src/**/*"],
|
|
25
|
+
"exclude": ["node_modules", "dist"]
|
|
26
|
+
}
|