@nodesify/astria 1.0.11 → 1.1.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/dist/commands/cluster.d.ts +7 -1
- package/dist/commands/cluster.d.ts.map +1 -1
- package/dist/commands/cluster.js +9 -2
- package/dist/commands/cluster.js.map +1 -1
- package/dist/commands/digest.d.ts +7 -0
- package/dist/commands/digest.d.ts.map +1 -0
- package/dist/commands/digest.js +161 -0
- package/dist/commands/digest.js.map +1 -0
- package/dist/commands/explain.d.ts.map +1 -1
- package/dist/commands/explain.js +14 -2
- package/dist/commands/explain.js.map +1 -1
- package/dist/commands/health.d.ts +1 -0
- package/dist/commands/health.d.ts.map +1 -1
- package/dist/commands/health.js +29 -19
- package/dist/commands/health.js.map +1 -1
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/install.js +11 -1
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/map.d.ts.map +1 -1
- package/dist/commands/map.js +2 -1
- package/dist/commands/map.js.map +1 -1
- package/dist/commands/mcp.d.ts +17 -2
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +16 -0
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/merge-driver.d.ts +7 -0
- package/dist/commands/merge-driver.d.ts.map +1 -0
- package/dist/commands/merge-driver.js +186 -0
- package/dist/commands/merge-driver.js.map +1 -0
- package/dist/commands/merge-gate.d.ts +14 -0
- package/dist/commands/merge-gate.d.ts.map +1 -0
- package/dist/commands/merge-gate.js +220 -0
- package/dist/commands/merge-gate.js.map +1 -0
- package/dist/commands/merge.d.ts +4 -1
- package/dist/commands/merge.d.ts.map +1 -1
- package/dist/commands/merge.js +4 -3
- package/dist/commands/merge.js.map +1 -1
- package/dist/commands/prs.d.ts +3 -0
- package/dist/commands/prs.d.ts.map +1 -1
- package/dist/commands/prs.js +188 -13
- package/dist/commands/prs.js.map +1 -1
- package/dist/commands/query.d.ts.map +1 -1
- package/dist/commands/query.js +2 -1
- package/dist/commands/query.js.map +1 -1
- package/dist/commands/stats.d.ts.map +1 -1
- package/dist/commands/stats.js +1 -0
- package/dist/commands/stats.js.map +1 -1
- package/dist/commands/watch.d.ts.map +1 -1
- package/dist/commands/watch.js +83 -49
- package/dist/commands/watch.js.map +1 -1
- package/dist/defaults.d.ts +2 -0
- package/dist/defaults.d.ts.map +1 -0
- package/dist/defaults.js +7 -0
- package/dist/defaults.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +85 -14
- package/dist/index.js.map +1 -1
- package/dist/install/index.d.ts +1 -0
- package/dist/install/index.d.ts.map +1 -1
- package/dist/install/index.js +64 -0
- package/dist/install/index.js.map +1 -1
- package/dist/install/settings-inject.d.ts.map +1 -1
- package/dist/install/settings-inject.js +3 -3
- package/dist/install/settings-inject.js.map +1 -1
- package/dist/native.d.ts +42 -40
- package/dist/native.d.ts.map +1 -1
- package/dist/native.js +56 -85
- package/dist/native.js.map +1 -1
- package/package.json +10 -8
- package/dist/commands/migrate.d.ts +0 -4
- package/dist/commands/migrate.d.ts.map +0 -1
- package/dist/commands/migrate.js +0 -75
- package/dist/commands/migrate.js.map +0 -1
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Git merge driver for the knowledge graph artifact. Parallel branches both
|
|
3
|
+
// rebuild the graph and both commit `.astria/graph.json` — plain git sees
|
|
4
|
+
// JSON line noise and conflicts. This driver performs a 3-way union merge
|
|
5
|
+
// over the graph structure so both branches' additions survive:
|
|
6
|
+
//
|
|
7
|
+
// nodes/edges/hyperedges: union by key with classic 3-way field
|
|
8
|
+
// resolution (unchanged side takes the changed side; both changed keeps
|
|
9
|
+
// ours); a side's deletion of an entry is respected.
|
|
10
|
+
// communities: derived data — take whichever side changed from base;
|
|
11
|
+
// the next `astria update` re-clusters anyway.
|
|
12
|
+
//
|
|
13
|
+
// Git wiring (done by `astria merge-driver install`):
|
|
14
|
+
// .gitattributes: .astria/graph.json merge=astria
|
|
15
|
+
// .git/config: merge.astria.driver = astria merge-driver run %O %A %B %P
|
|
16
|
+
//
|
|
17
|
+
// Exit 0 = merged cleanly (the merged graph is written over %A); exit 1 =
|
|
18
|
+
// unmergeable input (git falls back to a conflict).
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.threeWayUnion = threeWayUnion;
|
|
21
|
+
exports.mergeDriverRun = mergeDriverRun;
|
|
22
|
+
exports.mergeDriverInstall = mergeDriverInstall;
|
|
23
|
+
exports.mergeDriverUninstall = mergeDriverUninstall;
|
|
24
|
+
const fs_1 = require("fs");
|
|
25
|
+
const child_process_1 = require("child_process");
|
|
26
|
+
const path_1 = require("path");
|
|
27
|
+
const GRAPH_JSON_PATH = '.astria/graph.json';
|
|
28
|
+
const REPORT_PATH = '.astria/graph_report.md';
|
|
29
|
+
function loadJson(path, label) {
|
|
30
|
+
try {
|
|
31
|
+
return JSON.parse((0, fs_1.readFileSync)(path, 'utf-8'));
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
throw new Error(`cannot read ${label} (${path}): ${e.message || e}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/// Classic 3-way field resolution for two versions of one object.
|
|
38
|
+
/// Unchanged-on-both-sides, changed-on-one-side, and agree-on-both cases
|
|
39
|
+
/// collapse; genuine divergence keeps ours (git's own convention).
|
|
40
|
+
function mergeFields(base, ours, theirs) {
|
|
41
|
+
const out = {};
|
|
42
|
+
const keys = new Set([...Object.keys(ours), ...Object.keys(theirs)]);
|
|
43
|
+
for (const key of keys) {
|
|
44
|
+
const o = ours[key];
|
|
45
|
+
const t = theirs[key];
|
|
46
|
+
const b = base ? base[key] : undefined;
|
|
47
|
+
if (JSON.stringify(o) === JSON.stringify(t)) {
|
|
48
|
+
out[key] = o;
|
|
49
|
+
}
|
|
50
|
+
else if (JSON.stringify(o) === JSON.stringify(b)) {
|
|
51
|
+
out[key] = t; // only theirs changed
|
|
52
|
+
}
|
|
53
|
+
else if (JSON.stringify(t) === JSON.stringify(b)) {
|
|
54
|
+
out[key] = o; // only ours changed
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
out[key] = o; // both changed differently — ours wins
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
/// 3-way union over arrays of objects keyed by `key(entry)`. An entry that
|
|
63
|
+
/// exists only on one side and not in base is that side's addition; one in
|
|
64
|
+
/// base but missing from a side is that side's deletion.
|
|
65
|
+
function threeWayUnion(baseEntries, oursEntries, theirsEntries, keyOf) {
|
|
66
|
+
const index = (entries) => new Map(entries.map((e) => [keyOf(e), e]));
|
|
67
|
+
const base = index(baseEntries);
|
|
68
|
+
const ours = index(oursEntries);
|
|
69
|
+
const theirs = index(theirsEntries);
|
|
70
|
+
const keys = new Set([...base.keys(), ...ours.keys(), ...theirs.keys()]);
|
|
71
|
+
const merged = [];
|
|
72
|
+
for (const key of [...keys].sort()) {
|
|
73
|
+
const b = base.get(key);
|
|
74
|
+
const o = ours.get(key);
|
|
75
|
+
const t = theirs.get(key);
|
|
76
|
+
if (o && t) {
|
|
77
|
+
merged.push(mergeFields(b, o, t));
|
|
78
|
+
}
|
|
79
|
+
else if (o) {
|
|
80
|
+
if (!b)
|
|
81
|
+
merged.push(o); // ours added it
|
|
82
|
+
// else theirs deleted it — drop
|
|
83
|
+
}
|
|
84
|
+
else if (t) {
|
|
85
|
+
if (!b)
|
|
86
|
+
merged.push(t); // theirs added it
|
|
87
|
+
// else ours deleted it — drop
|
|
88
|
+
}
|
|
89
|
+
// both deleted, or vanished both sides — drop
|
|
90
|
+
}
|
|
91
|
+
return merged;
|
|
92
|
+
}
|
|
93
|
+
/// Communities are derived (re-clustered on every build): whichever side
|
|
94
|
+
/// moved away from base wins wholesale; identical sides stay identical.
|
|
95
|
+
function mergeCommunities(base, ours, theirs) {
|
|
96
|
+
if (base && JSON.stringify(ours) === JSON.stringify(base.communities))
|
|
97
|
+
return theirs;
|
|
98
|
+
return ours;
|
|
99
|
+
}
|
|
100
|
+
function mergeGraphs(base, ours, theirs) {
|
|
101
|
+
const arr = (graph, name) => Array.isArray(graph[name]) ? graph[name] : [];
|
|
102
|
+
return {
|
|
103
|
+
nodes: threeWayUnion(arr(base, 'nodes'), arr(ours, 'nodes'), arr(theirs, 'nodes'), (n) => String(n.id)),
|
|
104
|
+
edges: threeWayUnion(arr(base, 'edges'), arr(ours, 'edges'), arr(theirs, 'edges'), (e) => `${e.source}|${e.target}|${e.relation}`),
|
|
105
|
+
hyperedges: threeWayUnion(arr(base, 'hyperedges'), arr(ours, 'hyperedges'), arr(theirs, 'hyperedges'), (h) => String(h.id)),
|
|
106
|
+
communities: mergeCommunities(base, arr(ours, 'communities'), arr(theirs, 'communities')),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/// The `git merge` driver entry: base, ours (written in place), theirs,
|
|
110
|
+
/// then git's path argument.
|
|
111
|
+
function mergeDriverRun(basePath, oursPath, theirsPath) {
|
|
112
|
+
try {
|
|
113
|
+
const base = (0, fs_1.existsSync)(basePath) ? loadJson(basePath, 'base graph') : { nodes: [], edges: [], hyperedges: [], communities: [] };
|
|
114
|
+
const ours = loadJson(oursPath, 'ours');
|
|
115
|
+
const theirs = loadJson(theirsPath, 'theirs');
|
|
116
|
+
const merged = mergeGraphs(base, ours, theirs);
|
|
117
|
+
(0, fs_1.writeFileSync)(oursPath, JSON.stringify(merged, null, 2) + '\n');
|
|
118
|
+
const n = merged.nodes.length;
|
|
119
|
+
const e = merged.edges.length;
|
|
120
|
+
console.log(`astria merge-driver: union-merged graph.json (${n} nodes, ${e} edges)`);
|
|
121
|
+
return 0;
|
|
122
|
+
}
|
|
123
|
+
catch (e) {
|
|
124
|
+
console.error(`astria merge-driver: ${e.message || e}`);
|
|
125
|
+
console.error('falling back to a git conflict on .astria/graph.json');
|
|
126
|
+
return 1;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function gitConfigGet(key) {
|
|
130
|
+
try {
|
|
131
|
+
return (0, child_process_1.execFileSync)('git', ['config', '--get', key], { encoding: 'utf-8' }).trim() || null;
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/// Idempotent install: .gitattributes entry + git config driver definition.
|
|
138
|
+
function mergeDriverInstall(projectDir) {
|
|
139
|
+
const messages = [];
|
|
140
|
+
const attributesPath = (0, path_1.join)(projectDir, '.gitattributes');
|
|
141
|
+
const graphEntry = `${GRAPH_JSON_PATH} merge=astria`;
|
|
142
|
+
const reportEntry = `${REPORT_PATH} merge=union`;
|
|
143
|
+
let attributes = (0, fs_1.existsSync)(attributesPath) ? (0, fs_1.readFileSync)(attributesPath, 'utf-8') : '';
|
|
144
|
+
let changed = false;
|
|
145
|
+
for (const entry of [graphEntry, reportEntry]) {
|
|
146
|
+
if (!attributes.split('\n').some((line) => line.trim() === entry)) {
|
|
147
|
+
if (attributes && !attributes.endsWith('\n'))
|
|
148
|
+
attributes += '\n';
|
|
149
|
+
attributes += entry + '\n';
|
|
150
|
+
changed = true;
|
|
151
|
+
messages.push(`.gitattributes: ${entry}`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (changed)
|
|
155
|
+
(0, fs_1.writeFileSync)(attributesPath, attributes);
|
|
156
|
+
(0, child_process_1.execFileSync)('git', ['config', 'merge.astria.name', 'astria knowledge graph union-merge'], { cwd: projectDir });
|
|
157
|
+
(0, child_process_1.execFileSync)('git', ['config', 'merge.astria.driver', 'astria merge-driver run %O %A %B %P'], { cwd: projectDir });
|
|
158
|
+
messages.push('git config: merge.astria.driver = astria merge-driver run %O %A %B %P');
|
|
159
|
+
messages.push('committed .astria/graph.json files on parallel branches now union-merge automatically');
|
|
160
|
+
return messages;
|
|
161
|
+
}
|
|
162
|
+
function mergeDriverUninstall(projectDir) {
|
|
163
|
+
const messages = [];
|
|
164
|
+
const attributesPath = (0, path_1.join)(projectDir, '.gitattributes');
|
|
165
|
+
if ((0, fs_1.existsSync)(attributesPath)) {
|
|
166
|
+
const kept = (0, fs_1.readFileSync)(attributesPath, 'utf-8')
|
|
167
|
+
.split('\n')
|
|
168
|
+
.filter((line) => {
|
|
169
|
+
const t = line.trim();
|
|
170
|
+
return t !== `${GRAPH_JSON_PATH} merge=astria` && t !== `${REPORT_PATH} merge=union` && t !== '';
|
|
171
|
+
});
|
|
172
|
+
(0, fs_1.writeFileSync)(attributesPath, kept.length ? kept.join('\n') + '\n' : '');
|
|
173
|
+
messages.push('.gitattributes: astria merge entries removed');
|
|
174
|
+
}
|
|
175
|
+
for (const key of ['merge.astria.name', 'merge.astria.driver']) {
|
|
176
|
+
try {
|
|
177
|
+
(0, child_process_1.execFileSync)('git', ['config', '--unset', key], { cwd: projectDir, stdio: 'pipe' });
|
|
178
|
+
messages.push(`git config: ${key} removed`);
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
// never set — fine
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return messages;
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=merge-driver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge-driver.js","sourceRoot":"","sources":["../../src/commands/merge-driver.ts"],"names":[],"mappings":";AAAA,4EAA4E;AAC5E,0EAA0E;AAC1E,0EAA0E;AAC1E,gEAAgE;AAChE,EAAE;AACF,kEAAkE;AAClE,4EAA4E;AAC5E,yDAAyD;AACzD,uEAAuE;AACvE,mDAAmD;AACnD,EAAE;AACF,sDAAsD;AACtD,qDAAqD;AACrD,+EAA+E;AAC/E,EAAE;AACF,0EAA0E;AAC1E,oDAAoD;;AA6CpD,sCA4BC;AAgCD,wCAgBC;AAWD,gDA0BC;AAED,oDAsBC;AApLD,2BAA6D;AAC7D,iDAA6C;AAC7C,+BAA4B;AAI5B,MAAM,eAAe,GAAG,oBAAoB,CAAC;AAC7C,MAAM,WAAW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U,EAAC,cAAc,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,GAAG,IAAA,iBAAY,EAAC,cAAc,EAAE,OAAO,CAAC;aAC/C,KAAK,CAAC,IAAI,CAAC;aACX,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;YACf,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YACtB,OAAO,CAAC,KAAK,GAAG,eAAe,eAAe,IAAI,CAAC,KAAK,GAAG,WAAW,cAAc,IAAI,CAAC,KAAK,EAAE,CAAC;QACnG,CAAC,CAAC,CAAC;QACL,IAAA,kBAAa,EAAC,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACzE,QAAQ,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAC;IAChE,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,CAAC,mBAAmB,EAAE,qBAAqB,CAAC,EAAE,CAAC;QAC/D,IAAI,CAAC;YACH,IAAA,4BAAY,EAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;YACpF,QAAQ,CAAC,IAAI,CAAC,eAAe,GAAG,UAAU,CAAC,CAAC;QAC9C,CAAC;QAAC,MAAM,CAAC;YACP,mBAAmB;QACrB,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface MergeGateOptions {
|
|
2
|
+
graph: string;
|
|
3
|
+
maxAgeHours?: string;
|
|
4
|
+
minHealth?: string;
|
|
5
|
+
maxRisk?: string;
|
|
6
|
+
staged?: boolean;
|
|
7
|
+
/** Score the committed diff `base...head` instead of the working tree (CI/PR mode). */
|
|
8
|
+
base?: string;
|
|
9
|
+
/** Head ref of the range; defaults to HEAD when --base is given. */
|
|
10
|
+
head?: string;
|
|
11
|
+
json?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function mergeGateCommand(opts: MergeGateOptions): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=merge-gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge-gate.d.ts","sourceRoot":"","sources":["../../src/commands/merge-gate.ts"],"names":[],"mappings":"AAqBA,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,uFAAuF;IACvF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAoCD,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,iBA8K5D"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Merge gate: the OSS-side artifact of the hosted tier's "merge-gate
|
|
3
|
+
// verification". A CI command that refuses to merge on a stale, missing, or
|
|
4
|
+
// unhealthy graph, and quantifies the blast radius of the pending diff:
|
|
5
|
+
//
|
|
6
|
+
// astria merge-gate --max-age-hours 24 --min-health 60 --max-risk 70
|
|
7
|
+
//
|
|
8
|
+
// Exit 0 = pass (green), exit 1 = fail with the failing checks listed —
|
|
9
|
+
// wire it into CI or a GitHub required check. `--json` for the hosted
|
|
10
|
+
// pipeline to consume.
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.mergeGateCommand = mergeGateCommand;
|
|
13
|
+
const child_process_1 = require("child_process");
|
|
14
|
+
const fs_1 = require("fs");
|
|
15
|
+
const path_1 = require("path");
|
|
16
|
+
const native_1 = require("../native");
|
|
17
|
+
const BOLD = '\x1b[1m';
|
|
18
|
+
const GREEN = '\x1b[32m';
|
|
19
|
+
const RED = '\x1b[31m';
|
|
20
|
+
const DIM = '\x1b[2m';
|
|
21
|
+
const RESET = '\x1b[0m';
|
|
22
|
+
// Git work-tree detection that distinguishes the three outcomes: inside a
|
|
23
|
+
// work tree, genuinely outside one (exit 128 + "not a git repository"), or
|
|
24
|
+
// the git invocation FAILED (git missing, broken index, ...). A failure is
|
|
25
|
+
// an error string — never a silent "not a repository" skip, which would
|
|
26
|
+
// let the gate pass without the diff-risk check it promised.
|
|
27
|
+
function gitWorkTreeStatus(projectRoot) {
|
|
28
|
+
try {
|
|
29
|
+
const out = (0, child_process_1.execFileSync)('git', ['rev-parse', '--is-inside-work-tree'], {
|
|
30
|
+
cwd: projectRoot,
|
|
31
|
+
encoding: 'utf8',
|
|
32
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
33
|
+
});
|
|
34
|
+
return { inside: out.trim() === 'true', error: null };
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
const stderr = String(e?.stderr ?? '');
|
|
38
|
+
if (e?.status === 128 && /not a git repository/i.test(stderr)) {
|
|
39
|
+
return { inside: false, error: null };
|
|
40
|
+
}
|
|
41
|
+
if (e?.code === 'ENOENT') {
|
|
42
|
+
return { inside: false, error: 'git executable not found on PATH' };
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
inside: false,
|
|
46
|
+
error: (stderr || e?.message || String(e)).trim().split('\n').pop() || 'git failed',
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async function mergeGateCommand(opts) {
|
|
51
|
+
try {
|
|
52
|
+
const maxAgeHours = opts.maxAgeHours !== undefined ? Number(opts.maxAgeHours) : 24;
|
|
53
|
+
const minHealth = opts.minHealth !== undefined ? Number(opts.minHealth) : 60;
|
|
54
|
+
const maxRisk = opts.maxRisk !== undefined ? Number(opts.maxRisk) : 70;
|
|
55
|
+
for (const [name, value] of [['--max-age-hours', maxAgeHours], ['--min-health', minHealth], ['--max-risk', maxRisk]]) {
|
|
56
|
+
if (!Number.isFinite(value))
|
|
57
|
+
throw new Error(`invalid ${name}: not a number`);
|
|
58
|
+
}
|
|
59
|
+
const checks = [];
|
|
60
|
+
const dbPath = (0, path_1.join)(opts.graph, '.astria', 'db.sqlite');
|
|
61
|
+
// 1. The graph exists and carries build provenance.
|
|
62
|
+
let build = null;
|
|
63
|
+
try {
|
|
64
|
+
build = (0, native_1.graphBuildInfo)(opts.graph);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
// fall through — handled by the exists check
|
|
68
|
+
}
|
|
69
|
+
const exists = build !== null && build !== undefined || (0, fs_1.existsSync)(dbPath);
|
|
70
|
+
checks.push({
|
|
71
|
+
name: 'graph-exists',
|
|
72
|
+
passed: exists,
|
|
73
|
+
detail: exists ? `built by astria ${build?.astriaVersion ?? '?'}, pipeline ${build?.pipelineVersion ?? '?'}` : `no graph at ${dbPath} — run 'astria run' first`,
|
|
74
|
+
});
|
|
75
|
+
// 2. Two distinct freshness signals:
|
|
76
|
+
// - graph AGE (how long since publication, ceiling-configured), and
|
|
77
|
+
// - source COVERAGE (does the graph represent the current HEAD —
|
|
78
|
+
// commit identity plus manifest content comparison).
|
|
79
|
+
// - extraction RULESET (was the graph built by the current extraction
|
|
80
|
+
// code at all — see check 2b).
|
|
81
|
+
// A graph built after a commit can still fail coverage: it may have
|
|
82
|
+
// been built from a dirty tree, an older commit, or drifted since.
|
|
83
|
+
// One probe for both coverage and diff-risk.
|
|
84
|
+
const gitStatus = gitWorkTreeStatus(opts.graph);
|
|
85
|
+
if (exists) {
|
|
86
|
+
const publishedAt = Number(build?.graphPublishedAt);
|
|
87
|
+
const ageHours = Number.isFinite(publishedAt) && publishedAt > 0
|
|
88
|
+
? (Date.now() / 1000 - publishedAt) / 3600
|
|
89
|
+
: null;
|
|
90
|
+
checks.push({
|
|
91
|
+
name: 'graph-fresh',
|
|
92
|
+
passed: ageHours !== null && ageHours <= maxAgeHours,
|
|
93
|
+
detail: ageHours === null
|
|
94
|
+
? 'graph has no publish timestamp (pre-provenance build) — rebuild with `astria run`'
|
|
95
|
+
: `graph is ${ageHours.toFixed(1)} h old (age limit ${maxAgeHours} h; source coverage is a separate check below)`,
|
|
96
|
+
});
|
|
97
|
+
// 2b. Extraction ruleset. Age and HEAD coverage both pass for a graph
|
|
98
|
+
// the CURRENT build would extract differently: the old cache is
|
|
99
|
+
// reused, so the graph reports yesterday's facts with today's
|
|
100
|
+
// timestamps. The committed self-graph drifted five commits this
|
|
101
|
+
// way (`extraction_hash_version` v12 against code at v14). A version
|
|
102
|
+
// mismatch means the recorded facts predate the current extraction
|
|
103
|
+
// rules, so nodes and edges may be missing; rebuild before trusting
|
|
104
|
+
// a merge decision to them.
|
|
105
|
+
const builtWith = build?.extractionHashVersion;
|
|
106
|
+
const currentRules = build?.currentExtractionHashVersion;
|
|
107
|
+
const extractionCurrent = !!builtWith && !!currentRules && builtWith === currentRules;
|
|
108
|
+
checks.push({
|
|
109
|
+
name: 'extraction-current',
|
|
110
|
+
passed: extractionCurrent,
|
|
111
|
+
detail: extractionCurrent
|
|
112
|
+
? `graph extracted by the current ruleset (${builtWith})`
|
|
113
|
+
: `graph was extracted with ${builtWith ?? 'an unknown version'} but this build extracts with ${currentRules ?? '?'} — run 'astria update .' to re-extract changed files`,
|
|
114
|
+
});
|
|
115
|
+
// Coverage: the HEAD recorded at publication must equal the current
|
|
116
|
+
// HEAD, and every manifest file must still hash to the content the
|
|
117
|
+
// graph was built from. A publish timestamp alone only proved the
|
|
118
|
+
// build happened LATER — never that it saw the commit.
|
|
119
|
+
if (gitStatus.error !== null) {
|
|
120
|
+
checks.push({
|
|
121
|
+
name: 'graph-covers-head',
|
|
122
|
+
passed: false,
|
|
123
|
+
detail: `git detection failed: ${gitStatus.error} — cannot verify the graph covers HEAD`,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
else if (gitStatus.inside) {
|
|
127
|
+
try {
|
|
128
|
+
const coverage = (0, native_1.verifySourceCommit)(opts.graph);
|
|
129
|
+
const samples = coverage.driftSamples.length > 0
|
|
130
|
+
? ` (${coverage.driftSamples.join('; ')})`
|
|
131
|
+
: '';
|
|
132
|
+
const verified = coverage.filesChecked > 0
|
|
133
|
+
? ` — ${coverage.filesChecked} manifest file(s) content-verified`
|
|
134
|
+
: '';
|
|
135
|
+
checks.push({
|
|
136
|
+
name: 'graph-covers-head',
|
|
137
|
+
passed: coverage.coversHead === true,
|
|
138
|
+
detail: `${coverage.reason}${verified}${samples}`,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
catch (e) {
|
|
142
|
+
checks.push({
|
|
143
|
+
name: 'graph-covers-head',
|
|
144
|
+
passed: false,
|
|
145
|
+
detail: `coverage verification failed: ${e?.message || e}`,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// 3. Health floor.
|
|
151
|
+
if (exists) {
|
|
152
|
+
const health = (0, native_1.healthReport)(opts.graph);
|
|
153
|
+
checks.push({
|
|
154
|
+
name: 'health-floor',
|
|
155
|
+
passed: health.score >= minHealth,
|
|
156
|
+
detail: `health score ${health.score}/100 (floor ${minHealth}), grade ${health.grade}`,
|
|
157
|
+
});
|
|
158
|
+
// 4. Blast radius of the pending diff. Outside a git repository is an
|
|
159
|
+
// explicit, visible skip; a FAILED git detection is a FAILED check
|
|
160
|
+
// — never a silent "not a repository" skip that lets the gate pass
|
|
161
|
+
// without the diff-risk it promised.
|
|
162
|
+
if (gitStatus.error !== null) {
|
|
163
|
+
checks.push({
|
|
164
|
+
name: 'diff-risk',
|
|
165
|
+
passed: false,
|
|
166
|
+
detail: `git detection failed: ${gitStatus.error} — cannot score the diff`,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
else if (!gitStatus.inside) {
|
|
170
|
+
checks.push({
|
|
171
|
+
name: 'diff-risk',
|
|
172
|
+
passed: true,
|
|
173
|
+
detail: 'skipped — not a git repository (risk requires a diff to score)',
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
try {
|
|
178
|
+
const useRange = opts.base !== undefined;
|
|
179
|
+
const risk = (0, native_1.riskReport)(opts.graph, opts.staged === true && !useRange, useRange ? opts.base : undefined, useRange ? (opts.head ?? 'HEAD') : undefined);
|
|
180
|
+
const riskPassed = risk.score <= maxRisk;
|
|
181
|
+
checks.push({
|
|
182
|
+
name: 'diff-risk',
|
|
183
|
+
passed: riskPassed,
|
|
184
|
+
detail: useRange
|
|
185
|
+
? `diff risk ${risk.score}/100 for ${opts.base}...${opts.head ?? 'HEAD'} (ceiling ${maxRisk}), ${risk.impacted} symbols impacted across ${risk.changedFiles.length} changed file(s)`
|
|
186
|
+
: `diff risk ${risk.score}/100 (ceiling ${maxRisk}), ${risk.impacted} symbols impacted across ${risk.changedFiles.length} changed file(s)`,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
catch (e) {
|
|
190
|
+
checks.push({
|
|
191
|
+
name: 'diff-risk',
|
|
192
|
+
passed: false,
|
|
193
|
+
detail: `risk calculation failed: ${e?.message || e}`,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
const passed = checks.every((c) => c.passed);
|
|
199
|
+
if (opts.json) {
|
|
200
|
+
console.log(JSON.stringify({ passed, checks }, null, 2));
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
console.log(`${BOLD}Merge gate — ${passed ? 'PASSED ✓' : 'FAILED ✗'}${RESET}\n`);
|
|
204
|
+
for (const check of checks) {
|
|
205
|
+
const mark = check.passed ? `${GREEN}✓${RESET}` : `${RED}✗${RESET}`;
|
|
206
|
+
console.log(` ${mark} ${check.name}: ${check.detail}`);
|
|
207
|
+
}
|
|
208
|
+
if (!passed) {
|
|
209
|
+
console.log(`\n${DIM}Fix the failing checks or adjust the thresholds — this gate is what the hosted tier enforces on every merge.${RESET}`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (!passed)
|
|
213
|
+
process.exitCode = 1;
|
|
214
|
+
}
|
|
215
|
+
catch (e) {
|
|
216
|
+
console.error(`Error: ${e.message || e}`);
|
|
217
|
+
process.exitCode = 1;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=merge-gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge-gate.js","sourceRoot":"","sources":["../../src/commands/merge-gate.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,4EAA4E;AAC5E,wEAAwE;AACxE,EAAE;AACF,uEAAuE;AACvE,EAAE;AACF,wEAAwE;AACxE,sEAAsE;AACtE,uBAAuB;;AA4DvB,4CA8KC;AAxOD,iDAA6C;AAC7C,2BAAgC;AAChC,+BAA4B;AAC5B,sCAAyF;AAEzF,MAAM,IAAI,GAAG,SAAS,CAAC;AACvB,MAAM,KAAK,GAAG,UAAU,CAAC;AACzB,MAAM,GAAG,GAAG,UAAU,CAAC;AACvB,MAAM,GAAG,GAAG,SAAS,CAAC;AACtB,MAAM,KAAK,GAAG,SAAS,CAAC;AAqBxB,0EAA0E;AAC1E,2EAA2E;AAC3E,2EAA2E;AAC3E,wEAAwE;AACxE,6DAA6D;AAC7D,SAAS,iBAAiB,CAAC,WAAmB;IAC5C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAA,4BAAY,EAAC,KAAK,EAAE,CAAC,WAAW,EAAE,uBAAuB,CAAC,EAAE;YACtE,GAAG,EAAE,WAAW;YAChB,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;SAChC,CAAC,CAAC;QACH,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,EAAE,KAAK,MAAM,EAAE,KAAK,EAA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CAAC,CAAC;YACzD,CAAC;YACD,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG,+GAA+G,KAAK,EAAE,CAAC,CAAC;YAC9I,CAAC;QACH,CAAC;QACD,IAAI,CAAC,MAAM;YAAE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACpC,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,OAAO,IAAI,CAAC,EAAE,CAAC,CAAC;QAC1C,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
|
package/dist/commands/merge.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface MergeOptions {
|
|
2
|
+
sameRepo?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function mergeCommand(pathA: string, pathB: string, outPath: string, opts?: MergeOptions): Promise<void>;
|
|
2
5
|
//# sourceMappingURL=merge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/commands/merge.ts"],"names":[],"mappings":"AAGA,wBAAsB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/commands/merge.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,YAAiB,iBAaxG"}
|
package/dist/commands/merge.js
CHANGED
|
@@ -36,10 +36,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.mergeCommand = mergeCommand;
|
|
37
37
|
const path = __importStar(require("path"));
|
|
38
38
|
const native_1 = require("../native");
|
|
39
|
-
async function mergeCommand(pathA, pathB, outPath) {
|
|
39
|
+
async function mergeCommand(pathA, pathB, outPath, opts = {}) {
|
|
40
40
|
try {
|
|
41
|
-
console.log(`Merging graphs: ${pathA} + ${pathB} -> ${outPath}`
|
|
42
|
-
|
|
41
|
+
console.log(`Merging graphs: ${pathA} + ${pathB} -> ${outPath}` +
|
|
42
|
+
(opts.sameRepo ? ' (same repository: shared ids, conflicts error)' : ' (cross-repository: ids namespaced per root)'));
|
|
43
|
+
const result = (0, native_1.mergeGraphs)(pathA, pathB, outPath, opts.sameRepo === true);
|
|
43
44
|
console.log(`Nodes: ${result.nodesAdded}, Edges: ${result.edgesAdded}, Communities: ${result.communities}`);
|
|
44
45
|
console.log(`Merged graph written to: ${path.join(outPath, '.astria')}`);
|
|
45
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/commands/merge.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/commands/merge.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,oCAaC;AApBD,2CAA6B;AAC7B,sCAAwC;AAMjC,KAAK,UAAU,YAAY,CAAC,KAAa,EAAE,KAAa,EAAE,OAAe,EAAE,OAAqB,EAAE;IACvG,IAAI,CAAC;QACH,OAAO,CAAC,GAAG,CACT,mBAAmB,KAAK,MAAM,KAAK,OAAO,OAAO,EAAE;YACjD,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,iDAAiD,CAAC,CAAC,CAAC,8CAA8C,CAAC,CACvH,CAAC;QACF,MAAM,MAAM,GAAG,IAAA,oBAAW,EAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC;QAC1E,OAAO,CAAC,GAAG,CAAC,UAAU,MAAM,CAAC,UAAU,YAAY,MAAM,CAAC,UAAU,kBAAkB,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;QAC5G,OAAO,CAAC,GAAG,CAAC,4BAA4B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC;IAC3E,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,OAAO,IAAI,CAAC,EAAE,CAAC,CAAC;QAC1C,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
|
package/dist/commands/prs.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prs.d.ts","sourceRoot":"","sources":["../../src/commands/prs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prs.d.ts","sourceRoot":"","sources":["../../src/commands/prs.ts"],"names":[],"mappings":"AA+SA,wBAAsB,UAAU,CAC9B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,iBA2E/F"}
|