@red-codes/core 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/LICENSE +190 -0
  2. package/dist/actions.d.ts +11 -0
  3. package/dist/actions.d.ts.map +1 -0
  4. package/dist/actions.js +76 -0
  5. package/dist/actions.js.map +1 -0
  6. package/dist/adapters.d.ts +19 -0
  7. package/dist/adapters.d.ts.map +1 -0
  8. package/dist/adapters.js +85 -0
  9. package/dist/adapters.js.map +1 -0
  10. package/dist/crypto-hash.d.ts +11 -0
  11. package/dist/crypto-hash.d.ts.map +1 -0
  12. package/dist/crypto-hash.js +14 -0
  13. package/dist/crypto-hash.js.map +1 -0
  14. package/dist/data/actions.json +42 -0
  15. package/dist/data/blast-radius.json +36 -0
  16. package/dist/data/destructive-patterns.json +94 -0
  17. package/dist/data/escalation.json +13 -0
  18. package/dist/data/git-action-patterns.json +7 -0
  19. package/dist/data/invariant-patterns.json +48 -0
  20. package/dist/data/tool-action-map.json +14 -0
  21. package/dist/execution-log/bridge.d.ts +12 -0
  22. package/dist/execution-log/bridge.d.ts.map +1 -0
  23. package/dist/execution-log/bridge.js +112 -0
  24. package/dist/execution-log/bridge.js.map +1 -0
  25. package/dist/execution-log/event-log.d.ts +7 -0
  26. package/dist/execution-log/event-log.d.ts.map +1 -0
  27. package/dist/execution-log/event-log.js +103 -0
  28. package/dist/execution-log/event-log.js.map +1 -0
  29. package/dist/execution-log/event-projections.d.ts +28 -0
  30. package/dist/execution-log/event-projections.d.ts.map +1 -0
  31. package/dist/execution-log/event-projections.js +272 -0
  32. package/dist/execution-log/event-projections.js.map +1 -0
  33. package/dist/execution-log/event-schema.d.ts +56 -0
  34. package/dist/execution-log/event-schema.d.ts.map +1 -0
  35. package/dist/execution-log/event-schema.js +160 -0
  36. package/dist/execution-log/event-schema.js.map +1 -0
  37. package/dist/execution-log/index.d.ts +7 -0
  38. package/dist/execution-log/index.d.ts.map +1 -0
  39. package/dist/execution-log/index.js +13 -0
  40. package/dist/execution-log/index.js.map +1 -0
  41. package/dist/governance-data.d.ts +177 -0
  42. package/dist/governance-data.d.ts.map +1 -0
  43. package/dist/governance-data.js +53 -0
  44. package/dist/governance-data.js.map +1 -0
  45. package/dist/hash.d.ts +5 -0
  46. package/dist/hash.d.ts.map +1 -0
  47. package/dist/hash.js +13 -0
  48. package/dist/hash.js.map +1 -0
  49. package/dist/index.d.ts +13 -0
  50. package/dist/index.d.ts.map +1 -0
  51. package/dist/index.js +13 -0
  52. package/dist/index.js.map +1 -0
  53. package/dist/persona.d.ts +32 -0
  54. package/dist/persona.d.ts.map +1 -0
  55. package/dist/persona.js +138 -0
  56. package/dist/persona.js.map +1 -0
  57. package/dist/repo-root.d.ts +15 -0
  58. package/dist/repo-root.d.ts.map +1 -0
  59. package/dist/repo-root.js +56 -0
  60. package/dist/repo-root.js.map +1 -0
  61. package/dist/rng.d.ts +29 -0
  62. package/dist/rng.d.ts.map +1 -0
  63. package/dist/rng.js +48 -0
  64. package/dist/rng.js.map +1 -0
  65. package/dist/rtk.d.ts +22 -0
  66. package/dist/rtk.d.ts.map +1 -0
  67. package/dist/rtk.js +61 -0
  68. package/dist/rtk.js.map +1 -0
  69. package/dist/trust-store.d.ts +19 -0
  70. package/dist/trust-store.d.ts.map +1 -0
  71. package/dist/trust-store.js +98 -0
  72. package/dist/trust-store.js.map +1 -0
  73. package/dist/types.d.ts +849 -0
  74. package/dist/types.d.ts.map +1 -0
  75. package/dist/types.js +8 -0
  76. package/dist/types.js.map +1 -0
  77. package/package.json +34 -0
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 Jared Pleva
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
@@ -0,0 +1,11 @@
1
+ import type { ActionClass, ActionDefinition, Decision, CanonicalAction, ValidationResult } from './types.js';
2
+ export declare const ACTION_CLASS: Record<string, ActionClass>;
3
+ export declare const ACTION_TYPES: Record<string, ActionDefinition>;
4
+ export declare const DECISION: Record<string, Decision>;
5
+ export declare function resetActionCounter(): void;
6
+ export declare function validateActionType(type: string): ValidationResult;
7
+ export declare function validateAction(action: Record<string, unknown>): ValidationResult;
8
+ export declare function createAction(type: string, target: string, justification: string, metadata?: Record<string, unknown>): CanonicalAction;
9
+ export declare function getActionClass(type: string): ActionClass | null;
10
+ export declare function listActionTypes(): string[];
11
+ //# sourceMappingURL=actions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,WAAW,EACX,gBAAgB,EAChB,QAAQ,EACR,eAAe,EACf,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAMpB,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAGpD,CAAC;AAGF,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAGzD,CAAC;AAGF,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAA6C,CAAC;AAK5F,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AAUD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAWjE;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,gBAAgB,CAuBhF;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACrC,eAAe,CAejB;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAG/D;AAED,wBAAgB,eAAe,IAAI,MAAM,EAAE,CAE1C"}
@@ -0,0 +1,76 @@
1
+ // Canonical action schema for the Agent Reference Monitor
2
+ // All agent execution requests are normalized into these action objects.
3
+ // No DOM, no Node.js APIs — pure data definitions.
4
+ import { simpleHash } from './hash.js';
5
+ // --- Action Classes (sourced from data/actions.json) ---
6
+ import { ACTION_CLASS_DATA, ACTION_TYPES_DATA, DECISION_DATA } from './governance-data.js';
7
+ export const ACTION_CLASS = ACTION_CLASS_DATA;
8
+ // --- Action Types (sourced from data/actions.json) ---
9
+ export const ACTION_TYPES = ACTION_TYPES_DATA;
10
+ // --- Decisions (sourced from data/actions.json) ---
11
+ export const DECISION = DECISION_DATA;
12
+ // --- Action Factory ---
13
+ let actionCounter = 0;
14
+ export function resetActionCounter() {
15
+ actionCounter = 0;
16
+ }
17
+ function generateActionId(timestamp) {
18
+ return `act_${timestamp}_${++actionCounter}`;
19
+ }
20
+ function fingerprintAction(type, target, justification) {
21
+ return simpleHash(`${type}:${target}:${justification}`);
22
+ }
23
+ export function validateActionType(type) {
24
+ const errors = [];
25
+ if (typeof type !== 'string' || !type) {
26
+ errors.push('Action type must be a non-empty string');
27
+ return { valid: false, errors };
28
+ }
29
+ if (!ACTION_TYPES[type]) {
30
+ errors.push(`Unknown action type: ${type}`);
31
+ return { valid: false, errors };
32
+ }
33
+ return { valid: true, errors };
34
+ }
35
+ export function validateAction(action) {
36
+ const errors = [];
37
+ if (!action || typeof action !== 'object') {
38
+ return { valid: false, errors: ['Action must be a non-null object'] };
39
+ }
40
+ if (!action.type) {
41
+ errors.push('Action is missing required field: type');
42
+ }
43
+ else {
44
+ const typeCheck = validateActionType(action.type);
45
+ if (!typeCheck.valid)
46
+ errors.push(...typeCheck.errors);
47
+ }
48
+ if (!action.target && action.target !== '') {
49
+ errors.push('Action is missing required field: target');
50
+ }
51
+ if (!action.justification) {
52
+ errors.push('Action is missing required field: justification');
53
+ }
54
+ return { valid: errors.length === 0, errors };
55
+ }
56
+ export function createAction(type, target, justification, metadata = {}) {
57
+ const action = { type, target, justification, ...metadata };
58
+ const { valid, errors } = validateAction(action);
59
+ if (!valid) {
60
+ throw new Error(`Invalid action: ${errors.join('; ')}`);
61
+ }
62
+ const timestamp = Date.now();
63
+ action.id = generateActionId(timestamp);
64
+ action.class = ACTION_TYPES[type].class;
65
+ action.timestamp = timestamp;
66
+ action.fingerprint = fingerprintAction(type, target, justification);
67
+ return action;
68
+ }
69
+ export function getActionClass(type) {
70
+ const def = ACTION_TYPES[type];
71
+ return def ? def.class : null;
72
+ }
73
+ export function listActionTypes() {
74
+ return Object.keys(ACTION_TYPES);
75
+ }
76
+ //# sourceMappingURL=actions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,yEAAyE;AACzE,mDAAmD;AASnD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,0DAA0D;AAC1D,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE3F,MAAM,CAAC,MAAM,YAAY,GAAgC,iBAGxD,CAAC;AAEF,wDAAwD;AACxD,MAAM,CAAC,MAAM,YAAY,GAAqC,iBAG7D,CAAC;AAEF,qDAAqD;AACrD,MAAM,CAAC,MAAM,QAAQ,GAA6B,aAAyC,CAAC;AAE5F,yBAAyB;AACzB,IAAI,aAAa,GAAG,CAAC,CAAC;AAEtB,MAAM,UAAU,kBAAkB;IAChC,aAAa,GAAG,CAAC,CAAC;AACpB,CAAC;AAED,SAAS,gBAAgB,CAAC,SAAiB;IACzC,OAAO,OAAO,SAAS,IAAI,EAAE,aAAa,EAAE,CAAC;AAC/C,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAY,EAAE,MAAc,EAAE,aAAqB;IAC5E,OAAO,UAAU,CAAC,GAAG,IAAI,IAAI,MAAM,IAAI,aAAa,EAAE,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QACtC,MAAM,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;QACtD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAClC,CAAC;IACD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,MAA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,aAAa,EAAE,GAAG,QAAQ,EAAE,CAAC;IAErF,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IACjD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,MAAM,CAAC,EAAE,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC;IACxC,MAAM,CAAC,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC;IACxC,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,MAAM,CAAC,WAAW,GAAG,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;IAEpE,OAAO,MAAoC,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAC/B,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AACnC,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { AdapterHandler, AdapterRegistry } from './types.js';
2
+ export declare function createAdapterRegistry(): AdapterRegistry;
3
+ interface DryRunEntry {
4
+ type: string;
5
+ target: string;
6
+ timestamp: number;
7
+ dryRun: true;
8
+ }
9
+ export declare function createDryRunAdapter(): {
10
+ adapter: AdapterHandler;
11
+ getLog: () => DryRunEntry[];
12
+ clear: () => void;
13
+ };
14
+ export declare function createDryRunRegistry(): {
15
+ registry: AdapterRegistry;
16
+ dryRun: ReturnType<typeof createDryRunAdapter>;
17
+ };
18
+ export {};
19
+ //# sourceMappingURL=adapters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapters.d.ts","sourceRoot":"","sources":["../src/adapters.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAIV,cAAc,EACd,eAAe,EAChB,MAAM,YAAY,CAAC;AAKpB,wBAAgB,qBAAqB,IAAI,eAAe,CA0DvD;AAID,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,IAAI,CAAC;CACd;AAED,wBAAgB,mBAAmB,IAAI;IACrC,OAAO,EAAE,cAAc,CAAC;IACxB,MAAM,EAAE,MAAM,WAAW,EAAE,CAAC;IAC5B,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAqBA;AAED,wBAAgB,oBAAoB,IAAI;IACtC,QAAQ,EAAE,eAAe,CAAC;IAC1B,MAAM,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;CAChD,CAUA"}
@@ -0,0 +1,85 @@
1
+ // Execution adapters for the Agent Reference Monitor
2
+ // Adapters translate authorized action objects into executable operations.
3
+ // Each adapter validates that an action has been authorized before proceeding.
4
+ // No DOM, no Node.js APIs — pure adapter interfaces and registry.
5
+ import { DECISION } from './actions.js';
6
+ // --- Adapter Registry ---
7
+ export function createAdapterRegistry() {
8
+ const adapters = new Map();
9
+ function register(actionClass, handler) {
10
+ if (typeof handler !== 'function') {
11
+ throw new Error(`Adapter handler must be a function for class: ${actionClass}`);
12
+ }
13
+ adapters.set(actionClass, handler);
14
+ }
15
+ async function execute(action, decisionRecord) {
16
+ if (!decisionRecord || decisionRecord.decision !== DECISION.ALLOW) {
17
+ return {
18
+ success: false,
19
+ error: `Action not authorized: ${decisionRecord ? decisionRecord.decision : 'no decision'}`,
20
+ };
21
+ }
22
+ if (decisionRecord.actionId !== action.id) {
23
+ return {
24
+ success: false,
25
+ error: `Decision record does not match action (expected ${action.id}, got ${decisionRecord.actionId})`,
26
+ };
27
+ }
28
+ const adapter = adapters.get(action.class);
29
+ if (!adapter) {
30
+ return {
31
+ success: false,
32
+ error: `No adapter registered for action class: ${action.class}`,
33
+ };
34
+ }
35
+ try {
36
+ const result = await adapter(action);
37
+ return { success: true, result };
38
+ }
39
+ catch (err) {
40
+ return { success: false, error: err.message };
41
+ }
42
+ }
43
+ function has(actionClass) {
44
+ return adapters.has(actionClass);
45
+ }
46
+ function listRegistered() {
47
+ return [...adapters.keys()];
48
+ }
49
+ return Object.freeze({
50
+ register,
51
+ execute,
52
+ has,
53
+ listRegistered,
54
+ });
55
+ }
56
+ export function createDryRunAdapter() {
57
+ const log = [];
58
+ const adapter = (action) => {
59
+ const entry = {
60
+ type: action.type,
61
+ target: action.target,
62
+ timestamp: Date.now(),
63
+ dryRun: true,
64
+ };
65
+ log.push(entry);
66
+ return entry;
67
+ };
68
+ return {
69
+ adapter,
70
+ getLog: () => [...log],
71
+ clear: () => {
72
+ log.length = 0;
73
+ },
74
+ };
75
+ }
76
+ export function createDryRunRegistry() {
77
+ const registry = createAdapterRegistry();
78
+ const dryRun = createDryRunAdapter();
79
+ const classes = ['file', 'test', 'git', 'shell', 'npm', 'http', 'deploy', 'infra'];
80
+ for (const cls of classes) {
81
+ registry.register(cls, dryRun.adapter);
82
+ }
83
+ return { registry, dryRun };
84
+ }
85
+ //# sourceMappingURL=adapters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapters.js","sourceRoot":"","sources":["../src/adapters.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,2EAA2E;AAC3E,+EAA+E;AAC/E,kEAAkE;AASlE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,2BAA2B;AAE3B,MAAM,UAAU,qBAAqB;IACnC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA0B,CAAC;IAEnD,SAAS,QAAQ,CAAC,WAAmB,EAAE,OAAuB;Q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OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Cryptographic SHA-256 for integrity verification.
3
+ * Use for trust store, hook integrity, policy trust.
4
+ * Returns lowercase 64-character hex digest.
5
+ *
6
+ * NOTE: This is separate from simpleHash() in hash.ts which is a
7
+ * non-cryptographic djb2 hash for event fingerprinting. Do NOT
8
+ * replace simpleHash calls with this — it would break event IDs.
9
+ */
10
+ export declare function computeSHA256(content: string | Buffer): string;
11
+ //# sourceMappingURL=crypto-hash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto-hash.d.ts","sourceRoot":"","sources":["../src/crypto-hash.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAE9D"}
@@ -0,0 +1,14 @@
1
+ import { createHash } from 'node:crypto';
2
+ /**
3
+ * Cryptographic SHA-256 for integrity verification.
4
+ * Use for trust store, hook integrity, policy trust.
5
+ * Returns lowercase 64-character hex digest.
6
+ *
7
+ * NOTE: This is separate from simpleHash() in hash.ts which is a
8
+ * non-cryptographic djb2 hash for event fingerprinting. Do NOT
9
+ * replace simpleHash calls with this — it would break event IDs.
10
+ */
11
+ export function computeSHA256(content) {
12
+ return createHash('sha256').update(content).digest('hex');
13
+ }
14
+ //# sourceMappingURL=crypto-hash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto-hash.js","sourceRoot":"","sources":["../src/crypto-hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAC,OAAwB;IACpD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC5D,CAAC"}
@@ -0,0 +1,42 @@
1
+ {
2
+ "classes": {
3
+ "FILE": "file",
4
+ "TEST": "test",
5
+ "GIT": "git",
6
+ "SHELL": "shell",
7
+ "NPM": "npm",
8
+ "HTTP": "http",
9
+ "DEPLOY": "deploy",
10
+ "INFRA": "infra"
11
+ },
12
+ "types": {
13
+ "file.read": { "class": "file", "description": "Read file contents" },
14
+ "file.write": { "class": "file", "description": "Write or create a file" },
15
+ "file.delete": { "class": "file", "description": "Delete a file" },
16
+ "file.move": { "class": "file", "description": "Move or rename a file" },
17
+ "test.run": { "class": "test", "description": "Run test suite" },
18
+ "test.run.unit": { "class": "test", "description": "Run unit tests" },
19
+ "test.run.integration": { "class": "test", "description": "Run integration tests" },
20
+ "git.diff": { "class": "git", "description": "View git diff" },
21
+ "git.commit": { "class": "git", "description": "Create a git commit" },
22
+ "git.push": { "class": "git", "description": "Push to remote" },
23
+ "git.branch.create": { "class": "git", "description": "Create a branch" },
24
+ "git.branch.delete": { "class": "git", "description": "Delete a branch" },
25
+ "git.checkout": { "class": "git", "description": "Switch branches" },
26
+ "git.reset": { "class": "git", "description": "Reset git state" },
27
+ "git.merge": { "class": "git", "description": "Merge branches" },
28
+ "shell.exec": { "class": "shell", "description": "Execute a shell command" },
29
+ "npm.install": { "class": "npm", "description": "Install npm packages" },
30
+ "npm.script.run": { "class": "npm", "description": "Run an npm script" },
31
+ "npm.publish": { "class": "npm", "description": "Publish to npm registry" },
32
+ "http.request": { "class": "http", "description": "Make an HTTP request" },
33
+ "deploy.trigger": { "class": "deploy", "description": "Trigger deployment" },
34
+ "infra.apply": { "class": "infra", "description": "Apply infrastructure changes" },
35
+ "infra.destroy": { "class": "infra", "description": "Destroy infrastructure" }
36
+ },
37
+ "decisions": {
38
+ "ALLOW": "allow",
39
+ "DENY": "deny",
40
+ "ESCALATE": "escalate"
41
+ }
42
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "defaultWeights": {
3
+ "delete": 3.0,
4
+ "write": 1.5,
5
+ "read": 0.1,
6
+ "git": 2.0,
7
+ "shell": 1.0,
8
+ "sensitivePath": 5.0,
9
+ "configPath": 2.0,
10
+ "destructive": 4.0
11
+ },
12
+ "sensitivePatterns": [".env", "credentials", ".pem", ".key", "secret", "token", ".password"],
13
+ "configPatterns": [
14
+ "package.json",
15
+ "tsconfig.json",
16
+ "eslint",
17
+ ".prettierrc",
18
+ "webpack.config",
19
+ "vite.config",
20
+ "next.config",
21
+ "jest.config",
22
+ "vitest.config",
23
+ ".babelrc",
24
+ "babel.config",
25
+ "Dockerfile",
26
+ "docker-compose",
27
+ ".github/",
28
+ ".gitlab-ci",
29
+ "Jenkinsfile",
30
+ ".circleci/"
31
+ ],
32
+ "riskThresholds": {
33
+ "high": 50,
34
+ "medium": 15
35
+ }
36
+ }
@@ -0,0 +1,94 @@
1
+ [
2
+ { "pattern": "\\brm\\s+-rf\\b", "description": "Recursive force delete", "riskLevel": "critical", "category": "filesystem" },
3
+ { "pattern": "\\brm\\s+-r\\b", "description": "Recursive delete", "riskLevel": "critical", "category": "filesystem" },
4
+ { "pattern": "\\brm\\s+--recursive\\b", "description": "Recursive delete (long flag)", "riskLevel": "critical", "category": "filesystem" },
5
+ { "pattern": "\\bmkfs\\b", "description": "Create filesystem (erases partition)", "riskLevel": "critical", "category": "filesystem" },
6
+ { "pattern": ">\\s*\\/dev\\/sd[a-z]", "description": "Direct write to block device", "riskLevel": "critical", "category": "filesystem" },
7
+ { "pattern": "\\bdd\\s+if=", "description": "Low-level disk copy (can overwrite devices)", "riskLevel": "critical", "category": "filesystem" },
8
+ { "pattern": "\\bshred\\b", "description": "Secure file deletion (irrecoverable)", "riskLevel": "critical", "category": "filesystem" },
9
+ { "pattern": "\\bfdisk\\b", "description": "Partition table manipulation", "riskLevel": "critical", "category": "filesystem" },
10
+ { "pattern": "\\bsudo\\s+rm\\b", "description": "Privileged file deletion", "riskLevel": "critical", "category": "system" },
11
+ { "pattern": "\\bsudo\\s+", "description": "Privileged command execution", "riskLevel": "high", "category": "system" },
12
+ { "pattern": "\\bsu\\s+-?\\s*\\w*", "description": "Switch user (privilege escalation)", "riskLevel": "high", "category": "system" },
13
+ { "pattern": "\\bchmod\\s+777\\b", "description": "World-writable permissions", "riskLevel": "high", "category": "system" },
14
+ { "pattern": "\\bchown\\s+", "description": "Change file ownership", "riskLevel": "high", "category": "system" },
15
+ { "pattern": "\\bkill\\s+-9\\b", "description": "Force kill process (SIGKILL)", "riskLevel": "high", "category": "process" },
16
+ { "pattern": "\\bpkill\\b", "description": "Kill processes by name", "riskLevel": "high", "category": "process" },
17
+ { "pattern": "\\bkillall\\b", "description": "Kill all processes by name", "riskLevel": "high", "category": "process" },
18
+ { "pattern": "\\bdocker\\s+rm\\b", "description": "Remove Docker container", "riskLevel": "high", "category": "container" },
19
+ { "pattern": "\\bdocker\\s+rmi\\b", "description": "Remove Docker image", "riskLevel": "high", "category": "container" },
20
+ { "pattern": "\\bdocker\\s+system\\s+prune\\b", "description": "Prune all unused Docker resources", "riskLevel": "critical", "category": "container" },
21
+ { "pattern": "\\bsystemctl\\s+stop\\b", "description": "Stop system service", "riskLevel": "high", "category": "service" },
22
+ { "pattern": "\\bsystemctl\\s+disable\\b", "description": "Disable system service", "riskLevel": "high", "category": "service" },
23
+ { "pattern": "\\bservice\\s+\\S+\\s+stop\\b", "description": "Stop system service (SysV)", "riskLevel": "high", "category": "service" },
24
+ { "pattern": "\\bdropdb\\b", "description": "Drop PostgreSQL database", "riskLevel": "critical", "category": "database" },
25
+ { "pattern": "\\bDROP\\s+DATABASE\\b", "description": "Drop database (SQL)", "riskLevel": "critical", "category": "database", "flags": "i" },
26
+ { "pattern": "\\bDROP\\s+TABLE\\b", "description": "Drop table (SQL)", "riskLevel": "critical", "category": "database", "flags": "i" },
27
+ { "pattern": "\\bTRUNCATE\\b", "description": "Truncate table (delete all rows)", "riskLevel": "critical", "category": "database", "flags": "i" },
28
+ { "pattern": "\\bDELETE\\s+FROM\\s+\\S+\\s*(?:;|\\s*$)", "description": "Delete all rows (no WHERE clause)", "riskLevel": "critical", "category": "database", "flags": "i" },
29
+ { "pattern": "\\bapt\\s+(?:remove|purge)\\b", "description": "Remove system package (apt)", "riskLevel": "high", "category": "package" },
30
+ { "pattern": "\\bnpm\\s+uninstall\\s+-g\\b", "description": "Uninstall global npm package", "riskLevel": "high", "category": "package" },
31
+ { "pattern": "\\bpip\\s+uninstall\\b", "description": "Uninstall Python package", "riskLevel": "high", "category": "package" },
32
+ { "pattern": "\\biptables\\s+-F\\b", "description": "Flush all firewall rules", "riskLevel": "critical", "category": "network" },
33
+ { "pattern": "\\bufw\\s+disable\\b", "description": "Disable firewall", "riskLevel": "critical", "category": "network" },
34
+ { "pattern": "\\bdocker\\s+stop\\b", "description": "Stop Docker container", "riskLevel": "high", "category": "container" },
35
+ { "pattern": "\\bdocker\\s+volume\\s+rm\\b", "description": "Remove Docker volume (data loss)", "riskLevel": "critical", "category": "container" },
36
+ { "pattern": "\\bdocker\\s+volume\\s+prune\\b", "description": "Prune all unused Docker volumes", "riskLevel": "critical", "category": "container" },
37
+ { "pattern": "\\bdocker\\s+network\\s+rm\\b", "description": "Remove Docker network", "riskLevel": "high", "category": "container" },
38
+ { "pattern": "\\bdocker[\\s-]compose\\s+down\\b", "description": "Tear down Docker Compose services", "riskLevel": "high", "category": "container" },
39
+ { "pattern": "\\bkubectl\\s+delete\\b", "description": "Delete Kubernetes resources", "riskLevel": "high", "category": "container" },
40
+ { "pattern": "\\bterraform\\s+destroy\\b", "description": "Destroy Terraform-managed infrastructure", "riskLevel": "critical", "category": "infra" },
41
+ { "pattern": "\\bDROP\\s+SCHEMA\\b", "description": "Drop database schema (SQL)", "riskLevel": "critical", "category": "database", "flags": "i" },
42
+ { "pattern": "\\bDROP\\s+VIEW\\b", "description": "Drop view (SQL)", "riskLevel": "high", "category": "database", "flags": "i" },
43
+ { "pattern": "\\bDROP\\s+INDEX\\b", "description": "Drop index (SQL)", "riskLevel": "high", "category": "database", "flags": "i" },
44
+ { "pattern": "\\bFLUSHALL\\b", "description": "Flush all Redis databases", "riskLevel": "critical", "category": "database" },
45
+ { "pattern": "\\bFLUSHDB\\b", "description": "Flush current Redis database", "riskLevel": "critical", "category": "database" },
46
+ { "pattern": "\\bbrew\\s+(?:uninstall|remove)\\b", "description": "Remove macOS package (Homebrew)", "riskLevel": "high", "category": "package" },
47
+ { "pattern": "\\bgem\\s+uninstall\\b", "description": "Uninstall Ruby gem", "riskLevel": "high", "category": "package" },
48
+ { "pattern": "\\byarn\\s+global\\s+remove\\b", "description": "Remove global Yarn package", "riskLevel": "high", "category": "package" },
49
+ { "pattern": "\\bcurl\\s+.*\\|\\s*(?:ba)?sh\\b", "description": "Pipe remote content to shell (code execution)", "riskLevel": "critical", "category": "network" },
50
+ { "pattern": "\\bwget\\s+.*\\|\\s*(?:ba)?sh\\b", "description": "Pipe remote download to shell (code execution)", "riskLevel": "critical", "category": "network" },
51
+ { "pattern": "\\bgit\\s+reset\\s+--hard\\b", "description": "Discard all uncommitted changes", "riskLevel": "high", "category": "filesystem" },
52
+ { "pattern": "\\bgit\\s+clean\\s+-[fdxX]+\\b", "description": "Remove untracked files from working tree", "riskLevel": "high", "category": "filesystem" },
53
+ { "pattern": "\\bcrontab\\s+-r\\b", "description": "Remove all cron jobs for current user", "riskLevel": "high", "category": "system" },
54
+ { "pattern": "\\bdoas\\s+", "description": "Privileged command execution (OpenBSD)", "riskLevel": "high", "category": "system" },
55
+ { "pattern": "\\bxkill\\b", "description": "Kill X11 window process", "riskLevel": "high", "category": "process" },
56
+ { "pattern": "\\bdocker\\s+container\\s+prune\\b", "description": "Prune all stopped Docker containers", "riskLevel": "high", "category": "container" },
57
+ { "pattern": "\\bdocker\\s+image\\s+prune\\b", "description": "Prune dangling Docker images", "riskLevel": "high", "category": "container" },
58
+ { "pattern": "\\bhelm\\s+(?:uninstall|delete)\\b", "description": "Remove Kubernetes Helm release", "riskLevel": "high", "category": "container" },
59
+ { "pattern": "\\bsystemctl\\s+mask\\b", "description": "Permanently prevent service from starting", "riskLevel": "high", "category": "service" },
60
+ { "pattern": "\\bALTER\\s+TABLE\\s+\\S+\\s+DROP\\b", "description": "Drop column or constraint (SQL)", "riskLevel": "high", "category": "database", "flags": "i" },
61
+ { "pattern": "\\bdb\\.dropDatabase\\s*\\(", "description": "Drop MongoDB database", "riskLevel": "critical", "category": "database" },
62
+ { "pattern": "\\bdb\\.\\w+\\.drop\\s*\\(", "description": "Drop MongoDB collection", "riskLevel": "critical", "category": "database" },
63
+ { "pattern": "\\b(?:dnf|yum)\\s+(?:remove|erase)\\b", "description": "Remove RPM package (dnf/yum)", "riskLevel": "high", "category": "package" },
64
+ { "pattern": "\\bpacman\\s+-R", "description": "Remove Arch Linux package", "riskLevel": "high", "category": "package" },
65
+ { "pattern": "\\bsnap\\s+remove\\b", "description": "Remove Snap package", "riskLevel": "high", "category": "package" },
66
+ { "pattern": "\\bcargo\\s+uninstall\\b", "description": "Uninstall Rust crate", "riskLevel": "high", "category": "package" },
67
+ { "pattern": "\\bpnpm\\s+(?:remove|uninstall)\\s+-g\\b", "description": "Uninstall global pnpm package", "riskLevel": "high", "category": "package" },
68
+ { "pattern": "\\bpulumi\\s+destroy\\b", "description": "Destroy Pulumi-managed infrastructure", "riskLevel": "critical", "category": "infra" },
69
+ { "pattern": "\\bgit\\s+stash\\s+drop\\b", "description": "Drop stashed changes", "riskLevel": "high", "category": "filesystem" },
70
+ { "pattern": "\\bgit\\s+reflog\\s+expire\\b", "description": "Expire reflog entries (history loss)", "riskLevel": "high", "category": "filesystem" },
71
+ { "pattern": "\\biptables\\s+-X\\b", "description": "Delete user-defined firewall chains", "riskLevel": "high", "category": "network" },
72
+ { "pattern": "\\bnft\\s+flush\\s+ruleset\\b", "description": "Flush all nftables rules", "riskLevel": "critical", "category": "network" },
73
+ { "pattern": "\\bshutdown\\b", "description": "System shutdown", "riskLevel": "critical", "category": "system" },
74
+ { "pattern": "\\breboot\\b", "description": "System reboot", "riskLevel": "high", "category": "system" },
75
+ { "pattern": "\\bpoweroff\\b", "description": "System power off", "riskLevel": "critical", "category": "system" },
76
+ { "pattern": "\\bhalt\\b", "description": "System halt", "riskLevel": "critical", "category": "system" },
77
+ { "pattern": "\\binit\\s+[06]\\b", "description": "Change system runlevel (shutdown/reboot)", "riskLevel": "critical", "category": "system" },
78
+ { "pattern": "\\bnpm\\s+unpublish\\b", "description": "Unpublish npm package (removes from registry)", "riskLevel": "critical", "category": "package" },
79
+ { "pattern": "\\bkubectl\\s+drain\\b", "description": "Drain Kubernetes node (evict all pods)", "riskLevel": "high", "category": "container" },
80
+ { "pattern": "\\bdocker\\s+swarm\\s+leave\\b", "description": "Leave Docker swarm cluster", "riskLevel": "high", "category": "container" },
81
+ { "pattern": "\\baws\\s+s3\\s+rb\\b", "description": "Remove AWS S3 bucket", "riskLevel": "critical", "category": "infra" },
82
+ { "pattern": "\\baws\\s+s3\\s+rm\\s+.*--recursive\\b", "description": "Recursively delete AWS S3 objects", "riskLevel": "critical", "category": "infra" },
83
+ { "pattern": "\\baws\\s+ec2\\s+terminate-instances\\b", "description": "Terminate AWS EC2 instances", "riskLevel": "critical", "category": "infra" },
84
+ { "pattern": "\\bgcloud\\s+compute\\s+instances\\s+delete\\b", "description": "Delete GCP Compute Engine instances", "riskLevel": "critical", "category": "infra" },
85
+ { "pattern": "\\baz\\s+vm\\s+delete\\b", "description": "Delete Azure virtual machines", "riskLevel": "critical", "category": "infra" },
86
+ { "pattern": "\\bpg_dropcluster\\b", "description": "Drop PostgreSQL cluster", "riskLevel": "critical", "category": "database" },
87
+ { "pattern": "\\bDROP\\s+KEYSPACE\\b", "description": "Drop Cassandra keyspace", "riskLevel": "critical", "category": "database", "flags": "i" },
88
+ { "pattern": "\\bgit\\s+filter-branch\\b", "description": "Rewrite git history (destructive)", "riskLevel": "critical", "category": "filesystem" },
89
+ { "pattern": "\\bkill\\s+\\d", "description": "Kill process by PID", "riskLevel": "high", "category": "process" },
90
+ { "pattern": "\\bsystemctl\\s+restart\\b", "description": "Restart system service", "riskLevel": "high", "category": "service" },
91
+ { "pattern": "\\bchmod\\s+-R\\b", "description": "Recursive permission change", "riskLevel": "high", "category": "system" },
92
+ { "pattern": "\\bnpm\\s+publish\\b", "description": "Publish npm package (irreversible public release)", "riskLevel": "high", "category": "package" },
93
+ { "pattern": "\\bdocker\\s+kill\\b", "description": "Force kill Docker container", "riskLevel": "high", "category": "container" }
94
+ ]