popeye-cli 1.9.5 → 2.0.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/CHANGELOG.md +59 -0
- package/CONTRIBUTING.md +15 -1
- package/README.md +57 -0
- package/cheatsheet.md +65 -0
- package/dist/cli/commands/debug-context.d.ts +64 -0
- package/dist/cli/commands/debug-context.d.ts.map +1 -0
- package/dist/cli/commands/debug-context.js +221 -0
- package/dist/cli/commands/debug-context.js.map +1 -0
- package/dist/cli/commands/debug-prompts.d.ts +25 -0
- package/dist/cli/commands/debug-prompts.d.ts.map +1 -0
- package/dist/cli/commands/debug-prompts.js +80 -0
- package/dist/cli/commands/debug-prompts.js.map +1 -0
- package/dist/cli/commands/debug.d.ts +68 -0
- package/dist/cli/commands/debug.d.ts.map +1 -0
- package/dist/cli/commands/debug.js +543 -0
- package/dist/cli/commands/debug.js.map +1 -0
- package/dist/cli/commands/index.d.ts +1 -0
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +1 -0
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/interactive.d.ts.map +1 -1
- package/dist/cli/interactive.js +25 -0
- package/dist/cli/interactive.js.map +1 -1
- package/dist/generators/all.d.ts.map +1 -1
- package/dist/generators/all.js +2 -0
- package/dist/generators/all.js.map +1 -1
- package/dist/generators/templates/database-docker.d.ts.map +1 -1
- package/dist/generators/templates/database-docker.js +10 -0
- package/dist/generators/templates/database-docker.js.map +1 -1
- package/dist/generators/templates/fullstack.d.ts +4 -1
- package/dist/generators/templates/fullstack.d.ts.map +1 -1
- package/dist/generators/templates/fullstack.js +6 -2
- package/dist/generators/templates/fullstack.js.map +1 -1
- package/dist/pipeline/artifact-manager.d.ts +47 -0
- package/dist/pipeline/artifact-manager.d.ts.map +1 -0
- package/dist/pipeline/artifact-manager.js +251 -0
- package/dist/pipeline/artifact-manager.js.map +1 -0
- package/dist/pipeline/artifact-validators.d.ts +29 -0
- package/dist/pipeline/artifact-validators.d.ts.map +1 -0
- package/dist/pipeline/artifact-validators.js +173 -0
- package/dist/pipeline/artifact-validators.js.map +1 -0
- package/dist/pipeline/change-request.d.ts +47 -0
- package/dist/pipeline/change-request.d.ts.map +1 -0
- package/dist/pipeline/change-request.js +91 -0
- package/dist/pipeline/change-request.js.map +1 -0
- package/dist/pipeline/check-runner.d.ts +47 -0
- package/dist/pipeline/check-runner.d.ts.map +1 -0
- package/dist/pipeline/check-runner.js +417 -0
- package/dist/pipeline/check-runner.js.map +1 -0
- package/dist/pipeline/command-resolver.d.ts +9 -0
- package/dist/pipeline/command-resolver.d.ts.map +1 -0
- package/dist/pipeline/command-resolver.js +140 -0
- package/dist/pipeline/command-resolver.js.map +1 -0
- package/dist/pipeline/consensus/consensus-runner.d.ts +44 -0
- package/dist/pipeline/consensus/consensus-runner.d.ts.map +1 -0
- package/dist/pipeline/consensus/consensus-runner.js +212 -0
- package/dist/pipeline/consensus/consensus-runner.js.map +1 -0
- package/dist/pipeline/constitution.d.ts +45 -0
- package/dist/pipeline/constitution.d.ts.map +1 -0
- package/dist/pipeline/constitution.js +82 -0
- package/dist/pipeline/constitution.js.map +1 -0
- package/dist/pipeline/gate-engine.d.ts +55 -0
- package/dist/pipeline/gate-engine.d.ts.map +1 -0
- package/dist/pipeline/gate-engine.js +270 -0
- package/dist/pipeline/gate-engine.js.map +1 -0
- package/dist/pipeline/index.d.ts +26 -0
- package/dist/pipeline/index.d.ts.map +1 -0
- package/dist/pipeline/index.js +35 -0
- package/dist/pipeline/index.js.map +1 -0
- package/dist/pipeline/migration.d.ts +15 -0
- package/dist/pipeline/migration.d.ts.map +1 -0
- package/dist/pipeline/migration.js +76 -0
- package/dist/pipeline/migration.js.map +1 -0
- package/dist/pipeline/orchestrator.d.ts +28 -0
- package/dist/pipeline/orchestrator.d.ts.map +1 -0
- package/dist/pipeline/orchestrator.js +238 -0
- package/dist/pipeline/orchestrator.js.map +1 -0
- package/dist/pipeline/packets/audit-report-builder.d.ts +11 -0
- package/dist/pipeline/packets/audit-report-builder.d.ts.map +1 -0
- package/dist/pipeline/packets/audit-report-builder.js +32 -0
- package/dist/pipeline/packets/audit-report-builder.js.map +1 -0
- package/dist/pipeline/packets/consensus-packet-builder.d.ts +35 -0
- package/dist/pipeline/packets/consensus-packet-builder.d.ts.map +1 -0
- package/dist/pipeline/packets/consensus-packet-builder.js +80 -0
- package/dist/pipeline/packets/consensus-packet-builder.js.map +1 -0
- package/dist/pipeline/packets/index.d.ts +12 -0
- package/dist/pipeline/packets/index.d.ts.map +1 -0
- package/dist/pipeline/packets/index.js +8 -0
- package/dist/pipeline/packets/index.js.map +1 -0
- package/dist/pipeline/packets/plan-packet-builder.d.ts +21 -0
- package/dist/pipeline/packets/plan-packet-builder.d.ts.map +1 -0
- package/dist/pipeline/packets/plan-packet-builder.js +27 -0
- package/dist/pipeline/packets/plan-packet-builder.js.map +1 -0
- package/dist/pipeline/packets/rca-packet-builder.d.ts +19 -0
- package/dist/pipeline/packets/rca-packet-builder.d.ts.map +1 -0
- package/dist/pipeline/packets/rca-packet-builder.js +22 -0
- package/dist/pipeline/packets/rca-packet-builder.js.map +1 -0
- package/dist/pipeline/phases/architecture.d.ts +7 -0
- package/dist/pipeline/phases/architecture.d.ts.map +1 -0
- package/dist/pipeline/phases/architecture.js +60 -0
- package/dist/pipeline/phases/architecture.js.map +1 -0
- package/dist/pipeline/phases/audit.d.ts +8 -0
- package/dist/pipeline/phases/audit.d.ts.map +1 -0
- package/dist/pipeline/phases/audit.js +144 -0
- package/dist/pipeline/phases/audit.js.map +1 -0
- package/dist/pipeline/phases/consensus-architecture.d.ts +7 -0
- package/dist/pipeline/phases/consensus-architecture.d.ts.map +1 -0
- package/dist/pipeline/phases/consensus-architecture.js +84 -0
- package/dist/pipeline/phases/consensus-architecture.js.map +1 -0
- package/dist/pipeline/phases/consensus-master-plan.d.ts +7 -0
- package/dist/pipeline/phases/consensus-master-plan.d.ts.map +1 -0
- package/dist/pipeline/phases/consensus-master-plan.js +81 -0
- package/dist/pipeline/phases/consensus-master-plan.js.map +1 -0
- package/dist/pipeline/phases/consensus-role-plans.d.ts +7 -0
- package/dist/pipeline/phases/consensus-role-plans.d.ts.map +1 -0
- package/dist/pipeline/phases/consensus-role-plans.js +85 -0
- package/dist/pipeline/phases/consensus-role-plans.js.map +1 -0
- package/dist/pipeline/phases/done.d.ts +7 -0
- package/dist/pipeline/phases/done.d.ts.map +1 -0
- package/dist/pipeline/phases/done.js +45 -0
- package/dist/pipeline/phases/done.js.map +1 -0
- package/dist/pipeline/phases/implementation.d.ts +8 -0
- package/dist/pipeline/phases/implementation.d.ts.map +1 -0
- package/dist/pipeline/phases/implementation.js +42 -0
- package/dist/pipeline/phases/implementation.js.map +1 -0
- package/dist/pipeline/phases/index.d.ts +20 -0
- package/dist/pipeline/phases/index.d.ts.map +1 -0
- package/dist/pipeline/phases/index.js +19 -0
- package/dist/pipeline/phases/index.js.map +1 -0
- package/dist/pipeline/phases/intake.d.ts +8 -0
- package/dist/pipeline/phases/intake.d.ts.map +1 -0
- package/dist/pipeline/phases/intake.js +40 -0
- package/dist/pipeline/phases/intake.js.map +1 -0
- package/dist/pipeline/phases/phase-context.d.ts +30 -0
- package/dist/pipeline/phases/phase-context.d.ts.map +1 -0
- package/dist/pipeline/phases/phase-context.js +33 -0
- package/dist/pipeline/phases/phase-context.js.map +1 -0
- package/dist/pipeline/phases/production-gate.d.ts +8 -0
- package/dist/pipeline/phases/production-gate.d.ts.map +1 -0
- package/dist/pipeline/phases/production-gate.js +84 -0
- package/dist/pipeline/phases/production-gate.js.map +1 -0
- package/dist/pipeline/phases/qa-validation.d.ts +7 -0
- package/dist/pipeline/phases/qa-validation.d.ts.map +1 -0
- package/dist/pipeline/phases/qa-validation.js +50 -0
- package/dist/pipeline/phases/qa-validation.js.map +1 -0
- package/dist/pipeline/phases/recovery-loop.d.ts +7 -0
- package/dist/pipeline/phases/recovery-loop.d.ts.map +1 -0
- package/dist/pipeline/phases/recovery-loop.js +91 -0
- package/dist/pipeline/phases/recovery-loop.js.map +1 -0
- package/dist/pipeline/phases/review.d.ts +8 -0
- package/dist/pipeline/phases/review.d.ts.map +1 -0
- package/dist/pipeline/phases/review.js +127 -0
- package/dist/pipeline/phases/review.js.map +1 -0
- package/dist/pipeline/phases/role-planning.d.ts +7 -0
- package/dist/pipeline/phases/role-planning.d.ts.map +1 -0
- package/dist/pipeline/phases/role-planning.js +75 -0
- package/dist/pipeline/phases/role-planning.js.map +1 -0
- package/dist/pipeline/phases/stuck.d.ts +7 -0
- package/dist/pipeline/phases/stuck.d.ts.map +1 -0
- package/dist/pipeline/phases/stuck.js +51 -0
- package/dist/pipeline/phases/stuck.js.map +1 -0
- package/dist/pipeline/repo-snapshot.d.ts +24 -0
- package/dist/pipeline/repo-snapshot.d.ts.map +1 -0
- package/dist/pipeline/repo-snapshot.js +343 -0
- package/dist/pipeline/repo-snapshot.js.map +1 -0
- package/dist/pipeline/role-execution-adapter.d.ts +59 -0
- package/dist/pipeline/role-execution-adapter.d.ts.map +1 -0
- package/dist/pipeline/role-execution-adapter.js +159 -0
- package/dist/pipeline/role-execution-adapter.js.map +1 -0
- package/dist/pipeline/skill-loader.d.ts +34 -0
- package/dist/pipeline/skill-loader.d.ts.map +1 -0
- package/dist/pipeline/skill-loader.js +156 -0
- package/dist/pipeline/skill-loader.js.map +1 -0
- package/dist/pipeline/skills/defaults.d.ts +16 -0
- package/dist/pipeline/skills/defaults.d.ts.map +1 -0
- package/dist/pipeline/skills/defaults.js +189 -0
- package/dist/pipeline/skills/defaults.js.map +1 -0
- package/dist/pipeline/type-defs/artifacts.d.ts +202 -0
- package/dist/pipeline/type-defs/artifacts.d.ts.map +1 -0
- package/dist/pipeline/type-defs/artifacts.js +66 -0
- package/dist/pipeline/type-defs/artifacts.js.map +1 -0
- package/dist/pipeline/type-defs/audit.d.ts +256 -0
- package/dist/pipeline/type-defs/audit.d.ts.map +1 -0
- package/dist/pipeline/type-defs/audit.js +54 -0
- package/dist/pipeline/type-defs/audit.js.map +1 -0
- package/dist/pipeline/type-defs/checks.d.ts +81 -0
- package/dist/pipeline/type-defs/checks.d.ts.map +1 -0
- package/dist/pipeline/type-defs/checks.js +38 -0
- package/dist/pipeline/type-defs/checks.js.map +1 -0
- package/dist/pipeline/type-defs/enums.d.ts +43 -0
- package/dist/pipeline/type-defs/enums.d.ts.map +1 -0
- package/dist/pipeline/type-defs/enums.js +55 -0
- package/dist/pipeline/type-defs/enums.js.map +1 -0
- package/dist/pipeline/type-defs/index.d.ts +12 -0
- package/dist/pipeline/type-defs/index.d.ts.map +1 -0
- package/dist/pipeline/type-defs/index.js +12 -0
- package/dist/pipeline/type-defs/index.js.map +1 -0
- package/dist/pipeline/type-defs/packets.d.ts +806 -0
- package/dist/pipeline/type-defs/packets.d.ts.map +1 -0
- package/dist/pipeline/type-defs/packets.js +109 -0
- package/dist/pipeline/type-defs/packets.js.map +1 -0
- package/dist/pipeline/type-defs/snapshot.d.ts +52 -0
- package/dist/pipeline/type-defs/snapshot.d.ts.map +1 -0
- package/dist/pipeline/type-defs/snapshot.js +35 -0
- package/dist/pipeline/type-defs/snapshot.js.map +1 -0
- package/dist/pipeline/type-defs/state.d.ts +449 -0
- package/dist/pipeline/type-defs/state.d.ts.map +1 -0
- package/dist/pipeline/type-defs/state.js +88 -0
- package/dist/pipeline/type-defs/state.js.map +1 -0
- package/dist/pipeline/types.d.ts +16 -0
- package/dist/pipeline/types.d.ts.map +1 -0
- package/dist/pipeline/types.js +16 -0
- package/dist/pipeline/types.js.map +1 -0
- package/dist/types/audit.d.ts +6 -6
- package/dist/workflow/index.d.ts.map +1 -1
- package/dist/workflow/index.js +48 -0
- package/dist/workflow/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/ARBITRATOR.md +137 -0
- package/skills/ARCHITECT.md +167 -0
- package/skills/AUDITOR.md +128 -0
- package/skills/AUDIT_REPORT_SCHEMA.md +20 -0
- package/skills/BACKEND_PROGRAMMER.md +95 -0
- package/skills/CONSENSUS_PACKET_SCHEMA.md +166 -0
- package/skills/DB_EXPERT.md +106 -0
- package/skills/DEBUGGER.md +286 -0
- package/skills/DISPATCHER.md +157 -0
- package/skills/FRONTEND_PROGRAMMER.md +84 -0
- package/skills/JOURNALIST.md +247 -0
- package/skills/MARKETING_EXPERT.md +23 -0
- package/skills/PHASE_GATE_ENGINE_SPEC.md +171 -0
- package/skills/PLAN_PACKET_SCHEMA.md +222 -0
- package/skills/POPEYE_CONSTITUTION.md +177 -0
- package/skills/POPEYE_FULL_AUTONOMY_PIPELINE.md +537 -0
- package/skills/PRODUCTION_READINESS_SCHEMA.md +19 -0
- package/skills/QA_TESTER.md +40 -0
- package/skills/RCA_PACKET_SCHEMA.md +22 -0
- package/skills/RELEASE_MANAGER.md +60 -0
- package/skills/REVIEWER.md +133 -0
- package/skills/SOCIAL_EXPERT.md +22 -0
- package/skills/UI_UX_SPECIALIST.md +22 -0
- package/skills/WEBSITE_PROGRAMMER.md +37 -0
- package/src/cli/commands/debug-context.ts +265 -0
- package/src/cli/commands/debug-prompts.ts +91 -0
- package/src/cli/commands/debug.ts +662 -0
- package/src/cli/commands/index.ts +1 -0
- package/src/cli/index.ts +2 -0
- package/src/cli/interactive.ts +27 -0
- package/src/generators/all.ts +2 -0
- package/src/generators/templates/database-docker.ts +10 -0
- package/src/generators/templates/fullstack.ts +6 -2
- package/src/pipeline/artifact-manager.ts +339 -0
- package/src/pipeline/artifact-validators.ts +224 -0
- package/src/pipeline/change-request.ts +119 -0
- package/src/pipeline/check-runner.ts +504 -0
- package/src/pipeline/command-resolver.ts +168 -0
- package/src/pipeline/consensus/consensus-runner.ts +317 -0
- package/src/pipeline/constitution.ts +109 -0
- package/src/pipeline/gate-engine.ts +347 -0
- package/src/pipeline/index.ts +82 -0
- package/src/pipeline/migration.ts +91 -0
- package/src/pipeline/orchestrator.ts +314 -0
- package/src/pipeline/packets/audit-report-builder.ts +47 -0
- package/src/pipeline/packets/consensus-packet-builder.ts +112 -0
- package/src/pipeline/packets/index.ts +15 -0
- package/src/pipeline/packets/plan-packet-builder.ts +52 -0
- package/src/pipeline/packets/rca-packet-builder.ts +38 -0
- package/src/pipeline/phases/architecture.ts +73 -0
- package/src/pipeline/phases/audit.ts +193 -0
- package/src/pipeline/phases/consensus-architecture.ts +104 -0
- package/src/pipeline/phases/consensus-master-plan.ts +100 -0
- package/src/pipeline/phases/consensus-role-plans.ts +105 -0
- package/src/pipeline/phases/done.ts +68 -0
- package/src/pipeline/phases/implementation.ts +48 -0
- package/src/pipeline/phases/index.ts +21 -0
- package/src/pipeline/phases/intake.ts +54 -0
- package/src/pipeline/phases/phase-context.ts +86 -0
- package/src/pipeline/phases/production-gate.ts +113 -0
- package/src/pipeline/phases/qa-validation.ts +63 -0
- package/src/pipeline/phases/recovery-loop.ts +118 -0
- package/src/pipeline/phases/review.ts +149 -0
- package/src/pipeline/phases/role-planning.ts +92 -0
- package/src/pipeline/phases/stuck.ts +62 -0
- package/src/pipeline/repo-snapshot.ts +395 -0
- package/src/pipeline/role-execution-adapter.ts +238 -0
- package/src/pipeline/skill-loader.ts +192 -0
- package/src/pipeline/skills/defaults.ts +215 -0
- package/src/pipeline/type-defs/artifacts.ts +81 -0
- package/src/pipeline/type-defs/audit.ts +67 -0
- package/src/pipeline/type-defs/checks.ts +47 -0
- package/src/pipeline/type-defs/enums.ts +62 -0
- package/src/pipeline/type-defs/index.ts +12 -0
- package/src/pipeline/type-defs/packets.ts +131 -0
- package/src/pipeline/type-defs/snapshot.ts +55 -0
- package/src/pipeline/type-defs/state.ts +165 -0
- package/src/pipeline/types.ts +16 -0
- package/src/workflow/index.ts +48 -0
- package/tests/cli/commands/debug.test.ts +376 -0
- package/tests/pipeline/artifact-manager.test.ts +183 -0
- package/tests/pipeline/artifact-validators.test.ts +207 -0
- package/tests/pipeline/change-request.test.ts +180 -0
- package/tests/pipeline/check-runner.test.ts +157 -0
- package/tests/pipeline/command-resolver.test.ts +159 -0
- package/tests/pipeline/consensus-runner.test.ts +206 -0
- package/tests/pipeline/consensus-scoring.test.ts +163 -0
- package/tests/pipeline/constitution.test.ts +122 -0
- package/tests/pipeline/gate-engine.test.ts +195 -0
- package/tests/pipeline/migration.test.ts +133 -0
- package/tests/pipeline/orchestrator.test.ts +614 -0
- package/tests/pipeline/packets/builders.test.ts +347 -0
- package/tests/pipeline/repo-snapshot.test.ts +189 -0
- package/tests/pipeline/role-execution-adapter.test.ts +299 -0
- package/tests/pipeline/skill-loader.test.ts +186 -0
- package/tests/pipeline/start-env-checks.test.ts +123 -0
- package/tests/pipeline/types.test.ts +156 -0
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Packet Builders tests — all 4 builders: auto-compute, version increment.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, it, expect } from 'vitest';
|
|
6
|
+
import {
|
|
7
|
+
buildPlanPacket,
|
|
8
|
+
buildConsensusPacket,
|
|
9
|
+
buildRCAPacket,
|
|
10
|
+
buildAuditReport,
|
|
11
|
+
} from '../../../src/pipeline/packets/index.js';
|
|
12
|
+
import type { ArtifactRef, ReviewerVote, AuditFinding } from '../../../src/pipeline/types.js';
|
|
13
|
+
|
|
14
|
+
function makeRef(type: string = 'master_plan'): ArtifactRef {
|
|
15
|
+
return {
|
|
16
|
+
artifact_id: `ref-${type}`,
|
|
17
|
+
path: `docs/${type}.md`,
|
|
18
|
+
sha256: 'abc123',
|
|
19
|
+
version: 1,
|
|
20
|
+
type: type as ArtifactRef['type'],
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function makeVote(
|
|
25
|
+
vote: 'APPROVE' | 'REJECT' | 'CONDITIONAL',
|
|
26
|
+
reviewerId: string = 'reviewer-1',
|
|
27
|
+
): ReviewerVote {
|
|
28
|
+
return {
|
|
29
|
+
reviewer_id: reviewerId,
|
|
30
|
+
provider: 'openai',
|
|
31
|
+
model: 'gpt-4o',
|
|
32
|
+
temperature: 0.3,
|
|
33
|
+
prompt_hash: 'hash123',
|
|
34
|
+
vote,
|
|
35
|
+
confidence: 0.9,
|
|
36
|
+
blocking_issues: vote === 'REJECT' ? ['issue'] : [],
|
|
37
|
+
suggestions: [],
|
|
38
|
+
evidence_refs: [],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
describe('PacketBuilders', () => {
|
|
43
|
+
describe('buildPlanPacket', () => {
|
|
44
|
+
it('should create a valid plan packet', () => {
|
|
45
|
+
const packet = buildPlanPacket({
|
|
46
|
+
phase: 'INTAKE',
|
|
47
|
+
submittedBy: 'DISPATCHER',
|
|
48
|
+
masterPlanRef: makeRef('master_plan'),
|
|
49
|
+
constitutionRef: makeRef('constitution'),
|
|
50
|
+
repoSnapshotRef: makeRef('repo_snapshot'),
|
|
51
|
+
proposedArtifacts: [makeRef('architecture')],
|
|
52
|
+
acceptanceCriteria: ['All endpoints documented'],
|
|
53
|
+
dependencies: [],
|
|
54
|
+
constraints: [],
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
expect(packet.metadata.packet_id).toBeDefined();
|
|
58
|
+
expect(packet.metadata.timestamp).toBeDefined();
|
|
59
|
+
expect(packet.metadata.phase).toBe('INTAKE');
|
|
60
|
+
expect(packet.metadata.submitted_by).toBe('DISPATCHER');
|
|
61
|
+
expect(packet.metadata.version).toBe(1);
|
|
62
|
+
expect(packet.references.master_plan.artifact_id).toBe('ref-master_plan');
|
|
63
|
+
expect(packet.proposed_artifacts).toHaveLength(1);
|
|
64
|
+
expect(packet.acceptance_criteria).toHaveLength(1);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('should accept version override', () => {
|
|
68
|
+
const packet = buildPlanPacket({
|
|
69
|
+
phase: 'ARCHITECTURE',
|
|
70
|
+
submittedBy: 'ARCHITECT',
|
|
71
|
+
masterPlanRef: makeRef(),
|
|
72
|
+
constitutionRef: makeRef(),
|
|
73
|
+
repoSnapshotRef: makeRef('repo_snapshot'),
|
|
74
|
+
proposedArtifacts: [],
|
|
75
|
+
acceptanceCriteria: [],
|
|
76
|
+
dependencies: [],
|
|
77
|
+
constraints: [],
|
|
78
|
+
version: 3,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
expect(packet.metadata.version).toBe(3);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('should include open questions when provided', () => {
|
|
85
|
+
const packet = buildPlanPacket({
|
|
86
|
+
phase: 'INTAKE',
|
|
87
|
+
submittedBy: 'DISPATCHER',
|
|
88
|
+
masterPlanRef: makeRef(),
|
|
89
|
+
constitutionRef: makeRef(),
|
|
90
|
+
repoSnapshotRef: makeRef('repo_snapshot'),
|
|
91
|
+
proposedArtifacts: [],
|
|
92
|
+
acceptanceCriteria: [],
|
|
93
|
+
dependencies: [],
|
|
94
|
+
constraints: [],
|
|
95
|
+
openQuestions: ['Which database?', 'Auth strategy?'],
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
expect(packet.open_questions).toHaveLength(2);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe('buildConsensusPacket', () => {
|
|
103
|
+
it('should auto-compute APPROVED when all approve', () => {
|
|
104
|
+
const packet = buildConsensusPacket({
|
|
105
|
+
planPacketRef: makeRef(),
|
|
106
|
+
votes: [makeVote('APPROVE', 'r1'), makeVote('APPROVE', 'r2')],
|
|
107
|
+
rules: { threshold: 0.95, quorum: 2, min_reviewers: 2 },
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
expect(packet.consensus_result.approved).toBe(true);
|
|
111
|
+
expect(packet.consensus_result.score).toBe(1.0);
|
|
112
|
+
expect(packet.consensus_result.participating_reviewers).toBe(2);
|
|
113
|
+
expect(packet.final_status).toBe('APPROVED');
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('should auto-compute REJECTED when below threshold', () => {
|
|
117
|
+
const packet = buildConsensusPacket({
|
|
118
|
+
planPacketRef: makeRef(),
|
|
119
|
+
votes: [makeVote('APPROVE', 'r1'), makeVote('REJECT', 'r2')],
|
|
120
|
+
rules: { threshold: 0.95, quorum: 2, min_reviewers: 2 },
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
expect(packet.consensus_result.approved).toBe(false);
|
|
124
|
+
expect(packet.consensus_result.score).toBe(0.5);
|
|
125
|
+
expect(packet.final_status).toBe('REJECTED');
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('should set ARBITRATED when arbitrator present', () => {
|
|
129
|
+
const packet = buildConsensusPacket({
|
|
130
|
+
planPacketRef: makeRef(),
|
|
131
|
+
votes: [makeVote('APPROVE', 'r1'), makeVote('REJECT', 'r2')],
|
|
132
|
+
rules: { threshold: 0.95, quorum: 2, min_reviewers: 2 },
|
|
133
|
+
arbitratorResult: { decision: 'Approve with changes' },
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
expect(packet.final_status).toBe('ARBITRATED');
|
|
137
|
+
expect(packet.arbitrator_result?.decision).toBe('Approve with changes');
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('should reject when quorum not met', () => {
|
|
141
|
+
const packet = buildConsensusPacket({
|
|
142
|
+
planPacketRef: makeRef(),
|
|
143
|
+
votes: [makeVote('APPROVE', 'r1')],
|
|
144
|
+
rules: { threshold: 0.95, quorum: 2, min_reviewers: 2 },
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
// Score is 1.0 but quorum=2, only 1 voter
|
|
148
|
+
expect(packet.consensus_result.approved).toBe(false);
|
|
149
|
+
expect(packet.final_status).toBe('REJECTED');
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('should handle zero votes', () => {
|
|
153
|
+
const packet = buildConsensusPacket({
|
|
154
|
+
planPacketRef: makeRef(),
|
|
155
|
+
votes: [],
|
|
156
|
+
rules: { threshold: 0.95, quorum: 2, min_reviewers: 2 },
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
expect(packet.consensus_result.score).toBe(0);
|
|
160
|
+
expect(packet.consensus_result.approved).toBe(false);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it('should include weighted_score in consensus result (v1.1)', () => {
|
|
164
|
+
const packet = buildConsensusPacket({
|
|
165
|
+
planPacketRef: makeRef(),
|
|
166
|
+
votes: [makeVote('APPROVE', 'r1'), makeVote('APPROVE', 'r2')],
|
|
167
|
+
rules: { threshold: 0.5, quorum: 1, min_reviewers: 1 },
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
expect(packet.consensus_result.weighted_score).toBeDefined();
|
|
171
|
+
expect(typeof packet.consensus_result.weighted_score).toBe('number');
|
|
172
|
+
expect(packet.consensus_result.weighted_score).toBe(1.0);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('should have weighted_score < 1 for mixed votes (v1.1)', () => {
|
|
176
|
+
const packet = buildConsensusPacket({
|
|
177
|
+
planPacketRef: makeRef(),
|
|
178
|
+
votes: [makeVote('APPROVE', 'r1'), makeVote('REJECT', 'r2')],
|
|
179
|
+
rules: { threshold: 0.5, quorum: 1, min_reviewers: 1 },
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// weighted_score should be 0 since REJECT vote has blocking_issues
|
|
183
|
+
expect(packet.consensus_result.weighted_score).toBe(0);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it('should link to plan packet', () => {
|
|
187
|
+
const planRef = makeRef();
|
|
188
|
+
const packet = buildConsensusPacket({
|
|
189
|
+
planPacketRef: planRef,
|
|
190
|
+
votes: [makeVote('APPROVE')],
|
|
191
|
+
rules: { threshold: 0.5, quorum: 1, min_reviewers: 1 },
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
expect(packet.metadata.plan_packet_id).toBe(planRef.artifact_id);
|
|
195
|
+
expect(packet.plan_packet_reference).toBe(planRef);
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
describe('buildRCAPacket', () => {
|
|
200
|
+
it('should create RCA with all fields', () => {
|
|
201
|
+
const rca = buildRCAPacket({
|
|
202
|
+
incidentSummary: 'Tests failing on CI',
|
|
203
|
+
symptoms: ['test timeout', 'flaky assertions'],
|
|
204
|
+
rootCause: 'Race condition in async setup',
|
|
205
|
+
responsibleLayer: 'test infrastructure',
|
|
206
|
+
originPhase: 'QA_VALIDATION',
|
|
207
|
+
governanceGap: 'No test isolation check',
|
|
208
|
+
correctiveActions: ['Add mutex to shared resource'],
|
|
209
|
+
prevention: 'Enable parallel test isolation',
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
expect(rca.rca_id).toBeDefined();
|
|
213
|
+
expect(rca.timestamp).toBeDefined();
|
|
214
|
+
expect(rca.incident_summary).toBe('Tests failing on CI');
|
|
215
|
+
expect(rca.symptoms).toHaveLength(2);
|
|
216
|
+
expect(rca.root_cause).toContain('Race condition');
|
|
217
|
+
expect(rca.origin_phase).toBe('QA_VALIDATION');
|
|
218
|
+
expect(rca.corrective_actions).toHaveLength(1);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it('should include rewind target when provided', () => {
|
|
222
|
+
const rca = buildRCAPacket({
|
|
223
|
+
incidentSummary: 'Architecture mismatch',
|
|
224
|
+
symptoms: ['contract violation'],
|
|
225
|
+
rootCause: 'Wrong API design',
|
|
226
|
+
responsibleLayer: 'architecture',
|
|
227
|
+
originPhase: 'IMPLEMENTATION',
|
|
228
|
+
governanceGap: 'No contract validation',
|
|
229
|
+
correctiveActions: ['Redesign API'],
|
|
230
|
+
prevention: 'Add contract tests',
|
|
231
|
+
rewindTo: 'ARCHITECTURE',
|
|
232
|
+
requiresConsensusOn: ['ARCHITECTURE'],
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
expect(rca.requires_phase_rewind_to).toBe('ARCHITECTURE');
|
|
236
|
+
expect(rca.requires_consensus_on).toEqual(['ARCHITECTURE']);
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it('should leave rewind undefined when not needed', () => {
|
|
240
|
+
const rca = buildRCAPacket({
|
|
241
|
+
incidentSummary: 'Minor fix',
|
|
242
|
+
symptoms: ['typo'],
|
|
243
|
+
rootCause: 'Spelling error',
|
|
244
|
+
responsibleLayer: 'documentation',
|
|
245
|
+
originPhase: 'REVIEW',
|
|
246
|
+
governanceGap: 'None',
|
|
247
|
+
correctiveActions: ['Fix typo'],
|
|
248
|
+
prevention: 'Add spell check',
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
expect(rca.requires_phase_rewind_to).toBeUndefined();
|
|
252
|
+
expect(rca.requires_consensus_on).toBeUndefined();
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
describe('buildAuditReport', () => {
|
|
257
|
+
it('should PASS with no findings', () => {
|
|
258
|
+
const report = buildAuditReport({
|
|
259
|
+
repoSnapshot: makeRef('repo_snapshot'),
|
|
260
|
+
findings: [],
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
expect(report.audit_id).toBeDefined();
|
|
264
|
+
expect(report.overall_status).toBe('PASS');
|
|
265
|
+
expect(report.system_risk_score).toBe(0);
|
|
266
|
+
expect(report.recovery_required).toBe(false);
|
|
267
|
+
expect(report.findings).toHaveLength(0);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
it('should FAIL with blocking findings', () => {
|
|
271
|
+
const finding: AuditFinding = {
|
|
272
|
+
id: 'f1',
|
|
273
|
+
severity: 'P0',
|
|
274
|
+
category: 'security',
|
|
275
|
+
description: 'SQL injection in login',
|
|
276
|
+
evidence: [],
|
|
277
|
+
blocking: true,
|
|
278
|
+
suggested_owner: 'BACKEND_PROGRAMMER',
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
const report = buildAuditReport({
|
|
282
|
+
repoSnapshot: makeRef('repo_snapshot'),
|
|
283
|
+
findings: [finding],
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
expect(report.overall_status).toBe('FAIL');
|
|
287
|
+
expect(report.system_risk_score).toBe(40); // P0 = 40
|
|
288
|
+
expect(report.recovery_required).toBe(true);
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
it('should PASS with non-blocking findings', () => {
|
|
292
|
+
const finding: AuditFinding = {
|
|
293
|
+
id: 'f1',
|
|
294
|
+
severity: 'P3',
|
|
295
|
+
category: 'config',
|
|
296
|
+
description: 'Missing optional config',
|
|
297
|
+
evidence: [],
|
|
298
|
+
blocking: false,
|
|
299
|
+
suggested_owner: 'BACKEND_PROGRAMMER',
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
const report = buildAuditReport({
|
|
303
|
+
repoSnapshot: makeRef('repo_snapshot'),
|
|
304
|
+
findings: [finding],
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
expect(report.overall_status).toBe('PASS');
|
|
308
|
+
expect(report.system_risk_score).toBe(2); // P3 = 2
|
|
309
|
+
expect(report.recovery_required).toBe(false);
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
it('should compute cumulative risk score', () => {
|
|
313
|
+
const findings: AuditFinding[] = [
|
|
314
|
+
{ id: 'f1', severity: 'P0', category: 'security', description: 'A', evidence: [], blocking: true, suggested_owner: 'DEBUGGER' },
|
|
315
|
+
{ id: 'f2', severity: 'P1', category: 'tests', description: 'B', evidence: [], blocking: true, suggested_owner: 'QA_TESTER' },
|
|
316
|
+
{ id: 'f3', severity: 'P2', category: 'config', description: 'C', evidence: [], blocking: false, suggested_owner: 'BACKEND_PROGRAMMER' },
|
|
317
|
+
];
|
|
318
|
+
|
|
319
|
+
const report = buildAuditReport({
|
|
320
|
+
repoSnapshot: makeRef('repo_snapshot'),
|
|
321
|
+
findings,
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
expect(report.system_risk_score).toBe(68); // 40 + 20 + 8
|
|
325
|
+
expect(report.recovery_required).toBe(true);
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
it('should cap risk score at 100', () => {
|
|
329
|
+
const findings: AuditFinding[] = Array.from({ length: 5 }, (_, i) => ({
|
|
330
|
+
id: `f${i}`,
|
|
331
|
+
severity: 'P0' as const,
|
|
332
|
+
category: 'security' as const,
|
|
333
|
+
description: `Finding ${i}`,
|
|
334
|
+
evidence: [],
|
|
335
|
+
blocking: true,
|
|
336
|
+
suggested_owner: 'DEBUGGER' as const,
|
|
337
|
+
}));
|
|
338
|
+
|
|
339
|
+
const report = buildAuditReport({
|
|
340
|
+
repoSnapshot: makeRef('repo_snapshot'),
|
|
341
|
+
findings,
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
expect(report.system_risk_score).toBe(100); // 5 * 40 = 200, capped at 100
|
|
345
|
+
});
|
|
346
|
+
});
|
|
347
|
+
});
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repo Snapshot tests — config detection, tree summary, diff.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
6
|
+
import { mkdirSync, rmSync, writeFileSync, existsSync } from 'node:fs';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { generateRepoSnapshot, diffSnapshots } from '../../src/pipeline/repo-snapshot.js';
|
|
9
|
+
|
|
10
|
+
const TEST_DIR = join(process.cwd(), '.test-repo-snapshot');
|
|
11
|
+
|
|
12
|
+
describe('RepoSnapshot', () => {
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
if (existsSync(TEST_DIR)) rmSync(TEST_DIR, { recursive: true });
|
|
15
|
+
mkdirSync(TEST_DIR, { recursive: true });
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
if (existsSync(TEST_DIR)) rmSync(TEST_DIR, { recursive: true });
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe('generateRepoSnapshot', () => {
|
|
23
|
+
it('should generate snapshot with basic fields', async () => {
|
|
24
|
+
writeFileSync(join(TEST_DIR, 'index.ts'), 'console.log("hello");\n');
|
|
25
|
+
const snapshot = await generateRepoSnapshot(TEST_DIR);
|
|
26
|
+
|
|
27
|
+
expect(snapshot.snapshot_id).toBeDefined();
|
|
28
|
+
expect(snapshot.snapshot_id.length).toBe(16);
|
|
29
|
+
expect(snapshot.timestamp).toBeDefined();
|
|
30
|
+
expect(snapshot.tree_summary).toBeDefined();
|
|
31
|
+
expect(Array.isArray(snapshot.config_files)).toBe(true);
|
|
32
|
+
expect(Array.isArray(snapshot.languages_detected)).toBe(true);
|
|
33
|
+
expect(typeof snapshot.total_files).toBe('number');
|
|
34
|
+
expect(typeof snapshot.total_lines).toBe('number');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should detect package.json config', async () => {
|
|
38
|
+
const pkg = { name: 'test', version: '1.0.0', scripts: { test: 'vitest' } };
|
|
39
|
+
writeFileSync(join(TEST_DIR, 'package.json'), JSON.stringify(pkg, null, 2));
|
|
40
|
+
|
|
41
|
+
const snapshot = await generateRepoSnapshot(TEST_DIR);
|
|
42
|
+
const pkgConfig = snapshot.config_files.find((c) => c.type === 'package.json');
|
|
43
|
+
|
|
44
|
+
expect(pkgConfig).toBeDefined();
|
|
45
|
+
expect(pkgConfig!.content_hash).toBeDefined();
|
|
46
|
+
expect(pkgConfig!.key_fields).toHaveProperty('name', 'test');
|
|
47
|
+
expect(pkgConfig!.key_fields).toHaveProperty('scripts');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('should detect languages from file extensions', async () => {
|
|
51
|
+
mkdirSync(join(TEST_DIR, 'src'), { recursive: true });
|
|
52
|
+
writeFileSync(join(TEST_DIR, 'src', 'app.ts'), 'export const x = 1;\n');
|
|
53
|
+
writeFileSync(join(TEST_DIR, 'src', 'util.py'), 'x = 1\n');
|
|
54
|
+
|
|
55
|
+
const snapshot = await generateRepoSnapshot(TEST_DIR);
|
|
56
|
+
expect(snapshot.languages_detected).toContain('typescript');
|
|
57
|
+
expect(snapshot.languages_detected).toContain('python');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('should detect package manager from lock files', async () => {
|
|
61
|
+
writeFileSync(join(TEST_DIR, 'package.json'), '{}');
|
|
62
|
+
writeFileSync(join(TEST_DIR, 'pnpm-lock.yaml'), '');
|
|
63
|
+
|
|
64
|
+
const snapshot = await generateRepoSnapshot(TEST_DIR);
|
|
65
|
+
expect(snapshot.package_manager).toBe('pnpm');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('should detect test framework from scripts', async () => {
|
|
69
|
+
const pkg = { name: 'test', scripts: { test: 'vitest run' } };
|
|
70
|
+
writeFileSync(join(TEST_DIR, 'package.json'), JSON.stringify(pkg));
|
|
71
|
+
|
|
72
|
+
const snapshot = await generateRepoSnapshot(TEST_DIR);
|
|
73
|
+
expect(snapshot.test_framework).toBe('vitest');
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('should detect build tool from scripts', async () => {
|
|
77
|
+
const pkg = { name: 'test', scripts: { build: 'tsc -b' } };
|
|
78
|
+
writeFileSync(join(TEST_DIR, 'package.json'), JSON.stringify(pkg));
|
|
79
|
+
|
|
80
|
+
const snapshot = await generateRepoSnapshot(TEST_DIR);
|
|
81
|
+
expect(snapshot.build_tool).toBe('tsc');
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('should detect env files', async () => {
|
|
85
|
+
writeFileSync(join(TEST_DIR, '.env'), 'KEY=val');
|
|
86
|
+
writeFileSync(join(TEST_DIR, '.env.example'), 'KEY=');
|
|
87
|
+
|
|
88
|
+
const snapshot = await generateRepoSnapshot(TEST_DIR);
|
|
89
|
+
expect(snapshot.env_files).toContain('.env');
|
|
90
|
+
expect(snapshot.env_files).toContain('.env.example');
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('should detect migrations presence', async () => {
|
|
94
|
+
mkdirSync(join(TEST_DIR, 'migrations'), { recursive: true });
|
|
95
|
+
|
|
96
|
+
const snapshot = await generateRepoSnapshot(TEST_DIR);
|
|
97
|
+
expect(snapshot.migrations_present).toBe(true);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('should count files and lines', async () => {
|
|
101
|
+
mkdirSync(join(TEST_DIR, 'src'), { recursive: true });
|
|
102
|
+
writeFileSync(join(TEST_DIR, 'src', 'a.ts'), 'line1\nline2\nline3\n');
|
|
103
|
+
writeFileSync(join(TEST_DIR, 'src', 'b.ts'), 'one\ntwo\n');
|
|
104
|
+
|
|
105
|
+
const snapshot = await generateRepoSnapshot(TEST_DIR);
|
|
106
|
+
expect(snapshot.total_files).toBe(2);
|
|
107
|
+
expect(snapshot.total_lines).toBeGreaterThan(0);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('should exclude node_modules from scan', async () => {
|
|
111
|
+
mkdirSync(join(TEST_DIR, 'node_modules', 'dep'), { recursive: true });
|
|
112
|
+
writeFileSync(join(TEST_DIR, 'node_modules', 'dep', 'index.js'), 'x');
|
|
113
|
+
mkdirSync(join(TEST_DIR, 'src'), { recursive: true });
|
|
114
|
+
writeFileSync(join(TEST_DIR, 'src', 'app.ts'), 'const x = 1;\n');
|
|
115
|
+
|
|
116
|
+
const snapshot = await generateRepoSnapshot(TEST_DIR);
|
|
117
|
+
expect(snapshot.total_files).toBe(1); // Only src/app.ts
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
describe('diffSnapshots', () => {
|
|
122
|
+
it('should detect no changes for identical snapshots', async () => {
|
|
123
|
+
writeFileSync(join(TEST_DIR, 'index.ts'), 'x');
|
|
124
|
+
const snapshot = await generateRepoSnapshot(TEST_DIR);
|
|
125
|
+
const diff = diffSnapshots(snapshot, snapshot);
|
|
126
|
+
|
|
127
|
+
expect(diff.has_changes).toBe(false);
|
|
128
|
+
expect(diff.files_delta).toBe(0);
|
|
129
|
+
expect(diff.lines_delta).toBe(0);
|
|
130
|
+
expect(diff.added_configs).toHaveLength(0);
|
|
131
|
+
expect(diff.removed_configs).toHaveLength(0);
|
|
132
|
+
expect(diff.changed_configs).toHaveLength(0);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('should detect added config files', () => {
|
|
136
|
+
const before = {
|
|
137
|
+
snapshot_id: 'a', timestamp: '', tree_summary: '',
|
|
138
|
+
config_files: [], languages_detected: [],
|
|
139
|
+
scripts: {}, env_files: [],
|
|
140
|
+
migrations_present: false, ports_entrypoints: [],
|
|
141
|
+
total_files: 10, total_lines: 100,
|
|
142
|
+
};
|
|
143
|
+
const after = {
|
|
144
|
+
...before,
|
|
145
|
+
snapshot_id: 'b',
|
|
146
|
+
config_files: [{ path: 'package.json', type: 'package.json', content_hash: 'abc', key_fields: {} }],
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const diff = diffSnapshots(before, after);
|
|
150
|
+
expect(diff.added_configs).toContain('package.json');
|
|
151
|
+
expect(diff.has_changes).toBe(true);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('should detect changed config files', () => {
|
|
155
|
+
const before = {
|
|
156
|
+
snapshot_id: 'a', timestamp: '', tree_summary: '',
|
|
157
|
+
config_files: [{ path: 'package.json', type: 'package.json', content_hash: 'old', key_fields: {} }],
|
|
158
|
+
languages_detected: [], scripts: {},
|
|
159
|
+
env_files: [], migrations_present: false,
|
|
160
|
+
ports_entrypoints: [], total_files: 10, total_lines: 100,
|
|
161
|
+
};
|
|
162
|
+
const after = {
|
|
163
|
+
...before,
|
|
164
|
+
snapshot_id: 'b',
|
|
165
|
+
config_files: [{ path: 'package.json', type: 'package.json', content_hash: 'new', key_fields: {} }],
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const diff = diffSnapshots(before, after);
|
|
169
|
+
expect(diff.changed_configs).toContain('package.json');
|
|
170
|
+
expect(diff.has_changes).toBe(true);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('should detect file count delta', () => {
|
|
174
|
+
const before = {
|
|
175
|
+
snapshot_id: 'a', timestamp: '', tree_summary: '',
|
|
176
|
+
config_files: [], languages_detected: [],
|
|
177
|
+
scripts: {}, env_files: [],
|
|
178
|
+
migrations_present: false, ports_entrypoints: [],
|
|
179
|
+
total_files: 10, total_lines: 100,
|
|
180
|
+
};
|
|
181
|
+
const after = { ...before, snapshot_id: 'b', total_files: 15, total_lines: 200 };
|
|
182
|
+
|
|
183
|
+
const diff = diffSnapshots(before, after);
|
|
184
|
+
expect(diff.files_delta).toBe(5);
|
|
185
|
+
expect(diff.lines_delta).toBe(100);
|
|
186
|
+
expect(diff.has_changes).toBe(true);
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
});
|