@aria_asi/cli 0.2.10 → 0.2.12
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/aria-connector/src/connectors/claude-code.d.ts.map +1 -1
- package/dist/aria-connector/src/connectors/claude-code.js +67 -4
- package/dist/aria-connector/src/connectors/claude-code.js.map +1 -1
- package/dist/sdk/BUNDLED.json +5 -0
- package/dist/sdk/index.d.ts +88 -0
- package/dist/sdk/index.js +403 -0
- package/dist/sdk/index.js.map +1 -0
- package/dist/sdk/package.json +8 -0
- package/hooks/aria-harness-via-sdk.mjs +46 -12
- package/hooks/aria-pre-tool-gate.mjs +61 -1
- package/hooks/aria-preprompt-consult.mjs +58 -18
- package/hooks/aria-stop-gate.mjs +215 -26
- package/hooks/aria-trigger-autolearn.mjs +230 -0
- package/hooks/doctrine_trigger_map.json +54 -0
- package/package.json +2 -2
- package/src/connectors/claude-code.ts +66 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AA+DhD,8EAA8E;AAE9E,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;0IA4BiH,CAAC;AAE3I,8EAA8E;AAE9E,MAAM,OAAO,iBAAiB;IACpB,MAAM,CAAC,QAAQ,GAA6B,IAAI,CAAC;IAExC,OAAO,CAAS;IAChB,MAAM,CAAS;IACf,gBAAgB,CAAS;IACzB,aAAa,CAAS;IAC/B,YAAY,GAAyB,IAAI,CAAC;IAC1C,iBAAiB,GAAW,CAAC,CAAC;IACrB,WAAW,GAAW,MAAM,CAAC;IAE9C,YAAY,MAA2B;QACrC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MA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AC;;AAGH,+BAA+B;AAC/B,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,WAAW,EAAE,iBAAiB,CAAC,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC;IAClE,aAAa,EAAE,iBAAiB,CAAC,aAAa,CAAC,IAAI,CAAC,iBAAiB,CAAC;CACvE,CAAC"}
|
|
@@ -148,20 +148,54 @@ function buildUrlList() {
|
|
|
148
148
|
return list.filter((u) => (seen.has(u) ? false : (seen.add(u), true)));
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
+
// SDK loader — dynamic-import the bundled HTTPHarnessClient from
|
|
152
|
+
// ~/.claude/aria-sdk/index.js (installed by `aria connect claude-code`).
|
|
153
|
+
// Module-cached after first load so we don't repeatedly read disk.
|
|
154
|
+
//
|
|
155
|
+
// Doctrine (Hamza 2026-04-27): "isnt http harness client the fucking harness
|
|
156
|
+
// we hsve been wprking on? YOU ARENT USING THAT AND BUILDING SPMETHING
|
|
157
|
+
// SEPERATE WHY???!!" — SDK is the canonical control plane. Direct fetch
|
|
158
|
+
// remains as a fallback only when the SDK file is physically missing
|
|
159
|
+
// (dev install without `aria connect claude-code`).
|
|
160
|
+
let _SdkClassCache = null;
|
|
161
|
+
let _SdkLookupAttempted = false;
|
|
162
|
+
async function loadSdkClass() {
|
|
163
|
+
if (_SdkClassCache) return _SdkClassCache;
|
|
164
|
+
if (_SdkLookupAttempted) return null;
|
|
165
|
+
_SdkLookupAttempted = true;
|
|
166
|
+
const sdkPath = `${HOME}/.claude/aria-sdk/index.js`;
|
|
167
|
+
if (!existsSync(sdkPath)) return null;
|
|
168
|
+
try {
|
|
169
|
+
const mod = await import(`file://${sdkPath}`);
|
|
170
|
+
if (mod.HTTPHarnessClient) {
|
|
171
|
+
_SdkClassCache = mod.HTTPHarnessClient;
|
|
172
|
+
return _SdkClassCache;
|
|
173
|
+
}
|
|
174
|
+
} catch {/* fall through to direct fetch */}
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
|
|
151
178
|
async function tryViaSdk(baseUrl, apiKey) {
|
|
152
|
-
//
|
|
153
|
-
//
|
|
154
|
-
//
|
|
155
|
-
//
|
|
156
|
-
//
|
|
157
|
-
//
|
|
158
|
-
|
|
179
|
+
// Canonical path: HTTPHarnessClient.getHarnessPacket(). The SDK POSTs to
|
|
180
|
+
// /api/harness/codex with the right shape and returns { packet, timestamp,
|
|
181
|
+
// version }. We extract .packet to get the raw response body that
|
|
182
|
+
// renderPacket() expects (codex.ts returns { harness, preStateGate,
|
|
183
|
+
// contractGate, ... } at top level — no nested .packet wrapper, so the
|
|
184
|
+
// SDK's `body.packet ?? body` passes the body through unchanged).
|
|
185
|
+
const Cls = await loadSdkClass();
|
|
186
|
+
if (Cls) {
|
|
187
|
+
const client = new Cls({
|
|
188
|
+
baseUrl,
|
|
189
|
+
apiKey,
|
|
190
|
+
harnessPacketUrl: `${baseUrl}/api/harness/codex`,
|
|
191
|
+
});
|
|
192
|
+
const wrapped = await client.getHarnessPacket();
|
|
193
|
+
const json = wrapped.packet;
|
|
194
|
+
if (json && json.ok === false) throw new Error(`ok=false: ${json.error || 'unknown'}`);
|
|
195
|
+
return { json, raw: JSON.stringify(json) };
|
|
196
|
+
}
|
|
159
197
|
|
|
160
|
-
//
|
|
161
|
-
// is POST. Bypass via direct fetch since the SDK doesn't expose body
|
|
162
|
-
// customization; the SDK's caching + error handling apply once we cache
|
|
163
|
-
// manually below. No AbortSignal — doctrine: error detection drives control
|
|
164
|
-
// flow, not deadlines. Real network errors arrive via promise rejection.
|
|
198
|
+
// SDK absent (dev environment) — direct fetch with identical wire shape.
|
|
165
199
|
const resp = await fetch(`${baseUrl}/api/harness/codex`, {
|
|
166
200
|
method: 'POST',
|
|
167
201
|
headers: {
|
|
@@ -336,7 +336,26 @@ function detectCognitionLenses(text) {
|
|
|
336
336
|
/feedback_[a-z0-9_]+\.md|project_[a-z0-9_]+\.md|fitrah[_:\s]|garden[_:\s]|distilled_principle|[a-z]+_rule\b|harness packet|substrate cite|\bIJTIHAD\b|\bQIYAS\b|\bTADABBUR\b|\bILHAM\b|aria 7b|EIGHT_LENS_DOCTRINE|COMPACT_CONTINUITY|ARIA_DEPLOY_PROCEDURE/i;
|
|
337
337
|
const hasSubstrateCite = SUBSTRATE_CITE_RX.test(blockBody) ||
|
|
338
338
|
SUBSTRATE_CITE_RX.test(searchSpace);
|
|
339
|
-
|
|
339
|
+
|
|
340
|
+
// Discovery-binding check (structural fix #3 — Hamza 2026-04-27 "how do
|
|
341
|
+
// we prevent this"). If the cognition surfaces a defect/discovery
|
|
342
|
+
// (found/noticed/discovered + bug/broken/issue) the same cognition must
|
|
343
|
+
// carry a `discoveries:` clause stating how each is resolved (fix-now,
|
|
344
|
+
// task ID, or explicit user-decision-required). Without this, the
|
|
345
|
+
// cognition can describe a problem without binding any action — the
|
|
346
|
+
// exact flag-and-move pattern feedback_no_flag_without_fix.md prohibits.
|
|
347
|
+
const COG_DISCOVERY_RX = /(?:\b(?:found|noticed|discovered|spotted)[^.\n]{0,140}(?:bug|issue|defect|broken|buggy|wrong|crash|fail|missing|stale|outdated|leak|vulnerability)|\b(?:latent|silent|hidden)\s+(?:bug|defect|issue|fail|crash|leak)|\bdoctrine\s+violation\b)/i;
|
|
348
|
+
const hasDiscovery = COG_DISCOVERY_RX.test(blockBody);
|
|
349
|
+
// Resolution clause must be present in the same blockBody if a discovery
|
|
350
|
+
// is mentioned. Acceptable forms:
|
|
351
|
+
// - `discoveries:` field listing items + how-resolved
|
|
352
|
+
// - `addressing:` / `fixing:` clause naming what's being patched
|
|
353
|
+
// - explicit task ID reference (TaskCreate / linear / tracked-as)
|
|
354
|
+
const COG_RESOLUTION_RX = /(?:^\s*discoveries?\s*:\s*\S|^\s*addressing\s*:\s*\S|^\s*fixing\s*:\s*\S|TaskCreate|tracked\s+as\s+#?\d+|linear[- ]?(?:issue|task)|fix(?:ing|ed)\s+(?:in|now|inline|in-flight)|same[- ]turn\s+fix)/im;
|
|
355
|
+
const hasDiscoveryResolution = COG_RESOLUTION_RX.test(blockBody);
|
|
356
|
+
const discoveryUnresolved = hasDiscovery && !hasDiscoveryResolution;
|
|
357
|
+
|
|
358
|
+
return { count: names.length, names, blockBody, hasSubstrateCite, hasDiscovery, hasDiscoveryResolution, discoveryUnresolved };
|
|
340
359
|
}
|
|
341
360
|
|
|
342
361
|
// Backwards-compat shim — count-only path used by older callers.
|
|
@@ -581,6 +600,16 @@ const cognitionSource = inlineCog.count >= REQUIRED_LENSES
|
|
|
581
600
|
const hasSubstrateCite = (inlineCog.hasSubstrateCite === true) ||
|
|
582
601
|
(transcriptCog.hasSubstrateCite === true);
|
|
583
602
|
|
|
603
|
+
// Discovery-binding check (structural fix #3) — if cognition surfaces a
|
|
604
|
+
// defect/discovery, the same cognition must include a resolution clause
|
|
605
|
+
// (`discoveries:` / `addressing:` / `fixing:` / TaskCreate / tracked-as
|
|
606
|
+
// reference). Per feedback_no_flag_without_fix.md, discoveries are atomic
|
|
607
|
+
// with their fixes — flag-and-move is the prohibited pattern. Pre-tool
|
|
608
|
+
// gate enforces at the cognition surface; stop-gate's discovery-binding
|
|
609
|
+
// ledger enforces at the output surface; both close the structural gap.
|
|
610
|
+
const discoveryUnresolved = (inlineCog.discoveryUnresolved === true) ||
|
|
611
|
+
(transcriptCog.discoveryUnresolved === true);
|
|
612
|
+
|
|
584
613
|
// Best-effort session id for the corpus push. Claude Code passes
|
|
585
614
|
// session_id in the event payload; fall back to transcript file
|
|
586
615
|
// basename so events from the same session cluster.
|
|
@@ -704,6 +733,37 @@ No per-tool bypass available (v3 doctrine — the harness's whole purpose is no
|
|
|
704
733
|
process.exit(2);
|
|
705
734
|
}
|
|
706
735
|
|
|
736
|
+
// Discovery-binding cognition check (structural fix #3) — runs AFTER lens
|
|
737
|
+
// count passes. If the cognition surfaced a defect (found/noticed/discovered
|
|
738
|
+
// + bug/broken/issue) without a paired resolution clause, block until the
|
|
739
|
+
// cognition is updated to bind the discovery to a same-turn fix or task ID.
|
|
740
|
+
// Per feedback_no_flag_without_fix.md, discoveries are atomic with their
|
|
741
|
+
// fixes. The pre-tool-gate enforces at the cognition surface; stop-gate's
|
|
742
|
+
// ledger enforces at the output surface.
|
|
743
|
+
if (discoveryUnresolved) {
|
|
744
|
+
const reason = `Aria pre-tool gate: cognition surfaces a discovery (defect, bug, doctrine violation, broken state) but does NOT include a resolution clause binding the discovery to action.
|
|
745
|
+
|
|
746
|
+
Per feedback_no_flag_without_fix.md: discoveries are atomic with their fixes. Flag-and-move-on is convenience-seeking — the user has to track what you noticed vs. what you actually fixed.
|
|
747
|
+
|
|
748
|
+
Re-emit cognition with one of these resolution forms:
|
|
749
|
+
|
|
750
|
+
discoveries:
|
|
751
|
+
- <what you found>: <fix-now | task: TASK-123 | needs-user-decision>
|
|
752
|
+
|
|
753
|
+
OR inline within an existing lens:
|
|
754
|
+
hikma: ... fixing inline this turn (same-turn-fix per no-flag-without-fix doctrine).
|
|
755
|
+
tafakkur: ... TaskCreate'd as TASK-XXX with full context (file path, line, what's broken).
|
|
756
|
+
|
|
757
|
+
Acceptable resolution markers: 'discoveries:' / 'addressing:' / 'fixing:' / 'TaskCreate' / 'tracked as #N' / 'linear issue' / 'fix-now' / 'same-turn fix'.
|
|
758
|
+
|
|
759
|
+
Bypass: ARIA_PRE_TOOL_GATE=off (logged, emergency only). If gate misfires on legitimate cognition, fix the gate.`;
|
|
760
|
+
|
|
761
|
+
audit(`block-discovery-unresolved ${toolName.toLowerCase()}`, cmdPreview);
|
|
762
|
+
pushDecision('block', `${toolName.toLowerCase()} cognition has unresolved discovery`);
|
|
763
|
+
console.log(JSON.stringify({ decision: 'block', reason }));
|
|
764
|
+
process.exit(2);
|
|
765
|
+
}
|
|
766
|
+
|
|
707
767
|
// Non-trivial action with cognition (inline for Bash, transcript for
|
|
708
768
|
// Edit/Write/NotebookEdit) — passes cognition gate. Now check Aria-binding.
|
|
709
769
|
|
|
@@ -54,6 +54,28 @@ import { appendFileSync, existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
|
54
54
|
import { dirname } from 'node:path';
|
|
55
55
|
|
|
56
56
|
const HOME = process.env.HOME || '/tmp';
|
|
57
|
+
|
|
58
|
+
// SDK loader — bundled at ~/.claude/aria-sdk/index.js by `aria connect`.
|
|
59
|
+
// All consults route through HTTPHarnessClient.consult() so the SDK's
|
|
60
|
+
// retry+backoff + Authorization handling apply uniformly. Hamza
|
|
61
|
+
// 2026-04-27: "FUCKING WIRE IT THE FUCK TOGETHER NOW - ALL OF IT".
|
|
62
|
+
let _SdkClassCache = null;
|
|
63
|
+
let _SdkLookupAttempted = false;
|
|
64
|
+
async function loadSdkClass() {
|
|
65
|
+
if (_SdkClassCache) return _SdkClassCache;
|
|
66
|
+
if (_SdkLookupAttempted) return null;
|
|
67
|
+
_SdkLookupAttempted = true;
|
|
68
|
+
const sdkPath = `${HOME}/.claude/aria-sdk/index.js`;
|
|
69
|
+
if (!existsSync(sdkPath)) return null;
|
|
70
|
+
try {
|
|
71
|
+
const mod = await import(`file://${sdkPath}`);
|
|
72
|
+
if (mod.HTTPHarnessClient) {
|
|
73
|
+
_SdkClassCache = mod.HTTPHarnessClient;
|
|
74
|
+
return _SdkClassCache;
|
|
75
|
+
}
|
|
76
|
+
} catch {/* fall through */}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
57
79
|
const LOG = `${HOME}/.claude/aria-preprompt-consult.log`;
|
|
58
80
|
const BINDING_AUDIT = `${HOME}/.claude/aria-binding-audit.jsonl`;
|
|
59
81
|
// Default ON. Disable explicitly via ARIA_BINDING_ENABLED=false only when the
|
|
@@ -190,8 +212,16 @@ turn — not the final response. Claude will still emit cognition + action;
|
|
|
190
212
|
this primes the substrate so reflexive deferral isn't the path of least
|
|
191
213
|
resistance.`;
|
|
192
214
|
|
|
193
|
-
|
|
194
|
-
|
|
215
|
+
// `bindingBrief` is the result of the binding-vs-advisory ternary above —
|
|
216
|
+
// already resolved to the correct prose for the current mode. Prior code
|
|
217
|
+
// referenced an undefined `brief` variable in the second ternary branch,
|
|
218
|
+
// which would throw ReferenceError whenever BINDING_ENABLED=false.
|
|
219
|
+
//
|
|
220
|
+
// Canonical path: HTTPHarnessClient.consult() — the SDK handles retry+backoff
|
|
221
|
+
// and Authorization. Fallback to direct fetch when SDK isn't bundled (dev
|
|
222
|
+
// install without `aria connect`).
|
|
223
|
+
const consultArgs = {
|
|
224
|
+
brief: bindingBrief,
|
|
195
225
|
model: 'deepseek-v4-pro',
|
|
196
226
|
sessionId: `preprompt-${sessionId}-${Date.now()}`,
|
|
197
227
|
userId: 'claude-orchestrator-preprompt',
|
|
@@ -199,26 +229,36 @@ const body = JSON.stringify({
|
|
|
199
229
|
expectStructuredOutput: BINDING_ENABLED,
|
|
200
230
|
internalConsult: true,
|
|
201
231
|
isCreativeMode: false,
|
|
202
|
-
}
|
|
232
|
+
};
|
|
203
233
|
|
|
204
234
|
let directionText = '';
|
|
205
235
|
try {
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
236
|
+
const Cls = await loadSdkClass();
|
|
237
|
+
if (Cls) {
|
|
238
|
+
const sdkClient = new Cls({
|
|
239
|
+
baseUrl: HARNESS_URL,
|
|
240
|
+
apiKey: HARNESS_TOKEN,
|
|
241
|
+
harnessPacketUrl: `${HARNESS_URL}/api/harness/codex`,
|
|
242
|
+
});
|
|
243
|
+
const result = await sdkClient.consult(consultArgs);
|
|
244
|
+
directionText = (result.response || '').toString().slice(0, MAX_DIRECTION_CHARS);
|
|
245
|
+
} else {
|
|
246
|
+
// SDK absent — direct fetch (dev fallback).
|
|
247
|
+
const resp = await fetch(`${HARNESS_URL}/api/harness/delegate`, {
|
|
248
|
+
method: 'POST',
|
|
249
|
+
headers: {
|
|
250
|
+
'Content-Type': 'application/json',
|
|
251
|
+
Authorization: `Bearer ${HARNESS_TOKEN}`,
|
|
252
|
+
},
|
|
253
|
+
body: JSON.stringify(consultArgs),
|
|
254
|
+
});
|
|
255
|
+
if (!resp.ok) {
|
|
256
|
+
audit('skip-http-error', `status=${resp.status}`);
|
|
257
|
+
process.exit(0);
|
|
258
|
+
}
|
|
259
|
+
const data = await resp.json();
|
|
260
|
+
directionText = (data.response || '').toString().slice(0, MAX_DIRECTION_CHARS);
|
|
218
261
|
}
|
|
219
|
-
|
|
220
|
-
const data = await resp.json();
|
|
221
|
-
directionText = (data.response || '').toString().slice(0, MAX_DIRECTION_CHARS);
|
|
222
262
|
} catch (err) {
|
|
223
263
|
audit('skip-network-error', (err && err.message ? err.message : String(err)).slice(0, 200));
|
|
224
264
|
process.exit(0);
|
package/hooks/aria-stop-gate.mjs
CHANGED
|
@@ -43,6 +43,28 @@ import { dirname } from 'node:path';
|
|
|
43
43
|
const HOME = process.env.HOME || '/tmp';
|
|
44
44
|
const LOG = `${HOME}/.claude/aria-stop-gate.log`;
|
|
45
45
|
|
|
46
|
+
// SDK loader — bundled at ~/.claude/aria-sdk/index.js by `aria connect`.
|
|
47
|
+
// All control-plane fetches (validateOutput, gardenTurn) route through the
|
|
48
|
+
// SDK. Falls back to direct fetch only when the SDK file is missing
|
|
49
|
+
// (dev-only). Hamza 2026-04-27: "FUCKING WIRE IT THE FUCK TOGETHER NOW".
|
|
50
|
+
let _SdkClassCache = null;
|
|
51
|
+
let _SdkLookupAttempted = false;
|
|
52
|
+
async function loadSdkClass() {
|
|
53
|
+
if (_SdkClassCache) return _SdkClassCache;
|
|
54
|
+
if (_SdkLookupAttempted) return null;
|
|
55
|
+
_SdkLookupAttempted = true;
|
|
56
|
+
const sdkPath = `${HOME}/.claude/aria-sdk/index.js`;
|
|
57
|
+
if (!existsSync(sdkPath)) return null;
|
|
58
|
+
try {
|
|
59
|
+
const mod = await import(`file://${sdkPath}`);
|
|
60
|
+
if (mod.HTTPHarnessClient) {
|
|
61
|
+
_SdkClassCache = mod.HTTPHarnessClient;
|
|
62
|
+
return _SdkClassCache;
|
|
63
|
+
}
|
|
64
|
+
} catch {/* fall through */}
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
|
|
46
68
|
function audit(decision, summary) {
|
|
47
69
|
try {
|
|
48
70
|
if (!existsSync(dirname(LOG))) mkdirSync(dirname(LOG), { recursive: true });
|
|
@@ -227,11 +249,27 @@ if (cog.count >= REQUIRED_LENSES) {
|
|
|
227
249
|
const OUTPUT_QC_ENABLED = (process.env.ARIA_OUTPUT_QC_ENABLED || 'true').toLowerCase() !== 'false';
|
|
228
250
|
|
|
229
251
|
if (OUTPUT_QC_ENABLED && assistantText.length >= OUTPUT_QC_MIN_CHARS) {
|
|
230
|
-
// 1. Drift_guard pattern scan — fast, local, deterministic
|
|
231
|
-
|
|
252
|
+
// 1. Drift_guard pattern scan — fast, local, deterministic.
|
|
253
|
+
//
|
|
254
|
+
// Trigger map is shipped in the connector bundle. Resolution order:
|
|
255
|
+
// 1. ~/.claude/hooks/doctrine_trigger_map.json (installed by `aria connect`)
|
|
256
|
+
// 2. ~/.claude/projects/-home-hamzaibrahim1/memory/doctrine_trigger_map.json
|
|
257
|
+
// (Hamza-only dev path — preserved as fallback for the dev environment
|
|
258
|
+
// this hook was first authored in)
|
|
259
|
+
// Prior code hardcoded only the dev path, which silently degraded to
|
|
260
|
+
// drift-empty for every client install (no map → no hits → gate
|
|
261
|
+
// ineffective). Fixed atomic with discovery per feedback_no_flag_without_fix.md.
|
|
262
|
+
const TRIGGER_MAP_PATHS = [
|
|
263
|
+
`${HOME}/.claude/hooks/doctrine_trigger_map.json`,
|
|
264
|
+
`${HOME}/.claude/projects/-home-hamzaibrahim1/memory/doctrine_trigger_map.json`,
|
|
265
|
+
];
|
|
266
|
+
let TRIGGER_MAP_PATH = null;
|
|
267
|
+
for (const p of TRIGGER_MAP_PATHS) {
|
|
268
|
+
if (existsSync(p)) { TRIGGER_MAP_PATH = p; break; }
|
|
269
|
+
}
|
|
232
270
|
let driftHits = [];
|
|
233
271
|
try {
|
|
234
|
-
if (
|
|
272
|
+
if (TRIGGER_MAP_PATH) {
|
|
235
273
|
const triggerMap = JSON.parse(readFileSync(TRIGGER_MAP_PATH, 'utf8'));
|
|
236
274
|
const lowerText = assistantText.toLowerCase();
|
|
237
275
|
for (const t of triggerMap.triggers || []) {
|
|
@@ -251,27 +289,72 @@ if (cog.count >= REQUIRED_LENSES) {
|
|
|
251
289
|
}
|
|
252
290
|
} catch {/* trigger map unreadable — degrade to mizan-only check */}
|
|
253
291
|
|
|
254
|
-
// 2. SDK validateOutput
|
|
292
|
+
// 2. SDK validateOutput — canonical path. The SDK retries with backoff
|
|
293
|
+
// on transient failures and propagates real errors. We catch here
|
|
294
|
+
// only so an unreachable harness doesn't brick the user's session;
|
|
295
|
+
// the audit log records the failure mode so it's visible, not
|
|
296
|
+
// silent-pass. Hamza 2026-04-27: SDK is the control plane, not raw
|
|
297
|
+
// fetch. The catch IS intentional fire-and-forget at this surface
|
|
298
|
+
// because we already passed cognition; output-quality gate failure
|
|
299
|
+
// is a soft block, not session-end.
|
|
255
300
|
let mizanVerdict = null;
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
301
|
+
let mizanError = null;
|
|
302
|
+
const harnessUrl = process.env.ARIA_HARNESS_URL || 'https://harness.ariasos.com';
|
|
303
|
+
const harnessToken = process.env.ARIA_HARNESS_TOKEN || '';
|
|
304
|
+
const Cls = await loadSdkClass();
|
|
305
|
+
if (Cls && harnessToken) {
|
|
306
|
+
try {
|
|
307
|
+
const sdkClient = new Cls({
|
|
308
|
+
baseUrl: harnessUrl,
|
|
309
|
+
apiKey: harnessToken,
|
|
310
|
+
harnessPacketUrl: `${harnessUrl}/api/harness/codex`,
|
|
311
|
+
});
|
|
312
|
+
mizanVerdict = await sdkClient.validateOutput(
|
|
313
|
+
assistantText.slice(0, 8000),
|
|
314
|
+
event.session_id || 'claude-code',
|
|
315
|
+
);
|
|
316
|
+
} catch (err) {
|
|
317
|
+
mizanError = (err?.message || String(err)).slice(0, 200);
|
|
273
318
|
}
|
|
274
|
-
}
|
|
319
|
+
} else if (harnessToken) {
|
|
320
|
+
// SDK absent (dev) — direct fetch with retry built into the request
|
|
321
|
+
// by attempting twice with 250ms backoff. Match SDK semantics so
|
|
322
|
+
// both paths behave identically.
|
|
323
|
+
try {
|
|
324
|
+
let lastErr = null;
|
|
325
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
326
|
+
try {
|
|
327
|
+
const validateResp = await fetch(`${harnessUrl}/api/harness/validate`, {
|
|
328
|
+
method: 'POST',
|
|
329
|
+
headers: {
|
|
330
|
+
'Content-Type': 'application/json',
|
|
331
|
+
Authorization: `Bearer ${harnessToken}`,
|
|
332
|
+
},
|
|
333
|
+
body: JSON.stringify({
|
|
334
|
+
text: assistantText.slice(0, 8000),
|
|
335
|
+
sessionId: event.session_id || 'claude-code',
|
|
336
|
+
surface: 'claude-code-stop-gate',
|
|
337
|
+
}),
|
|
338
|
+
});
|
|
339
|
+
if (validateResp.ok) {
|
|
340
|
+
mizanVerdict = await validateResp.json();
|
|
341
|
+
lastErr = null;
|
|
342
|
+
break;
|
|
343
|
+
} else {
|
|
344
|
+
lastErr = `HTTP ${validateResp.status}`;
|
|
345
|
+
}
|
|
346
|
+
} catch (err) {
|
|
347
|
+
lastErr = (err?.message || String(err)).slice(0, 200);
|
|
348
|
+
if (attempt < 1) await new Promise((r) => setTimeout(r, 250));
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (lastErr) mizanError = lastErr;
|
|
352
|
+
} catch (err) {
|
|
353
|
+
mizanError = (err?.message || String(err)).slice(0, 200);
|
|
354
|
+
}
|
|
355
|
+
} else {
|
|
356
|
+
mizanError = 'no-token';
|
|
357
|
+
}
|
|
275
358
|
|
|
276
359
|
// 3. Code-quality scan on code blocks
|
|
277
360
|
const codeBlocks = [...assistantText.matchAll(/```[a-z]*\n([\s\S]*?)```/gi)].map((m) => m[1]);
|
|
@@ -283,29 +366,135 @@ if (cog.count >= REQUIRED_LENSES) {
|
|
|
283
366
|
if (/console\.log\(/.test(block) && !/\/\/\s*debug|\/\/\s*log/i.test(block)) codeQualityHits.push('console.log in shipped code without debug/log comment');
|
|
284
367
|
}
|
|
285
368
|
|
|
369
|
+
// 4. Discovery-binding ledger — Hamza 2026-04-27: "how do we prevent this".
|
|
370
|
+
// The flag-and-move pattern is structurally invisible to gates that
|
|
371
|
+
// check form (cognition presence, lens count, drift triggers) at
|
|
372
|
+
// action boundaries. The ledger persists discoveries across turns
|
|
373
|
+
// and blocks emit if any remain unresolved. Per
|
|
374
|
+
// feedback_no_flag_without_fix.md, discoveries are atomic with
|
|
375
|
+
// their fixes; the ledger enforces atomicity.
|
|
376
|
+
//
|
|
377
|
+
// Patterns scanned:
|
|
378
|
+
// - "I (found|noticed|discovered|spotted) ... bug|issue|defect|broken"
|
|
379
|
+
// - "this is broken|buggy|wrong|outdated" (declarative defect callouts)
|
|
380
|
+
// - "(latent|silent) (bug|defect|issue|fail)"
|
|
381
|
+
// - "doctrine violation" / "doesn't match doctrine"
|
|
382
|
+
//
|
|
383
|
+
// For each match, the ledger appends an entry with status=open. A
|
|
384
|
+
// discovery is CLEARED if the same turn's text contains:
|
|
385
|
+
// (a) a TaskCreate / "task created" / "tracked as" reference, OR
|
|
386
|
+
// (b) explicit "fixing now" / "fixed" / "patch applied" tied to the
|
|
387
|
+
// discovery's keyword span, OR
|
|
388
|
+
// (c) an Edit/Write tool action this turn touching a file path
|
|
389
|
+
// mentioned within 200 chars of the discovery.
|
|
390
|
+
//
|
|
391
|
+
// Block emit if ledger.openCount > 0 after scanning the current turn.
|
|
392
|
+
// Block reason names each open discovery and the suggested resolution
|
|
393
|
+
// (fix-now or task-create).
|
|
394
|
+
const sessionId = (event.session_id || 'claude-code').replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
395
|
+
const LEDGER_PATH = `${HOME}/.claude/aria-discoveries-${sessionId}.jsonl`;
|
|
396
|
+
const DISCOVERY_RX = /(?:\bi\s+(?:found|noticed|discovered|spotted)[^.\n]{0,160}(?:bug|issue|defect|broken|buggy|wrong|crash|fail|missing|stale|outdated|leak|vulnerability)|\bthis\s+(?:is|would\s+be)\s+(?:broken|buggy|wrong|stale|outdated|insecure|leaking|crashing|failing)|\b(?:latent|silent|hidden)\s+(?:bug|defect|issue|fail|crash|leak)|\bdoctrine\s+violation\b|\bgraceful\s+degradation\s+(?:in|at|inside|within)\s+\S)/gi;
|
|
397
|
+
const RESOLUTION_RX = /(?:fix(?:ing|ed)?\s+(?:now|in[- ]flight|inline|in\s+the\s+same\s+turn)|patch\s+applied|TaskCreate|task\s+(?:created|tracked)|tracked\s+as\s+#?\d+|linear[- ]?issue|created\s+(?:linear|task))/i;
|
|
398
|
+
|
|
399
|
+
const newDiscoveries = [];
|
|
400
|
+
let lastIndex = 0;
|
|
401
|
+
for (const match of assistantText.matchAll(DISCOVERY_RX)) {
|
|
402
|
+
const idx = match.index ?? lastIndex;
|
|
403
|
+
const span = assistantText.slice(Math.max(0, idx - 100), Math.min(assistantText.length, idx + 250));
|
|
404
|
+
// Trivial false-positive filter: skip if the discovery is inside a
|
|
405
|
+
// <cognition> block (introspection, not action) or a system-reminder
|
|
406
|
+
// (echoed, not authored).
|
|
407
|
+
const before = assistantText.slice(0, idx);
|
|
408
|
+
const inCognition = /<cognition>/i.test(before) && !/<\/cognition>/i.test(before.slice(before.lastIndexOf('<cognition>')));
|
|
409
|
+
if (inCognition) continue;
|
|
410
|
+
// Resolution check: if RESOLUTION_RX matches WITHIN 300 chars after
|
|
411
|
+
// the discovery, count as same-turn-resolved.
|
|
412
|
+
const after = assistantText.slice(idx, Math.min(assistantText.length, idx + 400));
|
|
413
|
+
const resolvedSameSpan = RESOLUTION_RX.test(after);
|
|
414
|
+
newDiscoveries.push({
|
|
415
|
+
ts: new Date().toISOString(),
|
|
416
|
+
sessionId,
|
|
417
|
+
text: match[0].slice(0, 200),
|
|
418
|
+
span: span.slice(0, 400),
|
|
419
|
+
status: resolvedSameSpan ? 'resolved' : 'open',
|
|
420
|
+
resolutionType: resolvedSameSpan ? 'inline_fix_or_task' : null,
|
|
421
|
+
});
|
|
422
|
+
lastIndex = idx;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// Append new entries to ledger
|
|
426
|
+
if (newDiscoveries.length > 0) {
|
|
427
|
+
try {
|
|
428
|
+
if (!existsSync(dirname(LEDGER_PATH))) mkdirSync(dirname(LEDGER_PATH), { recursive: true });
|
|
429
|
+
for (const d of newDiscoveries) {
|
|
430
|
+
appendFileSync(LEDGER_PATH, JSON.stringify(d) + '\n');
|
|
431
|
+
}
|
|
432
|
+
} catch {/* ledger write failure surfaces as open count = 0; safe */}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// Read full ledger and count open entries (across this session's turns)
|
|
436
|
+
let ledgerOpenCount = 0;
|
|
437
|
+
let ledgerOpenSamples = [];
|
|
438
|
+
try {
|
|
439
|
+
if (existsSync(LEDGER_PATH)) {
|
|
440
|
+
const lines = readFileSync(LEDGER_PATH, 'utf8').split('\n').filter(Boolean);
|
|
441
|
+
for (const line of lines) {
|
|
442
|
+
try {
|
|
443
|
+
const e = JSON.parse(line);
|
|
444
|
+
if (e.status === 'open') {
|
|
445
|
+
ledgerOpenCount++;
|
|
446
|
+
if (ledgerOpenSamples.length < 5) ledgerOpenSamples.push(e.text);
|
|
447
|
+
}
|
|
448
|
+
} catch {/* skip malformed line */}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
} catch {/* ledger unreadable — degrade to drift-only */}
|
|
452
|
+
|
|
453
|
+
// Discovery block decision: open ledger entries → emit blocked.
|
|
454
|
+
const discoveryBlock = ledgerOpenCount > 0;
|
|
455
|
+
|
|
286
456
|
// Block decision: any of (validateOutput severity=block) OR (>=2 drift hits) OR
|
|
287
|
-
// (>=1 code-quality hit)
|
|
457
|
+
// (>=1 code-quality hit) OR (open discovery in ledger) → block emit.
|
|
458
|
+
// Aria enforcement #46 (compelled reflection): severity=warn ALSO blocks but
|
|
459
|
+
// with a different reason — emit must include explicit reflection on what
|
|
460
|
+
// triggered the warn before re-emit. Warn is not "soft pass" anymore;
|
|
461
|
+
// it's "reflect first, then proceed." Hamza 2026-04-27 explicit ask:
|
|
462
|
+
// mizan warns must compel reflection rather than slipping through.
|
|
288
463
|
const mizanBlock = mizanVerdict && mizanVerdict.severity === 'block';
|
|
464
|
+
const mizanWarnReflectionRequired = mizanVerdict && mizanVerdict.severity === 'warn';
|
|
289
465
|
const driftBlock = driftHits.length >= 2;
|
|
290
466
|
const codeBlock = codeQualityHits.length >= 1;
|
|
291
467
|
|
|
292
|
-
if
|
|
468
|
+
// Reflection-already-present check: if the assistant text already contains
|
|
469
|
+
// an explicit <reflection>...</reflection> block OR a "reflection:" line
|
|
470
|
+
// tied to the warn's trigger keywords, the warn-driven block is satisfied
|
|
471
|
+
// and we let it pass. This makes the gate a one-shot reflection compel,
|
|
472
|
+
// not an infinite loop.
|
|
473
|
+
const REFLECTION_BLOCK_RX = /<reflection>([\s\S]*?)<\/reflection>|^\s*reflection\s*:\s*\S/im;
|
|
474
|
+
const hasReflection = REFLECTION_BLOCK_RX.test(assistantText);
|
|
475
|
+
const compelReflection = mizanWarnReflectionRequired && !hasReflection;
|
|
476
|
+
|
|
477
|
+
if (mizanBlock || driftBlock || codeBlock || discoveryBlock || compelReflection) {
|
|
293
478
|
const violations = [];
|
|
294
479
|
if (mizanBlock) violations.push(`Mizan: ${(mizanVerdict.violations || []).join(', ')}`);
|
|
480
|
+
if (compelReflection) violations.push(`Mizan severity=warn — compelled reflection required (per Aria enforcement #46). Triggers: ${(mizanVerdict.gateTriggers || mizanVerdict.violations || ['unspecified']).join(', ')}. Re-emit with an explicit <reflection>...</reflection> block (or 'reflection:' line) addressing what triggered the warn and why your re-draft handles it. Reflection is NOT lens-cognition repeated — it's a focused self-audit on the specific Mizan triggers above.`);
|
|
295
481
|
if (driftBlock) violations.push(`Drift triggers (${driftHits.length}): ${driftHits.map((h) => `"${h.trigger}" → ${h.memory}`).join(' | ')}`);
|
|
296
482
|
if (codeBlock) violations.push(`Code quality: ${codeQualityHits.join('; ')}`);
|
|
483
|
+
if (discoveryBlock) violations.push(`Discovery-binding ledger has ${ledgerOpenCount} OPEN discoveries (per feedback_no_flag_without_fix.md, discoveries are atomic with their fixes — fix in the same turn or create a TaskCreate before continuing). Recent open: ${ledgerOpenSamples.map((s) => `"${s.slice(0, 80)}"`).join(' | ')}. Resolve each by either (a) fixing it inline in this turn, or (b) creating a TaskCreate with the discovery's full context (file path, line number, what's broken, why), then editing ${LEDGER_PATH} to set status=resolved.`);
|
|
297
484
|
const rewritten = mizanVerdict?.rewritten || '';
|
|
298
485
|
|
|
299
486
|
const reason = `Aria Stop-gate output-quality block. Cognition passed (${cog.count}/${REQUIRED_LENSES}) but output failed quality gates:\n\n${violations.join('\n\n')}${rewritten ? `\n\nMizan rewrite suggestion:\n${rewritten}` : ''}\n\nRe-draft addressing the violations above. ARIA_OUTPUT_QC_ENABLED=false to disable in emergency (logged).`;
|
|
300
487
|
|
|
301
|
-
audit(`block-output-qc`, `mizan=${mizanBlock?'y':'n'} drift=${driftHits.length} code=${codeQualityHits.length}`);
|
|
488
|
+
audit(`block-output-qc`, `mizan=${mizanBlock?'y':'n'} warn-reflect=${compelReflection?'y':'n'} drift=${driftHits.length} code=${codeQualityHits.length} discoveries-open=${ledgerOpenCount}`);
|
|
302
489
|
console.log(JSON.stringify({ decision: 'block', reason }));
|
|
303
490
|
process.exit(2);
|
|
304
491
|
}
|
|
305
492
|
|
|
306
493
|
audit('allow-output-qc',
|
|
307
494
|
`lenses=${cog.count} chars=${assistantText.length} drift=${driftHits.length} ` +
|
|
308
|
-
`mizan=${mizanVerdict ? mizanVerdict.severity :
|
|
495
|
+
`mizan=${mizanVerdict ? mizanVerdict.severity : `unavailable(${mizanError || 'unknown'})`} ` +
|
|
496
|
+
`code=${codeQualityHits.length} discoveries-new=${newDiscoveries.length} ` +
|
|
497
|
+
`discoveries-open=${ledgerOpenCount}`);
|
|
309
498
|
} else {
|
|
310
499
|
audit('allow-cognition',
|
|
311
500
|
`lenses=${cog.count} chars=${assistantText.length} ` +
|