@lwelliott/cortex-cli 1.0.7 → 1.0.8
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 +7 -5
- package/dist/cli/project-resolver.js +1 -1
- package/dist/cli/project-resolver.js.map +1 -1
- package/dist/config/config.d.ts +8 -2
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +25 -9
- package/dist/config/config.js.map +1 -1
- package/dist/config/paths.d.ts +13 -0
- package/dist/config/paths.d.ts.map +1 -0
- package/dist/config/paths.js +76 -0
- package/dist/config/paths.js.map +1 -0
- package/dist/config/registry.d.ts +10 -3
- package/dist/config/registry.d.ts.map +1 -1
- package/dist/config/registry.js +49 -13
- package/dist/config/registry.js.map +1 -1
- package/dist/config/resolver.d.ts +6 -9
- package/dist/config/resolver.d.ts.map +1 -1
- package/dist/config/resolver.js +13 -30
- package/dist/config/resolver.js.map +1 -1
- package/dist/models/project.d.ts +3 -3
- package/dist/models/project.d.ts.map +1 -1
- package/dist/services/project.js +4 -4
- package/dist/services/project.js.map +1 -1
- package/dist/utils/errors.d.ts +5 -4
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +13 -13
- package/dist/utils/errors.js.map +1 -1
- package/package.json +1 -1
- package/dist/cli/entity.d.ts +0 -3
- package/dist/cli/entity.d.ts.map +0 -1
- package/dist/cli/entity.js +0 -135
- package/dist/cli/entity.js.map +0 -1
- package/dist/cli/schema.d.ts +0 -3
- package/dist/cli/schema.d.ts.map +0 -1
- package/dist/cli/schema.js +0 -94
- package/dist/cli/schema.js.map +0 -1
- package/dist/db/builtin-schema-constants.d.ts +0 -109
- package/dist/db/builtin-schema-constants.d.ts.map +0 -1
- package/dist/db/builtin-schema-constants.js +0 -32
- package/dist/db/builtin-schema-constants.js.map +0 -1
- package/dist/models/entity-model.d.ts +0 -30
- package/dist/models/entity-model.d.ts.map +0 -1
- package/dist/models/entity-model.js +0 -99
- package/dist/models/entity-model.js.map +0 -1
- package/dist/services/audit-checks/mapping-check.d.ts +0 -4
- package/dist/services/audit-checks/mapping-check.d.ts.map +0 -1
- package/dist/services/audit-checks/mapping-check.js +0 -74
- package/dist/services/audit-checks/mapping-check.js.map +0 -1
- package/dist/services/audit-checks/orphan-entities-check.d.ts +0 -4
- package/dist/services/audit-checks/orphan-entities-check.d.ts.map +0 -1
- package/dist/services/audit-checks/orphan-entities-check.js +0 -39
- package/dist/services/audit-checks/orphan-entities-check.js.map +0 -1
- package/dist/services/audit-checks/sprint-consistency-check.d.ts +0 -4
- package/dist/services/audit-checks/sprint-consistency-check.d.ts.map +0 -1
- package/dist/services/audit-checks/sprint-consistency-check.js +0 -80
- package/dist/services/audit-checks/sprint-consistency-check.js.map +0 -1
- package/dist/services/audit-checks/type-mismatch-check.d.ts +0 -4
- package/dist/services/audit-checks/type-mismatch-check.d.ts.map +0 -1
- package/dist/services/audit-checks/type-mismatch-check.js +0 -55
- package/dist/services/audit-checks/type-mismatch-check.js.map +0 -1
- package/dist/services/doc-entity-mapping.d.ts +0 -19
- package/dist/services/doc-entity-mapping.d.ts.map +0 -1
- package/dist/services/doc-entity-mapping.js +0 -35
- package/dist/services/doc-entity-mapping.js.map +0 -1
package/dist/cli/schema.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// CLI subcommands for schema group
|
|
3
|
-
// SAD-0012: Type System Overhaul — Migration Architecture
|
|
4
|
-
// MOD-022: Schema Migration Orchestrator
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createSchemaGroup = createSchemaGroup;
|
|
7
|
-
const commander_1 = require("commander");
|
|
8
|
-
const path_1 = require("path");
|
|
9
|
-
const connection_1 = require("../db/connection");
|
|
10
|
-
const migration_1 = require("../db/migration");
|
|
11
|
-
const project_resolver_1 = require("./project-resolver");
|
|
12
|
-
const format_selector_1 = require("./format-selector");
|
|
13
|
-
const schema_migration_service_1 = require("../services/schema-migration-service");
|
|
14
|
-
function run(fn, optsOrCmd) {
|
|
15
|
-
try {
|
|
16
|
-
const opts = optsOrCmd instanceof commander_1.Command ? optsOrCmd.optsWithGlobals() : optsOrCmd;
|
|
17
|
-
const output = fn(opts);
|
|
18
|
-
if (output)
|
|
19
|
-
console.log(output);
|
|
20
|
-
}
|
|
21
|
-
catch (err) {
|
|
22
|
-
const opts = optsOrCmd instanceof commander_1.Command ? optsOrCmd.optsWithGlobals() : optsOrCmd;
|
|
23
|
-
const format = (0, format_selector_1.selectFormat)({ quiet: opts.quiet, json: opts.json, format: opts.format });
|
|
24
|
-
console.error((0, format_selector_1.formatErrorOutput)(err instanceof Error ? err : new Error(String(err)), format));
|
|
25
|
-
process.exit(1);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function createSchemaGroup() {
|
|
29
|
-
const group = new commander_1.Command('schema').description('Graph schema management and migration');
|
|
30
|
-
// schema migrate — run the 4-phase schema migration
|
|
31
|
-
group.command('migrate')
|
|
32
|
-
.description('Run schema migration (MOD-022: Type System Overhaul)')
|
|
33
|
-
.option('--phase <phase>', 'Run only a specific phase: entity-types, relation-types, doc-types, schema-sync')
|
|
34
|
-
.action((_opts, _cmd) => {
|
|
35
|
-
run((opts) => {
|
|
36
|
-
const format = (0, format_selector_1.selectFormat)(opts);
|
|
37
|
-
const resolved = (0, project_resolver_1.resolveFromCLI)(opts);
|
|
38
|
-
const db = (0, connection_1.openConnection)(resolved.dbPath);
|
|
39
|
-
try {
|
|
40
|
-
(0, migration_1.initializeSchema)(db, false, true); // skip builtin schema since we're running migration
|
|
41
|
-
const projectRoot = (0, path_1.resolve)(resolved.folder || process.cwd());
|
|
42
|
-
const result = (0, schema_migration_service_1.runMigration)(db, projectRoot);
|
|
43
|
-
// Also return JSON output regardless of format for structured info
|
|
44
|
-
const summary = {
|
|
45
|
-
success: result.success,
|
|
46
|
-
totalElapsedMs: result.totalElapsedMs,
|
|
47
|
-
phases: result.phases.map(p => ({
|
|
48
|
-
phase: p.phase,
|
|
49
|
-
elapsedMs: p.elapsedMs,
|
|
50
|
-
details: p.details,
|
|
51
|
-
...(p.error ? { error: p.error } : {}),
|
|
52
|
-
})),
|
|
53
|
-
...(result.errors.length > 0 ? { errors: result.errors } : {}),
|
|
54
|
-
};
|
|
55
|
-
return (0, format_selector_1.formatOutput)(summary, format, 'schema-migration');
|
|
56
|
-
}
|
|
57
|
-
finally {
|
|
58
|
-
db.close();
|
|
59
|
-
}
|
|
60
|
-
}, _cmd);
|
|
61
|
-
});
|
|
62
|
-
// schema validate — validate pre/post migration state
|
|
63
|
-
group.command('validate')
|
|
64
|
-
.description('Validate schema state')
|
|
65
|
-
.action((_opts, _cmd) => {
|
|
66
|
-
run((opts) => {
|
|
67
|
-
const format = (0, format_selector_1.selectFormat)(opts);
|
|
68
|
-
const resolved = (0, project_resolver_1.resolveFromCLI)(opts);
|
|
69
|
-
const db = (0, connection_1.openConnection)(resolved.dbPath);
|
|
70
|
-
try {
|
|
71
|
-
(0, migration_1.initializeSchema)(db, false, true);
|
|
72
|
-
let state;
|
|
73
|
-
try {
|
|
74
|
-
(0, schema_migration_service_1.validatePostMigration)(db);
|
|
75
|
-
state = 'POST-MIGRATION (16 entity types, 27 relation types)';
|
|
76
|
-
}
|
|
77
|
-
catch {
|
|
78
|
-
// Check pre-migration state
|
|
79
|
-
const entityTypeCount = db.prepare('SELECT COUNT(*) as cnt FROM entity_types').get().cnt;
|
|
80
|
-
const relationTypeCount = db.prepare('SELECT COUNT(*) as cnt FROM relation_types').get().cnt;
|
|
81
|
-
state = entityTypeCount === 20 && relationTypeCount === 31
|
|
82
|
-
? 'PRE-MIGRATION (20 entity types, 31 relation types)'
|
|
83
|
-
: `INTERMEDIATE (${entityTypeCount} entity types, ${relationTypeCount} relation types)`;
|
|
84
|
-
}
|
|
85
|
-
return (0, format_selector_1.formatOutput)({ state, valid: state.startsWith('POST'), details: { entityTypeCount: 0, relationTypeCount: 0 } }, format, 'schema-validate');
|
|
86
|
-
}
|
|
87
|
-
finally {
|
|
88
|
-
db.close();
|
|
89
|
-
}
|
|
90
|
-
}, _cmd);
|
|
91
|
-
});
|
|
92
|
-
return group;
|
|
93
|
-
}
|
|
94
|
-
//# sourceMappingURL=schema.js.map
|
package/dist/cli/schema.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/cli/schema.ts"],"names":[],"mappings":";AAAA,mCAAmC;AACnC,0DAA0D;AAC1D,yCAAyC;;AAuBzC,8CAsEC;AA3FD,yCAAoC;AACpC,+BAA+B;AAC/B,iDAAkD;AAClD,+CAAmD;AACnD,yDAAoD;AACpD,uDAAkF;AAClF,mFAA2F;AAE3F,SAAS,GAAG,CAAC,EAA6C,EAAE,SAA4C;IACtG,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,SAAS,YAAY,mBAAO,CAAC,CAAC,CAAC,SAAS,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,SAAoC,CAAC;QAC/G,MAAM,MAAM,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QACxB,IAAI,MAAM;YAAE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,GAAG,SAAS,YAAY,mBAAO,CAAC,CAAC,CAAC,SAAS,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,SAAoC,CAAC;QAC/G,MAAM,MAAM,GAAG,IAAA,8BAAY,EAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QACzF,OAAO,CAAC,KAAK,CAAC,IAAA,mCAAiB,EAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,E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A0C,CAAC,CAAC,GAAG,EAAsB,CAAC,GAAG,CAAC;oBAC9G,MAAM,iBAAiB,GAAI,EAAE,CAAC,OAAO,CAAC,4CAA4C,CAAC,CAAC,GAAG,EAAsB,CAAC,GAAG,CAAC;oBAClH,KAAK,GAAG,eAAe,KAAK,EAAE,IAAI,iBAAiB,KAAK,EAAE;wBACxD,CAAC,CAAC,oDAAoD;wBACtD,CAAC,CAAC,iBAAiB,eAAe,kBAAkB,iBAAiB,kBAAkB,CAAC;gBAC5F,CAAC;gBAED,OAAO,IAAA,8BAAY,EAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,EAAE,eAAe,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAAC;YACpJ,CAAC;oBAAS,CAAC;gBACT,EAAE,CAAC,KAAK,EAAE,CAAC;YACb,CAAC;QACH,CAAC,EAAE,IAAI,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;IAEL,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
export declare const ENTITY_TYPES: readonly [{
|
|
2
|
-
readonly name: "Person";
|
|
3
|
-
readonly description: "A human agent (analyst, architect, coder, tester, captain)";
|
|
4
|
-
readonly required_fields: {};
|
|
5
|
-
}, {
|
|
6
|
-
readonly name: "Project";
|
|
7
|
-
readonly description: "A cortex-cli project workspace";
|
|
8
|
-
readonly required_fields: {};
|
|
9
|
-
}, {
|
|
10
|
-
readonly name: "Sprint";
|
|
11
|
-
readonly description: "A named sprint with a status lifecycle";
|
|
12
|
-
readonly required_fields: {};
|
|
13
|
-
}, {
|
|
14
|
-
readonly name: "Task";
|
|
15
|
-
readonly description: "A work item belonging to a sprint";
|
|
16
|
-
readonly required_fields: {};
|
|
17
|
-
}, {
|
|
18
|
-
readonly name: "Document";
|
|
19
|
-
readonly description: "A registered document artifact";
|
|
20
|
-
readonly required_fields: {};
|
|
21
|
-
}, {
|
|
22
|
-
readonly name: "Review";
|
|
23
|
-
readonly description: "A review record with verdict";
|
|
24
|
-
readonly required_fields: {};
|
|
25
|
-
}, {
|
|
26
|
-
readonly name: "TestReport";
|
|
27
|
-
readonly description: "A test execution report";
|
|
28
|
-
readonly required_fields: {};
|
|
29
|
-
}, {
|
|
30
|
-
readonly name: "Lesson";
|
|
31
|
-
readonly description: "A lessons-learned entry";
|
|
32
|
-
readonly required_fields: {};
|
|
33
|
-
}, {
|
|
34
|
-
readonly name: "Bug";
|
|
35
|
-
readonly description: "A tracked bug";
|
|
36
|
-
readonly required_fields: {};
|
|
37
|
-
}, {
|
|
38
|
-
readonly name: "SourceFile";
|
|
39
|
-
readonly description: "A source code file";
|
|
40
|
-
readonly required_fields: {};
|
|
41
|
-
}, {
|
|
42
|
-
readonly name: "Decision";
|
|
43
|
-
readonly description: "An architecture or design decision";
|
|
44
|
-
readonly required_fields: {};
|
|
45
|
-
}];
|
|
46
|
-
export declare const RELATION_TYPES: readonly [{
|
|
47
|
-
readonly name: "has_member";
|
|
48
|
-
readonly from_types: readonly ["Sprint"];
|
|
49
|
-
readonly to_types: readonly ["Task"];
|
|
50
|
-
readonly cardinality: "one_to_many";
|
|
51
|
-
readonly description: "Sprint contains tasks";
|
|
52
|
-
}, {
|
|
53
|
-
readonly name: "depends_on";
|
|
54
|
-
readonly from_types: readonly ["Task"];
|
|
55
|
-
readonly to_types: readonly ["Task"];
|
|
56
|
-
readonly cardinality: "many_to_many";
|
|
57
|
-
readonly description: "Task dependency";
|
|
58
|
-
}, {
|
|
59
|
-
readonly name: "relates_to";
|
|
60
|
-
readonly from_types: readonly ["Task"];
|
|
61
|
-
readonly to_types: readonly ["Task"];
|
|
62
|
-
readonly cardinality: "many_to_many";
|
|
63
|
-
readonly description: "Generic task relation";
|
|
64
|
-
}, {
|
|
65
|
-
readonly name: "written_by";
|
|
66
|
-
readonly from_types: readonly ["Document"];
|
|
67
|
-
readonly to_types: readonly ["Person"];
|
|
68
|
-
readonly cardinality: "many_to_one";
|
|
69
|
-
readonly description: "Document author";
|
|
70
|
-
}, {
|
|
71
|
-
readonly name: "reviewed_by";
|
|
72
|
-
readonly from_types: readonly ["Document"];
|
|
73
|
-
readonly to_types: readonly ["Review"];
|
|
74
|
-
readonly cardinality: "many_to_one";
|
|
75
|
-
readonly description: "Review of a document";
|
|
76
|
-
}, {
|
|
77
|
-
readonly name: "approved_by";
|
|
78
|
-
readonly from_types: readonly ["Review"];
|
|
79
|
-
readonly to_types: readonly ["Person"];
|
|
80
|
-
readonly cardinality: "many_to_one";
|
|
81
|
-
readonly description: "Reviewer who gave verdict";
|
|
82
|
-
}, {
|
|
83
|
-
readonly name: "tracks";
|
|
84
|
-
readonly from_types: readonly ["Bug"];
|
|
85
|
-
readonly to_types: readonly ["Task"];
|
|
86
|
-
readonly cardinality: "many_to_one";
|
|
87
|
-
readonly description: "Bug is tracked by a task";
|
|
88
|
-
}, {
|
|
89
|
-
readonly name: "implements";
|
|
90
|
-
readonly from_types: readonly ["SourceFile"];
|
|
91
|
-
readonly to_types: readonly ["Task"];
|
|
92
|
-
readonly cardinality: "many_to_one";
|
|
93
|
-
readonly description: "Source file implements a task";
|
|
94
|
-
}, {
|
|
95
|
-
readonly name: "decides";
|
|
96
|
-
readonly from_types: readonly ["Person"];
|
|
97
|
-
readonly to_types: readonly ["Decision"];
|
|
98
|
-
readonly cardinality: "many_to_one";
|
|
99
|
-
readonly description: "Person made a decision";
|
|
100
|
-
}, {
|
|
101
|
-
readonly name: "contains";
|
|
102
|
-
readonly from_types: readonly ["Project"];
|
|
103
|
-
readonly to_types: readonly ["Document"];
|
|
104
|
-
readonly cardinality: "one_to_many";
|
|
105
|
-
readonly description: "Project contains document";
|
|
106
|
-
}];
|
|
107
|
-
export type BuiltinEntityType = typeof ENTITY_TYPES[number];
|
|
108
|
-
export type BuiltinRelationType = typeof RELATION_TYPES[number];
|
|
109
|
-
//# sourceMappingURL=builtin-schema-constants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"builtin-schema-constants.d.ts","sourceRoot":"","sources":["../../src/db/builtin-schema-constants.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYf,CAAC;AAEX,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWjB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC;AAC5D,MAAM,MAAM,mBAAmB,GAAG,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Builtin graph schema constants
|
|
3
|
-
// URD-003 §4: Predefined entity types and relation types
|
|
4
|
-
// Used by initializeBuiltinSchema() in migration.ts
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.RELATION_TYPES = exports.ENTITY_TYPES = void 0;
|
|
7
|
-
exports.ENTITY_TYPES = [
|
|
8
|
-
{ name: 'Person', description: 'A human agent (analyst, architect, coder, tester, captain)', required_fields: {} },
|
|
9
|
-
{ name: 'Project', description: 'A cortex-cli project workspace', required_fields: {} },
|
|
10
|
-
{ name: 'Sprint', description: 'A named sprint with a status lifecycle', required_fields: {} },
|
|
11
|
-
{ name: 'Task', description: 'A work item belonging to a sprint', required_fields: {} },
|
|
12
|
-
{ name: 'Document', description: 'A registered document artifact', required_fields: {} },
|
|
13
|
-
{ name: 'Review', description: 'A review record with verdict', required_fields: {} },
|
|
14
|
-
{ name: 'TestReport', description: 'A test execution report', required_fields: {} },
|
|
15
|
-
{ name: 'Lesson', description: 'A lessons-learned entry', required_fields: {} },
|
|
16
|
-
{ name: 'Bug', description: 'A tracked bug', required_fields: {} },
|
|
17
|
-
{ name: 'SourceFile', description: 'A source code file', required_fields: {} },
|
|
18
|
-
{ name: 'Decision', description: 'An architecture or design decision', required_fields: {} },
|
|
19
|
-
];
|
|
20
|
-
exports.RELATION_TYPES = [
|
|
21
|
-
{ name: 'has_member', from_types: ['Sprint'], to_types: ['Task'], cardinality: 'one_to_many', description: 'Sprint contains tasks' },
|
|
22
|
-
{ name: 'depends_on', from_types: ['Task'], to_types: ['Task'], cardinality: 'many_to_many', description: 'Task dependency' },
|
|
23
|
-
{ name: 'relates_to', from_types: ['Task'], to_types: ['Task'], cardinality: 'many_to_many', description: 'Generic task relation' },
|
|
24
|
-
{ name: 'written_by', from_types: ['Document'], to_types: ['Person'], cardinality: 'many_to_one', description: 'Document author' },
|
|
25
|
-
{ name: 'reviewed_by', from_types: ['Document'], to_types: ['Review'], cardinality: 'many_to_one', description: 'Review of a document' },
|
|
26
|
-
{ name: 'approved_by', from_types: ['Review'], to_types: ['Person'], cardinality: 'many_to_one', description: 'Reviewer who gave verdict' },
|
|
27
|
-
{ name: 'tracks', from_types: ['Bug'], to_types: ['Task'], cardinality: 'many_to_one', description: 'Bug is tracked by a task' },
|
|
28
|
-
{ name: 'implements', from_types: ['SourceFile'], to_types: ['Task'], cardinality: 'many_to_one', description: 'Source file implements a task' },
|
|
29
|
-
{ name: 'decides', from_types: ['Person'], to_types: ['Decision'], cardinality: 'many_to_one', description: 'Person made a decision' },
|
|
30
|
-
{ name: 'contains', from_types: ['Project'], to_types: ['Document'], cardinality: 'one_to_many', description: 'Project contains document' },
|
|
31
|
-
];
|
|
32
|
-
//# sourceMappingURL=builtin-schema-constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"builtin-schema-constants.js","sourceRoot":"","sources":["../../src/db/builtin-schema-constants.ts"],"names":[],"mappings":";AAAA,iCAAiC;AACjC,yDAAyD;AACzD,oDAAoD;;;AAEvC,QAAA,YAAY,GAAG;IAC1B,EAAE,IAAI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AAE,IAAI,EAAE,UAAU,EAAK,UAAU,EAAE,CAAC,SAAS,CAAC,EAAO,QAAQ,EAAE,CAAC,UAAU,CAAC,EAAI,WAAW,EAAE,aAAa,EAAI,WAAW,EAAE,2BAA2B,EAAE;CAC/I,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type Database from 'better-sqlite3';
|
|
2
|
-
import type { Entity, EntityType, EntityQueryOptions } from './entity';
|
|
3
|
-
/**
|
|
4
|
-
* Create a new entity.
|
|
5
|
-
*/
|
|
6
|
-
export declare function createEntity(db: Database.Database, id: string, typeName: string, properties?: Record<string, unknown>): Entity;
|
|
7
|
-
/**
|
|
8
|
-
* Get an entity by ID.
|
|
9
|
-
*/
|
|
10
|
-
export declare function getEntity(db: Database.Database, id: string): Entity;
|
|
11
|
-
/**
|
|
12
|
-
* Query entities with optional filters.
|
|
13
|
-
*/
|
|
14
|
-
export declare function queryEntities(db: Database.Database, options: EntityQueryOptions): Entity[];
|
|
15
|
-
/**
|
|
16
|
-
* Update entity properties (merge with existing).
|
|
17
|
-
*/
|
|
18
|
-
export declare function updateEntity(db: Database.Database, id: string, properties: Record<string, unknown>): Entity;
|
|
19
|
-
/**
|
|
20
|
-
* Delete an entity with cascade (AD-0016).
|
|
21
|
-
* Deletes all relations where entity is source or target, then the entity.
|
|
22
|
-
*/
|
|
23
|
-
export declare function deleteEntity(db: Database.Database, id: string): void;
|
|
24
|
-
/**
|
|
25
|
-
* List all entity types.
|
|
26
|
-
* builtin:3.0 (Sprint 31): Derives entity types from documents.type.
|
|
27
|
-
* No entity_types table read.
|
|
28
|
-
*/
|
|
29
|
-
export declare function listEntityTypes(db: Database.Database): EntityType[];
|
|
30
|
-
//# sourceMappingURL=entity-model.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entity-model.d.ts","sourceRoot":"","sources":["../../src/models/entity-model.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAOvE;;GAEG;AACH,wBAAgB,YAAY,CAC1B,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnC,MAAM,CA0BR;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAInE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAY1F;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,EAAE,EAAE,MAAM,EACV,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,MAAM,CAaR;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAYpE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,GAAG,UAAU,EAAE,CAKnE"}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Entity model: CRUD operations for graph entities
|
|
3
|
-
// MOD-009: Entity CRUD with cascade delete (AD-0016)
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.createEntity = createEntity;
|
|
6
|
-
exports.getEntity = getEntity;
|
|
7
|
-
exports.queryEntities = queryEntities;
|
|
8
|
-
exports.updateEntity = updateEntity;
|
|
9
|
-
exports.deleteEntity = deleteEntity;
|
|
10
|
-
exports.listEntityTypes = listEntityTypes;
|
|
11
|
-
const retry_1 = require("../db/retry");
|
|
12
|
-
const errors_1 = require("../utils/errors");
|
|
13
|
-
/**
|
|
14
|
-
* Create a new entity.
|
|
15
|
-
*/
|
|
16
|
-
function createEntity(db, id, typeName, properties) {
|
|
17
|
-
return (0, retry_1.withTransaction)(db, () => {
|
|
18
|
-
// builtin:3.0 (Sprint 31): entity_types table dropped.
|
|
19
|
-
// Entity type validation uses canonical document types.
|
|
20
|
-
// Skip entity_types check; type_name is validated by doc type gates.
|
|
21
|
-
// Check duplicate
|
|
22
|
-
const existing = db.prepare('SELECT id FROM entities WHERE id = ?').get(id);
|
|
23
|
-
if (existing)
|
|
24
|
-
throw new errors_1.GraphEntityDuplicateError(id);
|
|
25
|
-
const now = new Date().toISOString();
|
|
26
|
-
const propsJson = JSON.stringify(properties ?? {});
|
|
27
|
-
db.prepare(`
|
|
28
|
-
INSERT INTO entities (id, type_name, properties, created_at, updated_at)
|
|
29
|
-
VALUES (?, ?, ?, ?, ?)
|
|
30
|
-
`).run(id, typeName, propsJson, now, now);
|
|
31
|
-
return {
|
|
32
|
-
id,
|
|
33
|
-
type_name: typeName,
|
|
34
|
-
properties: propsJson,
|
|
35
|
-
created_at: now,
|
|
36
|
-
updated_at: now,
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Get an entity by ID.
|
|
42
|
-
*/
|
|
43
|
-
function getEntity(db, id) {
|
|
44
|
-
const row = db.prepare('SELECT * FROM entities WHERE id = ?').get(id);
|
|
45
|
-
if (!row)
|
|
46
|
-
throw new errors_1.GraphEntityNotFoundError(id);
|
|
47
|
-
return row;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Query entities with optional filters.
|
|
51
|
-
*/
|
|
52
|
-
function queryEntities(db, options) {
|
|
53
|
-
const { typeName, limit = 100, offset = 0 } = options;
|
|
54
|
-
if (typeName) {
|
|
55
|
-
return db.prepare('SELECT * FROM entities WHERE type_name = ? ORDER BY created_at DESC LIMIT ? OFFSET ?').all(typeName, limit, offset);
|
|
56
|
-
}
|
|
57
|
-
return db.prepare('SELECT * FROM entities ORDER BY created_at DESC LIMIT ? OFFSET ?').all(limit, offset);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Update entity properties (merge with existing).
|
|
61
|
-
*/
|
|
62
|
-
function updateEntity(db, id, properties) {
|
|
63
|
-
return (0, retry_1.withTransaction)(db, () => {
|
|
64
|
-
const existing = getEntity(db, id);
|
|
65
|
-
const existingProps = JSON.parse(existing.properties || '{}');
|
|
66
|
-
const merged = { ...existingProps, ...properties };
|
|
67
|
-
const now = new Date().toISOString();
|
|
68
|
-
db.prepare(`
|
|
69
|
-
UPDATE entities SET properties = ?, updated_at = ? WHERE id = ?
|
|
70
|
-
`).run(JSON.stringify(merged), now, id);
|
|
71
|
-
return { ...existing, properties: JSON.stringify(merged), updated_at: now };
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Delete an entity with cascade (AD-0016).
|
|
76
|
-
* Deletes all relations where entity is source or target, then the entity.
|
|
77
|
-
*/
|
|
78
|
-
function deleteEntity(db, id) {
|
|
79
|
-
(0, retry_1.withTransaction)(db, () => {
|
|
80
|
-
// Verify entity exists
|
|
81
|
-
const entity = db.prepare('SELECT id FROM entities WHERE id = ?').get(id);
|
|
82
|
-
if (!entity)
|
|
83
|
-
throw new errors_1.GraphEntityNotFoundError(id);
|
|
84
|
-
// Cascade: delete all relations involving this entity
|
|
85
|
-
db.prepare('DELETE FROM relations WHERE from_id = ? OR to_id = ?').run(id, id);
|
|
86
|
-
// Delete the entity
|
|
87
|
-
db.prepare('DELETE FROM entities WHERE id = ?').run(id);
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* List all entity types.
|
|
92
|
-
* builtin:3.0 (Sprint 31): Derives entity types from documents.type.
|
|
93
|
-
* No entity_types table read.
|
|
94
|
-
*/
|
|
95
|
-
function listEntityTypes(db) {
|
|
96
|
-
const types = db.prepare('SELECT DISTINCT type FROM documents ORDER BY type').all();
|
|
97
|
-
return types.map(t => ({ name: t.type }));
|
|
98
|
-
}
|
|
99
|
-
//# sourceMappingURL=entity-model.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entity-model.js","sourceRoot":"","sources":["../../src/models/entity-model.ts"],"names":[],"mappings":";AAAA,mDAAmD;AACnD,qDAAqD;;AAarD,oCA+BC;AAKD,8BAIC;AAKD,sCAYC;AAKD,oCAiBC;AAMD,oCAYC;AAOD,0CAKC;AAtHD,uCAA8C;AAC9C,4CAGyB;AAEzB;;GAEG;AACH,SAAgB,YAAY,CAC1B,EAAqB,EACrB,EAAU,EACV,QAAgB,EAChB,UAAoC;IAEpC,OAAO,IAAA,uBAAe,EAAC,EAAE,EAAE,GAAG,EAAE;QAC9B,uDAAuD;QACvD,wDAAwD;QACxD,qEAAqE;QAErE,kBAAkB;QAClB,MAAM,QAAQ,GAAG,EAAE,CAAC,OAAO,CAAC,sCAAsC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5E,IAAI,QAAQ;YAAE,MAAM,IAAI,kCAAyB,CAAC,EAAE,CAAC,CAAC;QAEtD,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QACrC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;QAEnD,EAAE,CAAC,OAAO,CAAC;;;KAGV,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAE1C,OAAO;YACL,EAAE;YACF,SAAS,EAAE,QAAQ;YACnB,UAAU,EAAE,SAAS;YACrB,UAAU,EAAE,GAAG;YACf,UAAU,EAAE,GAAG;SAChB,CAAC;IACJ,CAAC,CAAC,CAAC;A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AAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW,CAwElF"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// mapping audit check: doc→entity-type mapping validation
|
|
3
|
-
// FS-SS-023-0001: Verify every document has a valid entity-type mapping
|
|
4
|
-
// FS-SS-023-0012 v2: Sprint scoping via task/doc ID matching (URD-G001 removed documents.sprint_id)
|
|
5
|
-
// MOD-023: CLI Audit Command
|
|
6
|
-
// builtin:3.0 (Sprint 31): entity_types table dropped; doc types ARE entity type names
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.mappingCheck = mappingCheck;
|
|
9
|
-
/** Canonical document types in builtin:3.0 (SAD-0033 §2) */
|
|
10
|
-
const CANONICAL_DOC_TYPES = new Set(['AD', 'FR', 'FS', 'MDL', 'NFR', 'NFS', 'QA', 'SAD', 'SRC', 'TC', 'TR', 'TS', 'US']);
|
|
11
|
-
function mappingCheck(db, sprintId) {
|
|
12
|
-
let docs;
|
|
13
|
-
if (sprintId) {
|
|
14
|
-
// Sprint scoping via task ID matching (URD-G001 removed documents.sprint_id)
|
|
15
|
-
// Documents whose ID matches a task ID in the given sprint
|
|
16
|
-
const sprintDocIds = db.prepare(`
|
|
17
|
-
SELECT DISTINCT d.id FROM documents d
|
|
18
|
-
WHERE d.id IN (SELECT t.id FROM tasks t WHERE t.sprint_id = ?)
|
|
19
|
-
`).all(sprintId);
|
|
20
|
-
const sprintDocIdSet = new Set(sprintDocIds.map(r => r.id));
|
|
21
|
-
const allDocs = db.prepare('SELECT id, type, title FROM documents').all();
|
|
22
|
-
docs = allDocs.filter(d => sprintDocIdSet.has(d.id));
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
docs = db.prepare('SELECT id, type, title FROM documents').all();
|
|
26
|
-
}
|
|
27
|
-
const issues = [];
|
|
28
|
-
for (const doc of docs) {
|
|
29
|
-
// builtin:3.0: doc type IS entity type name (no mapping needed).
|
|
30
|
-
const expectedEntityType = doc.type;
|
|
31
|
-
if (!expectedEntityType) {
|
|
32
|
-
issues.push({
|
|
33
|
-
issueId: 'MISSING_MAPPING',
|
|
34
|
-
docId: doc.id,
|
|
35
|
-
docType: doc.type,
|
|
36
|
-
detail: `Document "${doc.id}" (type: ${doc.type}) has no known entity-type mapping`,
|
|
37
|
-
fixable: false,
|
|
38
|
-
});
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
// builtin:3.0: entity_types table dropped.
|
|
42
|
-
// Validate against canonical doc types instead.
|
|
43
|
-
if (!CANONICAL_DOC_TYPES.has(doc.type)) {
|
|
44
|
-
issues.push({
|
|
45
|
-
issueId: 'INVALID_ENTITY_TYPE',
|
|
46
|
-
docId: doc.id,
|
|
47
|
-
docType: doc.type,
|
|
48
|
-
detail: `Document "${doc.id}" (type: ${doc.type}) is not a canonical document type`,
|
|
49
|
-
fixable: false,
|
|
50
|
-
});
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
// Check if corresponding entity exists and has correct type_name
|
|
54
|
-
const entity = db.prepare('SELECT type_name FROM entities WHERE id = ?').get(doc.id);
|
|
55
|
-
if (entity !== undefined && entity.type_name !== expectedEntityType) {
|
|
56
|
-
issues.push({
|
|
57
|
-
issueId: 'TYPE_MISMATCH',
|
|
58
|
-
docId: doc.id,
|
|
59
|
-
docType: doc.type,
|
|
60
|
-
entityId: doc.id,
|
|
61
|
-
entityTypeFound: entity.type_name,
|
|
62
|
-
entityTypeExpected: expectedEntityType,
|
|
63
|
-
detail: `Document "${doc.id}" (type: ${doc.type}) has entity "${doc.id}" with type_name "${entity.type_name}" but expected "${expectedEntityType}"`,
|
|
64
|
-
fixable: false,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
const status = issues.length === 0 ? 'PASS' : 'FAIL';
|
|
69
|
-
const summary = status === 'PASS'
|
|
70
|
-
? `All ${docs.length} documents have valid entity-type mappings`
|
|
71
|
-
: `${issues.length} documents have mapping issues (${issues.filter(i => i.issueId === 'MISSING_MAPPING').length} missing, ${issues.filter(i => i.issueId === 'INVALID_ENTITY_TYPE').length} invalid, ${issues.filter(i => i.issueId === 'TYPE_MISMATCH').length} type mismatch)`;
|
|
72
|
-
return { checkName: 'mapping', status, summary, issues };
|
|
73
|
-
}
|
|
74
|
-
//# sourceMappingURL=mapping-check.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mapping-check.js","sourceRoot":"","sources":["../../../src/services/audit-checks/mapping-check.ts"],"names":[],"mappings":";AAAA,0DAA0D;AAC1D,wEAAwE;AACxE,oGAAoG;AACpG,6BAA6B;AAC7B,uFAAuF;;AAQvF,oCAwEC;AA3ED,4DAA4D;AAC5D,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAEzH,SAAgB,YAAY,CAAC,EAAqB,EAAE,QAAiB;IACnE,IAAI,IAAwD,CAAC;IAE7D,IAAI,QAAQ,EAAE,CAAC;QACb,6EAA6E;QAC7E,2DAA2D;QAC3D,MAAM,YAAY,GAAG,EAAE,CAAC,OAAO,CAAC;;;KAG/B,CAAC,CAAC,GAAG,CAAC,QAAQ,CAA0B,CAAC;QAC1C,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5D,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,uCAAuC,CAAC,CAAC,GAAG,EAAwD,CAAC;QAChI,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAA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[],"mappings":"AAIA,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAc,MAAM,SAAS,CAAC;AAEvD,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW,CAsCzF"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// orphan-entities audit check: entities with no graph relations
|
|
3
|
-
// FS-SS-023-0002: Detect entities with zero relations, classify fixability
|
|
4
|
-
// MOD-023: CLI Audit Command
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.orphanEntitiesCheck = orphanEntitiesCheck;
|
|
7
|
-
function orphanEntitiesCheck(db, sprintId) {
|
|
8
|
-
// Find entities with no relations
|
|
9
|
-
const orphans = db.prepare(`
|
|
10
|
-
SELECT e.id, e.type_name,
|
|
11
|
-
(SELECT COUNT(*) FROM documents d WHERE d.id = e.id) as doc_count
|
|
12
|
-
FROM entities e
|
|
13
|
-
WHERE (SELECT COUNT(*) FROM relations r WHERE r.from_id = e.id OR r.to_id = e.id) = 0
|
|
14
|
-
`).all();
|
|
15
|
-
let issues = [];
|
|
16
|
-
for (const entity of orphans) {
|
|
17
|
-
const hasDoc = entity.doc_count > 0;
|
|
18
|
-
issues.push({
|
|
19
|
-
issueId: hasDoc ? 'ORPHAN_ENTITY_WITH_DOC' : 'ORPHAN_ENTITY_NO_DOC',
|
|
20
|
-
entityId: entity.id,
|
|
21
|
-
detail: hasDoc
|
|
22
|
-
? `Entity "${entity.id}" (type: ${entity.type_name}) has no relations but has an associated document`
|
|
23
|
-
: `Entity "${entity.id}" (type: ${entity.type_name}) has no relations and no associated document`,
|
|
24
|
-
fixable: !hasDoc,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
// Sprint scoping via task ID matching (URD-G001 removed documents.sprint_id)
|
|
28
|
-
if (sprintId) {
|
|
29
|
-
const sprintDocIds = new Set(db.prepare('SELECT DISTINCT d.id FROM documents d WHERE d.id IN (SELECT t.id FROM tasks t WHERE t.sprint_id = ?)').all(sprintId).map(r => r.id));
|
|
30
|
-
issues = issues.filter(i => i.entityId && sprintDocIds.has(i.entityId));
|
|
31
|
-
}
|
|
32
|
-
const status = issues.length === 0 ? 'PASS' : 'FAIL';
|
|
33
|
-
const fixableCount = issues.filter(i => i.fixable).length;
|
|
34
|
-
const summary = status === 'PASS'
|
|
35
|
-
? 'No orphan entities found'
|
|
36
|
-
: `${issues.length} orphan entities found (${fixableCount} fixable)`;
|
|
37
|
-
return { checkName: 'orphan-entities', status, summary, issues };
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=orphan-entities-check.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"orphan-entities-check.js","sourceRoot":"","sources":["../../../src/services/audit-checks/orphan-entities-check.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,2EAA2E;AAC3E,6BAA6B;;AAK7B,kDAsCC;AAtCD,SAAgB,mBAAmB,CAAC,EAAqB,EAAE,QAAiB;IAC1E,kCAAkC;IAClC,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC;;;;;GAK1B,CAAC,CAAC,GAAG,EAAiE,CAAC;IAExE,IAAI,MAAM,GAAiB,EAAE,CAAC;IAE9B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,GAAG,CAAC,CAAC;QACpC,MAAM,CAAC,IAAI,CAAC;YACV,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,sBAAsB;YACnE,QAAQ,EAAE,MAAM,CAAC,EAAE;YACnB,MAAM,EAAE,MAAM;gBACZ,CAAC,CAAC,WAAW,MAAM,CAAC,EAAE,YAAY,MAAM,CAAC,SAAS,mDAAmD;gBACrG,CAAC,CAAC,W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B,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW,CA2D5F"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// sprint-consistency audit check: sprint-scoped doc types with missing sprint
|
|
3
|
-
// FS-SS-023-0004: Verify REVIEW, TEST-REPORT, TASK documents have sprint_id
|
|
4
|
-
// MOD-023: CLI Audit Command
|
|
5
|
-
//
|
|
6
|
-
// Note: TASK here refers to documents.type = 'TASK', not kanban tasks
|
|
7
|
-
//
|
|
8
|
-
// Backward compatibility: Documents created before MOD-022e enforcement date
|
|
9
|
-
// receive a warning (severity: warning) rather than a MISSING_SPRINT error,
|
|
10
|
-
// to avoid false positives for pre-enforcement legacy documents.
|
|
11
|
-
// FS-SS-023-0004 backward-compatibility scope (per SAD-023 §3.5).
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.sprintConsistencyCheck = sprintConsistencyCheck;
|
|
14
|
-
/** Document types that must be sprint-scoped */
|
|
15
|
-
const SPRINT_SCOPED_TYPES = ['REVIEW', 'TEST-REPORT', 'TASK'];
|
|
16
|
-
/**
|
|
17
|
-
* MOD-022e deployment cutoff date.
|
|
18
|
-
* Documents created before this date are exempt from MISSING_SPRINT errors
|
|
19
|
-
* because sprint-scoping enforcement was not yet active.
|
|
20
|
-
*
|
|
21
|
-
* This date is derived from the MOD-022e migration deployment (sprint-2026051101).
|
|
22
|
-
* It can be adjusted if the actual deployment timestamp differs.
|
|
23
|
-
*
|
|
24
|
-
* To disable backward-compatibility discrimination entirely, set to a date
|
|
25
|
-
* far in the past (e.g., '1970-01-01T00:00:00Z').
|
|
26
|
-
*/
|
|
27
|
-
const MOD_022E_CUTOFF_DATE = '2026-05-09T00:00:00Z';
|
|
28
|
-
function sprintConsistencyCheck(db, sprintId) {
|
|
29
|
-
let docs;
|
|
30
|
-
if (sprintId) {
|
|
31
|
-
docs = db.prepare(`SELECT id, type, sprint_id, created_at FROM documents WHERE sprint_id = ? AND type IN (${SPRINT_SCOPED_TYPES.map(() => '?').join(',')})`).all(sprintId, ...SPRINT_SCOPED_TYPES);
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
docs = db.prepare(`SELECT id, type, sprint_id, created_at FROM documents WHERE type IN (${SPRINT_SCOPED_TYPES.map(() => '?').join(',')})`).all(...SPRINT_SCOPED_TYPES);
|
|
35
|
-
}
|
|
36
|
-
const issues = [];
|
|
37
|
-
for (const doc of docs) {
|
|
38
|
-
if (doc.sprint_id === null) {
|
|
39
|
-
const isPreEnforcement = doc.created_at < MOD_022E_CUTOFF_DATE;
|
|
40
|
-
if (isPreEnforcement) {
|
|
41
|
-
// Pre-enforcement document: flag as informational warning, not error
|
|
42
|
-
issues.push({
|
|
43
|
-
issueId: 'MISSING_SPRINT',
|
|
44
|
-
severity: 'warning',
|
|
45
|
-
docId: doc.id,
|
|
46
|
-
docType: doc.type,
|
|
47
|
-
detail: `Document "${doc.id}" (type: ${doc.type}, created: ${doc.created_at}) is sprint-scoped but has no sprint_id — created before MOD-022e enforcement (${MOD_022E_CUTOFF_DATE}); informational only`,
|
|
48
|
-
fixable: false,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
// Post-enforcement document: real error
|
|
53
|
-
issues.push({
|
|
54
|
-
issueId: 'MISSING_SPRINT',
|
|
55
|
-
severity: 'error',
|
|
56
|
-
docId: doc.id,
|
|
57
|
-
docType: doc.type,
|
|
58
|
-
detail: `Document "${doc.id}" (type: ${doc.type}) is sprint-scoped but has no sprint_id`,
|
|
59
|
-
fixable: false,
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
// Determine status: warnings alone don't cause FAIL — only actual errors do
|
|
65
|
-
const errorIssues = issues.filter(i => i.severity !== 'warning' && i.severity !== 'info');
|
|
66
|
-
const warningCount = issues.filter(i => i.severity === 'warning').length;
|
|
67
|
-
const status = errorIssues.length === 0 ? (issues.length === 0 ? 'PASS' : 'PASS') : 'FAIL';
|
|
68
|
-
const summaryParts = [];
|
|
69
|
-
if (errorIssues.length > 0) {
|
|
70
|
-
summaryParts.push(`${errorIssues.length} sprint-scoped documents missing sprint_id`);
|
|
71
|
-
}
|
|
72
|
-
if (warningCount > 0) {
|
|
73
|
-
summaryParts.push(`${warningCount} pre-enforcement documents with missing sprint_id (informational)`);
|
|
74
|
-
}
|
|
75
|
-
const summary = summaryParts.length > 0
|
|
76
|
-
? summaryParts.join('; ')
|
|
77
|
-
: 'All sprint-scoped documents have valid sprint_id';
|
|
78
|
-
return { checkName: 'sprint-consistency', status, summary, issues };
|
|
79
|
-
}
|
|
80
|
-
//# sourceMappingURL=sprint-consistency-check.js.map
|