yuangs 2.31.0 → 2.32.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/cli.js +6 -1
- package/dist/cli.js.map +1 -1
- package/dist/governance/GovernanceEngine.d.ts +20 -0
- package/dist/governance/GovernanceEngine.js +95 -0
- package/dist/governance/GovernanceEngine.js.map +1 -0
- package/dist/governance/GovernedAction.d.ts +107 -0
- package/dist/governance/GovernedAction.js +9 -0
- package/dist/governance/GovernedAction.js.map +1 -0
- package/dist/governance/actions/CodeChangeAction.d.ts +28 -0
- package/dist/governance/actions/CodeChangeAction.js +139 -0
- package/dist/governance/actions/CodeChangeAction.js.map +1 -0
- package/dist/governance/capability/token.d.ts +45 -0
- package/dist/governance/capability/token.js +103 -0
- package/dist/governance/capability/token.js.map +1 -0
- package/dist/governance/commands/diffEdit.d.ts +2 -0
- package/dist/governance/commands/diffEdit.js +176 -0
- package/dist/governance/commands/diffEdit.js.map +1 -0
- package/dist/governance/execution/sandbox.d.ts +12 -0
- package/dist/governance/execution/sandbox.js +76 -0
- package/dist/governance/execution/sandbox.js.map +1 -0
- package/dist/governance/fsm/stateMachine.d.ts +40 -0
- package/dist/governance/fsm/stateMachine.js +93 -0
- package/dist/governance/fsm/stateMachine.js.map +1 -0
- package/dist/governance/index.d.ts +9 -0
- package/dist/governance/index.js +26 -0
- package/dist/governance/index.js.map +1 -0
- package/dist/governance/review/diffParser.d.ts +12 -0
- package/dist/governance/review/diffParser.js +61 -0
- package/dist/governance/review/diffParser.js.map +1 -0
- package/dist/governance/review/render.d.ts +5 -0
- package/dist/governance/review/render.js +58 -0
- package/dist/governance/review/render.js.map +1 -0
- package/dist/governance/storage/store.d.ts +16 -0
- package/dist/governance/storage/store.js +110 -0
- package/dist/governance/storage/store.js.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.sign = sign;
|
|
7
|
+
exports.verify = verify;
|
|
8
|
+
exports.issue = issue;
|
|
9
|
+
exports.checkCapability = checkCapability;
|
|
10
|
+
exports.attenuate = attenuate;
|
|
11
|
+
exports.revoke = revoke;
|
|
12
|
+
exports.checkRevoked = checkRevoked;
|
|
13
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
14
|
+
const SECRET = process.env.CAP_SECRET || "default-secret-change-in-production";
|
|
15
|
+
function sign(data) {
|
|
16
|
+
return crypto_1.default
|
|
17
|
+
.createHmac("sha256", SECRET)
|
|
18
|
+
.update(data)
|
|
19
|
+
.digest("hex");
|
|
20
|
+
}
|
|
21
|
+
function verify(cap) {
|
|
22
|
+
const { signature, ...rest } = cap;
|
|
23
|
+
const payload = JSON.stringify(rest);
|
|
24
|
+
const computed = sign(payload);
|
|
25
|
+
return computed === signature;
|
|
26
|
+
}
|
|
27
|
+
function issue(input) {
|
|
28
|
+
const base = {
|
|
29
|
+
id: crypto_1.default.randomUUID(),
|
|
30
|
+
subject: input.subject,
|
|
31
|
+
rights: input.rights,
|
|
32
|
+
scope: input.scope,
|
|
33
|
+
issuedAt: Date.now(),
|
|
34
|
+
expiresAt: Date.now() + input.ttlMs,
|
|
35
|
+
maxUses: input.maxUses ?? 1,
|
|
36
|
+
used: 0,
|
|
37
|
+
};
|
|
38
|
+
const payload = JSON.stringify(base);
|
|
39
|
+
return {
|
|
40
|
+
...base,
|
|
41
|
+
signature: sign(payload),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function checkCapability(cap, want, context) {
|
|
45
|
+
if (!verify(cap)) {
|
|
46
|
+
throw new Error("Invalid capability: signature verification failed");
|
|
47
|
+
}
|
|
48
|
+
if (Date.now() > cap.expiresAt) {
|
|
49
|
+
throw new Error("Capability expired");
|
|
50
|
+
}
|
|
51
|
+
if (cap.used >= cap.maxUses) {
|
|
52
|
+
throw new Error("Capability exhausted (max uses reached)");
|
|
53
|
+
}
|
|
54
|
+
const rightMatch = cap.rights.some((r) => JSON.stringify(r) === JSON.stringify(want));
|
|
55
|
+
if (!rightMatch) {
|
|
56
|
+
throw new Error(`Capability does not grant right: ${JSON.stringify(want)}`);
|
|
57
|
+
}
|
|
58
|
+
if (cap.scope.type === "ACTION" && context.actionId !== cap.scope.id) {
|
|
59
|
+
throw new Error(`Scope violation: capability scoped to action ${cap.scope.id}, used on ${context.actionId}`);
|
|
60
|
+
}
|
|
61
|
+
if (cap.scope.type === "PATH_PREFIX" &&
|
|
62
|
+
context.path &&
|
|
63
|
+
!context.path.startsWith(cap.scope.prefix)) {
|
|
64
|
+
throw new Error(`Scope violation: capability scoped to ${cap.scope.prefix}, used on ${context.path}`);
|
|
65
|
+
}
|
|
66
|
+
cap.used++;
|
|
67
|
+
}
|
|
68
|
+
function attenuate(cap, limits) {
|
|
69
|
+
if (!verify(cap)) {
|
|
70
|
+
throw new Error("Cannot attenuate invalid capability");
|
|
71
|
+
}
|
|
72
|
+
const reduced = {
|
|
73
|
+
...cap,
|
|
74
|
+
expiresAt: Math.min(cap.expiresAt, limits.expiresAt ?? cap.expiresAt),
|
|
75
|
+
maxUses: Math.min(cap.maxUses, limits.maxUses ?? cap.maxUses),
|
|
76
|
+
used: 0,
|
|
77
|
+
signature: "",
|
|
78
|
+
};
|
|
79
|
+
const payload = JSON.stringify({
|
|
80
|
+
id: reduced.id,
|
|
81
|
+
subject: reduced.subject,
|
|
82
|
+
rights: reduced.rights,
|
|
83
|
+
scope: reduced.scope,
|
|
84
|
+
issuedAt: reduced.issuedAt,
|
|
85
|
+
expiresAt: reduced.expiresAt,
|
|
86
|
+
maxUses: reduced.maxUses,
|
|
87
|
+
used: 0,
|
|
88
|
+
});
|
|
89
|
+
return {
|
|
90
|
+
...reduced,
|
|
91
|
+
signature: sign(payload),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
const revokedCaps = new Set();
|
|
95
|
+
function revoke(capId) {
|
|
96
|
+
revokedCaps.add(capId);
|
|
97
|
+
}
|
|
98
|
+
function checkRevoked(cap) {
|
|
99
|
+
if (revokedCaps.has(cap.id)) {
|
|
100
|
+
throw new Error(`Capability ${cap.id} has been revoked`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.js","sourceRoot":"","sources":["../../../src/governance/capability/token.ts"],"names":[],"mappings":";;;;;AA2BA,oBAKC;AAED,wBAMC;AAED,sBAwBC;AAED,0CA4CC;AAED,8BAkCC;AAID,wBAEC;AAED,oCAIC;AAhKD,oDAA4B;AAG5B,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,qCAAqC,CAAC;AAwB/E,SAAgB,IAAI,CAAC,IAAY;IAC/B,OAAO,gBAAM;SACV,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC;SAC5B,MAAM,CAAC,IAAI,CAAC;SACZ,MAAM,CAAC,KAAK,CAAC,CAAC;AACnB,CAAC;AAED,SAAgB,MAAM,CAAC,GAAe;IACpC,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG,CAAC;IACnC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;IAE/B,OAAO,QAAQ,KAAK,SAAS,CAAC;AAChC,CAAC;AAED,SAAgB,KAAK,CAAC,KAMrB;IACC,MAAM,IAAI,GAAG;QACX,EAAE,EAAE,gBAAM,CAAC,UAAU,EAAE;QACvB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,QAAQ,EAAE,IAAI,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;QACxB,IAAI,EAAE,CAAC;KACR,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,OAAO;QACV,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC;KACzB,CAAC;AACJ,CAAC;AAED,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;AAEtC,SAAgB,MAAM,CAAC,KAAa;IAClC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC;AAED,SAAgB,YAAY,CAAC,GAAe;IAC1C,IAAI,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,cAAc,GAAG,CAAC,EAAE,mBAAmB,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createDiffEditCommand = createDiffEditCommand;
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const GovernanceEngine_1 = require("../GovernanceEngine");
|
|
11
|
+
const CodeChangeAction_1 = require("../actions/CodeChangeAction");
|
|
12
|
+
const diffParser_1 = require("../review/diffParser");
|
|
13
|
+
const render_1 = require("../review/render");
|
|
14
|
+
const sandbox_1 = require("../execution/sandbox");
|
|
15
|
+
const store_1 = require("../storage/store");
|
|
16
|
+
const engine = new GovernanceEngine_1.GovernanceEngine();
|
|
17
|
+
(0, store_1.auditActions)((0, store_1.loadActions)());
|
|
18
|
+
class GitExecutor {
|
|
19
|
+
async applyDiff(diff) {
|
|
20
|
+
const { execSync } = require("child_process");
|
|
21
|
+
try {
|
|
22
|
+
execSync("git apply --index", {
|
|
23
|
+
input: diff,
|
|
24
|
+
stdio: "pipe",
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
throw new Error(`Failed to apply diff: ${error}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async readFile(path) {
|
|
32
|
+
return fs_1.default.promises.readFile(path, "utf-8");
|
|
33
|
+
}
|
|
34
|
+
async writeFile(path, content) {
|
|
35
|
+
await fs_1.default.promises.writeFile(path, content, "utf-8");
|
|
36
|
+
}
|
|
37
|
+
async deleteFile(path) {
|
|
38
|
+
await fs_1.default.promises.unlink(path);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function createDiffEditCommand() {
|
|
42
|
+
const program = new commander_1.Command("diff-edit");
|
|
43
|
+
program
|
|
44
|
+
.description("Governed code change CLI - review before executing")
|
|
45
|
+
.version("1.0.0");
|
|
46
|
+
program
|
|
47
|
+
.command("propose <diff-file>")
|
|
48
|
+
.option("-r, --rationale <text>", "Why this change is needed")
|
|
49
|
+
.action(async (diffFile, options) => {
|
|
50
|
+
if (!fs_1.default.existsSync(diffFile)) {
|
|
51
|
+
console.error(chalk_1.default.red(`Diff file not found: ${diffFile}`));
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
const diff = fs_1.default.readFileSync(diffFile, "utf-8");
|
|
55
|
+
const rationale = options.rationale || "Manual diff submission";
|
|
56
|
+
const files = (0, diffParser_1.extractFilesFromDiff)(diff);
|
|
57
|
+
const payload = { files, diff };
|
|
58
|
+
const action = CodeChangeAction_1.CodeChangeAction.create(payload, rationale, "cli", "manual-" + Date.now());
|
|
59
|
+
action.propose();
|
|
60
|
+
const actions = (0, store_1.loadActions)();
|
|
61
|
+
actions[action.id] = action;
|
|
62
|
+
(0, store_1.saveActions)(actions);
|
|
63
|
+
console.log(chalk_1.default.green(`[PROPOSED] ${action.id}`));
|
|
64
|
+
console.log(chalk_1.default.cyan("Files:"));
|
|
65
|
+
for (const f of files) {
|
|
66
|
+
console.log(` - ${chalk_1.default.yellow(f)}`);
|
|
67
|
+
}
|
|
68
|
+
console.log(`\n${chalk_1.default.bold("Rationale:")} ${rationale}`);
|
|
69
|
+
});
|
|
70
|
+
program
|
|
71
|
+
.command("list")
|
|
72
|
+
.description("List all proposed actions")
|
|
73
|
+
.action(() => {
|
|
74
|
+
const actions = (0, store_1.loadActions)();
|
|
75
|
+
console.log(chalk_1.default.bold("\n" + "=".repeat(60)));
|
|
76
|
+
console.log(chalk_1.default.bold("Actions"));
|
|
77
|
+
console.log(chalk_1.default.bold("=".repeat(60)) + "\n");
|
|
78
|
+
const table = [];
|
|
79
|
+
for (const [id, a] of Object.entries(actions)) {
|
|
80
|
+
table.push({
|
|
81
|
+
id,
|
|
82
|
+
kind: a.kind,
|
|
83
|
+
state: a.state,
|
|
84
|
+
rationale: a.rationale.substring(0, 50),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
console.table(table);
|
|
88
|
+
});
|
|
89
|
+
program
|
|
90
|
+
.command("approve <id>")
|
|
91
|
+
.description("Review and approve a proposed action")
|
|
92
|
+
.action(async (id) => {
|
|
93
|
+
const actions = (0, store_1.loadActions)();
|
|
94
|
+
const action = actions[id];
|
|
95
|
+
if (!action) {
|
|
96
|
+
console.error(chalk_1.default.red(`Action not found: ${id}`));
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
99
|
+
const files = (0, diffParser_1.parseUnifiedDiff)(action.payload.diff);
|
|
100
|
+
(0, render_1.renderDiffForReview)(files, action.rationale);
|
|
101
|
+
const { level, warnings } = (0, diffParser_1.assessRisk)(files);
|
|
102
|
+
(0, render_1.renderRiskAssessment)(level, warnings);
|
|
103
|
+
const approved = await (0, render_1.promptForApproval)();
|
|
104
|
+
if (!approved) {
|
|
105
|
+
console.log(chalk_1.default.red("\n[REJECTED] Approval aborted"));
|
|
106
|
+
action.state = "REJECTED";
|
|
107
|
+
(0, store_1.saveActions)(actions);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
action.state = "APPROVED";
|
|
111
|
+
(0, store_1.saveActions)(actions);
|
|
112
|
+
console.log(chalk_1.default.green(`\n[APPROVED] ${id}`));
|
|
113
|
+
});
|
|
114
|
+
program
|
|
115
|
+
.command("exec <id>")
|
|
116
|
+
.description("Execute an approved action")
|
|
117
|
+
.action(async (id) => {
|
|
118
|
+
const actions = (0, store_1.loadActions)();
|
|
119
|
+
const action = actions[id];
|
|
120
|
+
if (!action) {
|
|
121
|
+
console.error(chalk_1.default.red(`Action not found: ${id}`));
|
|
122
|
+
process.exit(1);
|
|
123
|
+
}
|
|
124
|
+
if (action.state !== "APPROVED") {
|
|
125
|
+
console.error(chalk_1.default.red(`Action not approved (state: ${action.state})`));
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
console.log(chalk_1.default.cyan(`\n[EXECUTING] ${id}...`));
|
|
129
|
+
const snapshot = (0, sandbox_1.createSnapshot)();
|
|
130
|
+
const executor = new GitExecutor();
|
|
131
|
+
const ctx = { executor, snapshot: snapshot.id };
|
|
132
|
+
try {
|
|
133
|
+
await executor.applyDiff(action.payload.diff);
|
|
134
|
+
const changedFiles = (0, sandbox_1.getChangedFiles)();
|
|
135
|
+
(0, sandbox_1.assertNoExtraChanges)(action.payload.files, changedFiles);
|
|
136
|
+
(0, sandbox_1.commitChanges)(`EXECUTED action ${id}`, snapshot.id);
|
|
137
|
+
action.state = "EXECUTED";
|
|
138
|
+
action.executedAt = Date.now();
|
|
139
|
+
(0, store_1.saveActions)(actions);
|
|
140
|
+
console.log(chalk_1.default.green(`\n[EXECUTED] ${id}`));
|
|
141
|
+
console.log(chalk_1.default.cyan(`Files changed: ${changedFiles.length}`));
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
console.error(chalk_1.default.red(`\n[FAILED] ${error}`));
|
|
145
|
+
console.log(chalk_1.default.yellow("\nRolling back to snapshot..."));
|
|
146
|
+
(0, sandbox_1.rollbackToSnapshot)(snapshot.id);
|
|
147
|
+
action.state = "REJECTED";
|
|
148
|
+
(0, store_1.saveActions)(actions);
|
|
149
|
+
console.log(chalk_1.default.cyan("\nRolled back successfully"));
|
|
150
|
+
process.exit(1);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
program
|
|
154
|
+
.command("status <id>")
|
|
155
|
+
.description("Show status of an action")
|
|
156
|
+
.action((id) => {
|
|
157
|
+
const actions = (0, store_1.loadActions)();
|
|
158
|
+
const action = actions[id];
|
|
159
|
+
if (!action) {
|
|
160
|
+
console.error(chalk_1.default.red(`Action not found: ${id}`));
|
|
161
|
+
process.exit(1);
|
|
162
|
+
}
|
|
163
|
+
console.log(chalk_1.default.bold("\n" + "=".repeat(60)));
|
|
164
|
+
console.log(chalk_1.default.bold(`Action: ${id}`));
|
|
165
|
+
console.log(chalk_1.default.bold("=".repeat(60)) + "\n");
|
|
166
|
+
console.log(`${chalk_1.default.bold("Kind:")} ${action.kind}`);
|
|
167
|
+
console.log(`${chalk_1.default.bold("State:")} ${action.state}`);
|
|
168
|
+
console.log(`${chalk_1.default.bold("Rationale:")} ${action.rationale}`);
|
|
169
|
+
console.log(`${chalk_1.default.bold("Updated:")} ${new Date(action.updatedAt).toLocaleString()}`);
|
|
170
|
+
if (action.state === "EXECUTED" && action.executedAt) {
|
|
171
|
+
console.log(`${chalk_1.default.bold("Executed:")} ${new Date(action.executedAt).toLocaleString()}`);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
return program;
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=diffEdit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diffEdit.js","sourceRoot":"","sources":["../../../src/governance/commands/diffEdit.ts"],"names":[],"mappings":";;;;;AA2CA,sDAoMC;AA/OD,yCAAoC;AACpC,kDAA0B;AAC1B,4CAAoB;AAEpB,0DAAuD;AACvD,kEAAkF;AAElF,qDAA0F;AAC1F,6CAA+G;AAC/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AM,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;QAE/C,OAAO,CAAC,GAAG,CAAC,GAAG,eAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QACrD,OAAO,CAAC,GAAG,CAAC,GAAG,eAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QACvD,OAAO,CAAC,GAAG,CAAC,GAAG,eAAK,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;QAC/D,OAAO,CAAC,GAAG,CACT,GAAG,eAAK,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,IAAI,CACnC,MAAM,CAAC,SAAS,CACjB,CAAC,cAAc,EAAE,EAAE,CACrB,CAAC;QAEF,IAAI,MAAM,CAAC,KAAK,KAAK,UAAU,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACrD,OAAO,CAAC,GAAG,CACT,GAAG,eAAK,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,IAAI,CACpC,MAAM,CAAC,UAAU,CAClB,CAAC,cAAc,EAAE,EAAE,CACrB,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface ExecutionSnapshot {
|
|
2
|
+
id: string;
|
|
3
|
+
commitHash: string;
|
|
4
|
+
timestamp: number;
|
|
5
|
+
isClean: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function createSnapshot(): ExecutionSnapshot;
|
|
8
|
+
export declare function verifySnapshot(snapshotId: string): boolean;
|
|
9
|
+
export declare function rollbackToSnapshot(snapshotId: string): void;
|
|
10
|
+
export declare function commitChanges(message: string, snapshotId: string): void;
|
|
11
|
+
export declare function getChangedFiles(): string[];
|
|
12
|
+
export declare function assertNoExtraChanges(approvedFiles: string[], actualFiles: string[]): void;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSnapshot = createSnapshot;
|
|
4
|
+
exports.verifySnapshot = verifySnapshot;
|
|
5
|
+
exports.rollbackToSnapshot = rollbackToSnapshot;
|
|
6
|
+
exports.commitChanges = commitChanges;
|
|
7
|
+
exports.getChangedFiles = getChangedFiles;
|
|
8
|
+
exports.assertNoExtraChanges = assertNoExtraChanges;
|
|
9
|
+
const child_process_1 = require("child_process");
|
|
10
|
+
function createSnapshot() {
|
|
11
|
+
const statusOutput = (0, child_process_1.execSync)("git status --porcelain", {
|
|
12
|
+
encoding: "utf-8",
|
|
13
|
+
}).trim();
|
|
14
|
+
const isClean = statusOutput.length === 0;
|
|
15
|
+
if (!isClean) {
|
|
16
|
+
throw new Error("Cannot create snapshot: working tree is dirty. Commit or stash changes first.");
|
|
17
|
+
}
|
|
18
|
+
const commitHash = (0, child_process_1.execSync)("git rev-parse HEAD", {
|
|
19
|
+
encoding: "utf-8",
|
|
20
|
+
}).trim();
|
|
21
|
+
return {
|
|
22
|
+
id: commitHash,
|
|
23
|
+
commitHash,
|
|
24
|
+
timestamp: Date.now(),
|
|
25
|
+
isClean,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function verifySnapshot(snapshotId) {
|
|
29
|
+
try {
|
|
30
|
+
const current = (0, child_process_1.execSync)("git rev-parse HEAD", {
|
|
31
|
+
encoding: "utf-8",
|
|
32
|
+
}).trim();
|
|
33
|
+
return current === snapshotId;
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function rollbackToSnapshot(snapshotId) {
|
|
40
|
+
try {
|
|
41
|
+
(0, child_process_1.execSync)(`git reset --hard ${snapshotId}`, {
|
|
42
|
+
stdio: "inherit",
|
|
43
|
+
});
|
|
44
|
+
console.log(`Rolled back to snapshot ${snapshotId}`);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
throw new Error(`Failed to rollback to snapshot ${snapshotId}: ${error}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function commitChanges(message, snapshotId) {
|
|
51
|
+
try {
|
|
52
|
+
(0, child_process_1.execSync)(`git commit -am "${message}"`, {
|
|
53
|
+
stdio: "inherit",
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
throw new Error(`Failed to commit changes: ${error}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function getChangedFiles() {
|
|
61
|
+
const output = (0, child_process_1.execSync)("git diff --name-only", {
|
|
62
|
+
encoding: "utf-8",
|
|
63
|
+
});
|
|
64
|
+
return output
|
|
65
|
+
.trim()
|
|
66
|
+
.split("\n")
|
|
67
|
+
.filter((f) => f.length > 0);
|
|
68
|
+
}
|
|
69
|
+
function assertNoExtraChanges(approvedFiles, actualFiles) {
|
|
70
|
+
const approvedSet = new Set(approvedFiles);
|
|
71
|
+
const extraFiles = actualFiles.filter((f) => !approvedSet.has(f));
|
|
72
|
+
if (extraFiles.length > 0) {
|
|
73
|
+
throw new Error(`Governance violation: execution modified undeclared files:\n${extraFiles.join("\n")}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=sandbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox.js","sourceRoot":"","sources":["../../../src/governance/execution/sandbox.ts"],"names":[],"mappings":";;AASA,wCAuBC;AAED,wCAUC;AAED,gDAWC;AAED,sCAQC;AAED,0CASC;AAED,oDAYC;AA5FD,iDAAyC;AASzC,SAAgB,cAAc;IAC5B,MAAM,YAAY,GAAG,IAAA,wBAAQ,EAAC,wBAAwB,EAAE;QACtD,QAAQ,EAAE,OAAO;KAClB,CAAC,CAAC,IAAI,EAAE,CAA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M,IAAI,KAAK,CAAC,6BAA6B,KAAK,EAAE,CAAC,CAAC;IACxD,CAAC;AACH,CAAC;AAED,SAAgB,eAAe;IAC7B,MAAM,MAAM,GAAG,IAAA,wBAAQ,EAAC,sBAAsB,EAAE;QAC9C,QAAQ,EAAE,OAAO;KAClB,CAAC,CAAC;IAEH,OAAO,MAAM;SACV,IAAI,EAAE;SACN,KAAK,CAAC,IAAI,CAAC;SACX,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACjC,CAAC;AAED,SAAgB,oBAAoB,CAClC,aAAuB,EACvB,WAAqB;IAErB,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC;IAC3C,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAElE,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,+DAA+D,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACvF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { GovernanceState } from "../GovernedAction";
|
|
2
|
+
/**
|
|
3
|
+
* Throw governance violation if transition is not permitted
|
|
4
|
+
*/
|
|
5
|
+
export declare function assertTransition(from: GovernanceState, to: GovernanceState): void;
|
|
6
|
+
/**
|
|
7
|
+
* Check if a transition is valid (without throwing)
|
|
8
|
+
*/
|
|
9
|
+
export declare function canTransition(from: GovernanceState, to: GovernanceState): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Get all possible next states from current state
|
|
12
|
+
*/
|
|
13
|
+
export declare function getNextStates(from: GovernanceState): GovernanceState[];
|
|
14
|
+
/**
|
|
15
|
+
* Validate that a state is valid
|
|
16
|
+
*/
|
|
17
|
+
export declare function isValidState(state: string): state is GovernanceState;
|
|
18
|
+
/**
|
|
19
|
+
* State machine transition history entry
|
|
20
|
+
*/
|
|
21
|
+
export interface TransitionHistoryEntry {
|
|
22
|
+
from: GovernanceState;
|
|
23
|
+
to: GovernanceState;
|
|
24
|
+
timestamp: number;
|
|
25
|
+
reason?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* State machine for tracking governance state transitions
|
|
29
|
+
* Enforces constitutional invariants
|
|
30
|
+
*/
|
|
31
|
+
export declare class GovernanceStateMachine {
|
|
32
|
+
private currentState;
|
|
33
|
+
private history;
|
|
34
|
+
constructor(initialState: GovernanceState);
|
|
35
|
+
get current(): GovernanceState;
|
|
36
|
+
get transitionHistory(): TransitionHistoryEntry[];
|
|
37
|
+
transition(to: GovernanceState, reason?: string): void;
|
|
38
|
+
isTerminal(): boolean;
|
|
39
|
+
canProceedTo(state: GovernanceState): boolean;
|
|
40
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GovernanceStateMachine = void 0;
|
|
4
|
+
exports.assertTransition = assertTransition;
|
|
5
|
+
exports.canTransition = canTransition;
|
|
6
|
+
exports.getNextStates = getNextStates;
|
|
7
|
+
exports.isValidState = isValidState;
|
|
8
|
+
/**
|
|
9
|
+
* Only these state transitions are legally permitted
|
|
10
|
+
* Any other transition is a governance violation
|
|
11
|
+
*/
|
|
12
|
+
const ALLOWED_TRANSITIONS = {
|
|
13
|
+
DRAFT: ["PROPOSED"],
|
|
14
|
+
PROPOSED: ["APPROVED", "REJECTED"],
|
|
15
|
+
APPROVED: ["EXECUTED"],
|
|
16
|
+
EXECUTED: ["OBSERVED"],
|
|
17
|
+
OBSERVED: ["VERIFIED"],
|
|
18
|
+
VERIFIED: [],
|
|
19
|
+
REJECTED: [],
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Throw governance violation if transition is not permitted
|
|
23
|
+
*/
|
|
24
|
+
function assertTransition(from, to) {
|
|
25
|
+
const allowed = ALLOWED_TRANSITIONS[from].includes(to);
|
|
26
|
+
if (!allowed) {
|
|
27
|
+
throw new Error(`Governance violation: illegal state transition ${from} → ${to}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Check if a transition is valid (without throwing)
|
|
32
|
+
*/
|
|
33
|
+
function canTransition(from, to) {
|
|
34
|
+
return ALLOWED_TRANSITIONS[from].includes(to);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get all possible next states from current state
|
|
38
|
+
*/
|
|
39
|
+
function getNextStates(from) {
|
|
40
|
+
return [...ALLOWED_TRANSITIONS[from]];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Validate that a state is valid
|
|
44
|
+
*/
|
|
45
|
+
function isValidState(state) {
|
|
46
|
+
return [
|
|
47
|
+
"DRAFT",
|
|
48
|
+
"PROPOSED",
|
|
49
|
+
"APPROVED",
|
|
50
|
+
"EXECUTED",
|
|
51
|
+
"OBSERVED",
|
|
52
|
+
"VERIFIED",
|
|
53
|
+
"REJECTED",
|
|
54
|
+
].includes(state);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* State machine for tracking governance state transitions
|
|
58
|
+
* Enforces constitutional invariants
|
|
59
|
+
*/
|
|
60
|
+
class GovernanceStateMachine {
|
|
61
|
+
currentState;
|
|
62
|
+
history = [];
|
|
63
|
+
constructor(initialState) {
|
|
64
|
+
if (!isValidState(initialState)) {
|
|
65
|
+
throw new Error(`Invalid initial state: ${initialState}`);
|
|
66
|
+
}
|
|
67
|
+
this.currentState = initialState;
|
|
68
|
+
}
|
|
69
|
+
get current() {
|
|
70
|
+
return this.currentState;
|
|
71
|
+
}
|
|
72
|
+
get transitionHistory() {
|
|
73
|
+
return [...this.history];
|
|
74
|
+
}
|
|
75
|
+
transition(to, reason) {
|
|
76
|
+
assertTransition(this.currentState, to);
|
|
77
|
+
this.history.push({
|
|
78
|
+
from: this.currentState,
|
|
79
|
+
to,
|
|
80
|
+
timestamp: Date.now(),
|
|
81
|
+
reason,
|
|
82
|
+
});
|
|
83
|
+
this.currentState = to;
|
|
84
|
+
}
|
|
85
|
+
isTerminal() {
|
|
86
|
+
return this.currentState === "VERIFIED" || this.currentState === "REJECTED";
|
|
87
|
+
}
|
|
88
|
+
canProceedTo(state) {
|
|
89
|
+
return canTransition(this.currentState, state);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.GovernanceStateMachine = GovernanceStateMachine;
|
|
93
|
+
//# sourceMappingURL=stateMachine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stateMachine.js","sourceRoot":"","sources":["../../../src/governance/fsm/stateMachine.ts"],"names":[],"mappings":";;;AAmBA,4CAWC;AAKD,sCAKC;AAKD,sCAEC;AAKD,oCAUC;AA5DD;;;GAGG;AACH,MAAM,mBAAmB,GAA+C;IACtE,KAAK,EAAE,CAAC,UAAU,CAAC;IACnB,QAAQ,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC;IAClC,QAAQ,EAAE,CAAC,UAAU,CAAC;IACtB,QAAQ,EAAE,CAAC,UAAU,CAAC;IACtB,QAAQ,EAAE,CAAC,UAAU,CAAC;IACtB,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,EAAE;CACb,CAAC;AAEF;;GAEG;AACH,SAAgB,gBAAgB,CAC9B,IAAqB,EACrB,EAAmB;IAEnB,MAAM,OAAO,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAEvD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,kDAAkD,IAAI,MAAM,EAAE,EAAE,CACjE,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa,CAC3B,IAAqB,EACrB,EAAmB;IAEnB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;IAC9E,CAAC;IAED,YAAY,CAAC,KAAsB;QACjC,OAAO,aAAa,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IACjD,CAAC;CACF;AAvCD,wDAuCC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./GovernedAction";
|
|
2
|
+
export * from "./GovernanceEngine";
|
|
3
|
+
export * from "./actions/CodeChangeAction";
|
|
4
|
+
export * from "./fsm/stateMachine";
|
|
5
|
+
export * from "./review/diffParser";
|
|
6
|
+
export * from "./review/render";
|
|
7
|
+
export * from "./execution/sandbox";
|
|
8
|
+
export * from "./capability/token";
|
|
9
|
+
export * from "./storage/store";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./GovernedAction"), exports);
|
|
18
|
+
__exportStar(require("./GovernanceEngine"), exports);
|
|
19
|
+
__exportStar(require("./actions/CodeChangeAction"), exports);
|
|
20
|
+
__exportStar(require("./fsm/stateMachine"), exports);
|
|
21
|
+
__exportStar(require("./review/diffParser"), exports);
|
|
22
|
+
__exportStar(require("./review/render"), exports);
|
|
23
|
+
__exportStar(require("./execution/sandbox"), exports);
|
|
24
|
+
__exportStar(require("./capability/token"), exports);
|
|
25
|
+
__exportStar(require("./storage/store"), exports);
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/governance/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,qDAAmC;AACnC,6DAA2C;AAC3C,qDAAmC;AACnC,sDAAoC;AACpC,kDAAgC;AAChC,sDAAoC;AACpC,qDAAmC;AACnC,kDAAgC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface DiffFile {
|
|
2
|
+
file: string;
|
|
3
|
+
additions: number;
|
|
4
|
+
deletions: number;
|
|
5
|
+
hunks: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare function parseUnifiedDiff(diff: string): DiffFile[];
|
|
8
|
+
export declare function extractFilesFromDiff(diff: string): string[];
|
|
9
|
+
export declare function assessRisk(files: DiffFile[]): {
|
|
10
|
+
level: "low" | "medium" | "high";
|
|
11
|
+
warnings: string[];
|
|
12
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseUnifiedDiff = parseUnifiedDiff;
|
|
4
|
+
exports.extractFilesFromDiff = extractFilesFromDiff;
|
|
5
|
+
exports.assessRisk = assessRisk;
|
|
6
|
+
function parseUnifiedDiff(diff) {
|
|
7
|
+
const files = [];
|
|
8
|
+
let current = null;
|
|
9
|
+
for (const line of diff.split("\n")) {
|
|
10
|
+
if (line.startsWith("diff --git")) {
|
|
11
|
+
if (current) {
|
|
12
|
+
files.push(current);
|
|
13
|
+
}
|
|
14
|
+
const match = line.match(/b\/(.+)$/);
|
|
15
|
+
const file = match ? match[1] : "unknown";
|
|
16
|
+
current = { file, additions: 0, deletions: 0, hunks: [] };
|
|
17
|
+
}
|
|
18
|
+
else if (!current) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
else if (line.startsWith("+") && !line.startsWith("+++")) {
|
|
22
|
+
current.additions++;
|
|
23
|
+
}
|
|
24
|
+
else if (line.startsWith("-") && !line.startsWith("---")) {
|
|
25
|
+
current.deletions++;
|
|
26
|
+
}
|
|
27
|
+
else if (line.startsWith("@@")) {
|
|
28
|
+
current.hunks.push(line);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (current) {
|
|
32
|
+
files.push(current);
|
|
33
|
+
}
|
|
34
|
+
return files;
|
|
35
|
+
}
|
|
36
|
+
function extractFilesFromDiff(diff) {
|
|
37
|
+
const files = [];
|
|
38
|
+
const filePattern = /^\+\+\+ b\/(.+)$/m;
|
|
39
|
+
for (const match of diff.matchAll(filePattern)) {
|
|
40
|
+
files.push(match[1]);
|
|
41
|
+
}
|
|
42
|
+
return files;
|
|
43
|
+
}
|
|
44
|
+
function assessRisk(files) {
|
|
45
|
+
const warnings = [];
|
|
46
|
+
const totalLines = files.reduce((sum, f) => sum + f.additions + f.deletions, 0);
|
|
47
|
+
if (totalLines > 300) {
|
|
48
|
+
warnings.push(`Large changeset: ${totalLines} lines`);
|
|
49
|
+
}
|
|
50
|
+
if (files.length > 10) {
|
|
51
|
+
warnings.push(`Many files touched: ${files.length}`);
|
|
52
|
+
}
|
|
53
|
+
if (totalLines > 1000) {
|
|
54
|
+
return { level: "high", warnings };
|
|
55
|
+
}
|
|
56
|
+
if (totalLines > 300 || files.length > 10) {
|
|
57
|
+
return { level: "medium", warnings };
|
|
58
|
+
}
|
|
59
|
+
return { level: "low", warnings };
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=diffParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diffParser.js","sourceRoot":"","sources":["../../../src/governance/review/diffParser.ts"],"names":[],"mappings":";;A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