instar 1.3.486 → 1.3.487
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/reflect.d.ts.map +1 -1
- package/dist/commands/reflect.js +4 -0
- package/dist/commands/reflect.js.map +1 -1
- package/dist/commands/route.d.ts.map +1 -1
- package/dist/commands/route.js +3 -0
- package/dist/commands/route.js.map +1 -1
- package/dist/commands/server.d.ts.map +1 -1
- package/dist/commands/server.js +14 -0
- package/dist/commands/server.js.map +1 -1
- package/dist/core/CircuitBreakingIntelligenceProvider.d.ts +7 -0
- package/dist/core/CircuitBreakingIntelligenceProvider.d.ts.map +1 -1
- package/dist/core/CircuitBreakingIntelligenceProvider.js +50 -0
- package/dist/core/CircuitBreakingIntelligenceProvider.js.map +1 -1
- package/dist/core/ClaudeCliIntelligenceProvider.d.ts +5 -0
- package/dist/core/ClaudeCliIntelligenceProvider.d.ts.map +1 -1
- package/dist/core/ClaudeCliIntelligenceProvider.js +6 -1
- package/dist/core/ClaudeCliIntelligenceProvider.js.map +1 -1
- package/dist/core/CodexCliIntelligenceProvider.d.ts +58 -0
- package/dist/core/CodexCliIntelligenceProvider.d.ts.map +1 -1
- package/dist/core/CodexCliIntelligenceProvider.js +293 -27
- package/dist/core/CodexCliIntelligenceProvider.js.map +1 -1
- package/dist/core/GeminiCliIntelligenceProvider.d.ts +8 -0
- package/dist/core/GeminiCliIntelligenceProvider.d.ts.map +1 -1
- package/dist/core/GeminiCliIntelligenceProvider.js +8 -0
- package/dist/core/GeminiCliIntelligenceProvider.js.map +1 -1
- package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
- package/dist/core/PostUpdateMigrator.js +40 -0
- package/dist/core/PostUpdateMigrator.js.map +1 -1
- package/dist/core/SafeGitExecutor.d.ts.map +1 -1
- package/dist/core/SafeGitExecutor.js +79 -1
- package/dist/core/SafeGitExecutor.js.map +1 -1
- package/dist/core/componentCategories.d.ts.map +1 -1
- package/dist/core/componentCategories.js +10 -0
- package/dist/core/componentCategories.js.map +1 -1
- package/dist/core/intelligenceProviderFactory.d.ts +8 -0
- package/dist/core/intelligenceProviderFactory.d.ts.map +1 -1
- package/dist/core/intelligenceProviderFactory.js +1 -0
- package/dist/core/intelligenceProviderFactory.js.map +1 -1
- package/dist/core/types.d.ts +17 -9
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/messaging/slack/SlackAdapter.d.ts +3 -0
- package/dist/messaging/slack/SlackAdapter.d.ts.map +1 -1
- package/dist/messaging/slack/SlackAdapter.js +8 -1
- package/dist/messaging/slack/SlackAdapter.js.map +1 -1
- package/dist/monitoring/FeatureMetricsLedger.d.ts +123 -1
- package/dist/monitoring/FeatureMetricsLedger.d.ts.map +1 -1
- package/dist/monitoring/FeatureMetricsLedger.js +211 -25
- package/dist/monitoring/FeatureMetricsLedger.js.map +1 -1
- package/dist/providers/adapters/anthropic-interactive-pool/index.d.ts.map +1 -1
- package/dist/providers/adapters/anthropic-interactive-pool/index.js +1 -0
- package/dist/providers/adapters/anthropic-interactive-pool/index.js.map +1 -1
- package/dist/providers/adapters/openai-codex/transport/codexSpawn.d.ts +93 -0
- package/dist/providers/adapters/openai-codex/transport/codexSpawn.d.ts.map +1 -1
- package/dist/providers/adapters/openai-codex/transport/codexSpawn.js +339 -0
- package/dist/providers/adapters/openai-codex/transport/codexSpawn.js.map +1 -1
- package/dist/providers/adapters/openai-codex/transport/codexUsageParser.d.ts +84 -0
- package/dist/providers/adapters/openai-codex/transport/codexUsageParser.d.ts.map +1 -0
- package/dist/providers/adapters/openai-codex/transport/codexUsageParser.js +208 -0
- package/dist/providers/adapters/openai-codex/transport/codexUsageParser.js.map +1 -0
- package/dist/providers/uxConfirm/OverrideDetector.d.ts.map +1 -1
- package/dist/providers/uxConfirm/OverrideDetector.js +1 -0
- package/dist/providers/uxConfirm/OverrideDetector.js.map +1 -1
- package/dist/providers/uxConfirm/TaskClassifier.d.ts.map +1 -1
- package/dist/providers/uxConfirm/TaskClassifier.js +1 -0
- package/dist/providers/uxConfirm/TaskClassifier.js.map +1 -1
- package/dist/scaffold/templates.d.ts.map +1 -1
- package/dist/scaffold/templates.js +3 -2
- package/dist/scaffold/templates.js.map +1 -1
- package/dist/security/LLMSanitizer.d.ts.map +1 -1
- package/dist/security/LLMSanitizer.js +7 -1
- package/dist/security/LLMSanitizer.js.map +1 -1
- package/dist/server/CapabilityIndex.js +1 -1
- package/dist/server/CapabilityIndex.js.map +1 -1
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/routes.js +10 -1
- package/dist/server/routes.js.map +1 -1
- package/dist/threadline/PipeSessionSpawner.d.ts.map +1 -1
- package/dist/threadline/PipeSessionSpawner.js +2 -0
- package/dist/threadline/PipeSessionSpawner.js.map +1 -1
- package/dist/threadline/WarrantsReplyGate.d.ts.map +1 -1
- package/dist/threadline/WarrantsReplyGate.js +5 -1
- package/dist/threadline/WarrantsReplyGate.js.map +1 -1
- package/package.json +4 -2
- package/scripts/lint-llm-attribution.js +418 -0
- package/scripts/lint-no-direct-destructive.js +4 -0
- package/scripts/pre-push-gate.js +24 -0
- package/src/data/builtin-manifest.json +63 -63
- package/src/scaffold/templates.ts +3 -2
- package/upgrades/1.3.487.md +39 -0
- package/upgrades/side-effects/token-audit-completeness.md +84 -0
|
@@ -10,15 +10,28 @@
|
|
|
10
10
|
* implementation. Reviewers, sentinels, canaries, and JobReflector now
|
|
11
11
|
* have a non-Claude path. The composition root picks the right
|
|
12
12
|
* implementation based on the agent's configured framework.
|
|
13
|
+
*
|
|
14
|
+
* token-audit-completeness: by default calls run as `codex exec --json`
|
|
15
|
+
* (streaming event parse → per-call token usage via onUsage; result read
|
|
16
|
+
* ONLY from the --output-last-message file). The kill-switch
|
|
17
|
+
* `intelligence.codexExecJson: false` (or env `INSTAR_CODEX_EXEC_JSON=0`)
|
|
18
|
+
* restores the previous plain-output invocation byte-for-byte.
|
|
13
19
|
*/
|
|
14
20
|
import { execFile } from 'node:child_process';
|
|
15
|
-
import { mkdtempSync, existsSync } from 'node:fs';
|
|
21
|
+
import { mkdtempSync, existsSync, readFileSync, statSync } from 'node:fs';
|
|
16
22
|
import { tmpdir } from 'node:os';
|
|
17
23
|
import { join } from 'node:path';
|
|
18
24
|
import { resolveCliModelFlag } from '../providers/adapters/openai-codex/models.js';
|
|
19
|
-
import { buildCodexChildEnv } from '../providers/adapters/openai-codex/transport/codexSpawn.js';
|
|
25
|
+
import { buildCodexChildEnv, spawnCodexExecJson, createCodexOutDir, cleanupCodexOutDir, maybeSweepStaleCodexOutDirs, } from '../providers/adapters/openai-codex/transport/codexSpawn.js';
|
|
26
|
+
import { CodexUsageAccumulator } from '../providers/adapters/openai-codex/transport/codexUsageParser.js';
|
|
20
27
|
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
21
28
|
const INTELLIGENCE_SCRATCH_DIR_PREFIX = 'instar-codex-intel-scratch-';
|
|
29
|
+
/**
|
|
30
|
+
* Fail-loudly ceiling for the --output-last-message file. The old execFile
|
|
31
|
+
* path had a 1 MB maxBuffer; with that gone, an unbounded read into a string
|
|
32
|
+
* is the replacement hazard — so the file is size-checked before read.
|
|
33
|
+
*/
|
|
34
|
+
const MAX_RESULT_FILE_BYTES = 16 * 1024 * 1024;
|
|
22
35
|
let cachedScratchDir = null;
|
|
23
36
|
/**
|
|
24
37
|
* Lazily create and return an EMPTY scratch directory used as the `--cd`
|
|
@@ -45,6 +58,11 @@ let cachedScratchDir = null;
|
|
|
45
58
|
* The dir is re-verified each call: a tmp-reaper may delete it during a
|
|
46
59
|
* long-lived process, so we recreate it if it has gone missing.
|
|
47
60
|
*
|
|
61
|
+
* NOTE: model output is NEVER written into or read from this dir — its
|
|
62
|
+
* `existsSync` reuse branch does not re-verify ownership/mode. The
|
|
63
|
+
* --output-last-message file lives in a fresh per-call dir instead
|
|
64
|
+
* (createCodexOutDir).
|
|
65
|
+
*
|
|
48
66
|
* Bug (2026-05-26): ~1,550 such judgment spawns/day were re-injecting the
|
|
49
67
|
* identity + firing session_start, causing notification spam and spawn-storm
|
|
50
68
|
* delivery failures. Spec: CODEX-INTELLIGENCE-PROVIDER-CLEAN-CALL-SPEC.md.
|
|
@@ -55,53 +73,210 @@ function resolveIntelligenceScratchDir() {
|
|
|
55
73
|
cachedScratchDir = mkdtempSync(join(tmpdir(), INTELLIGENCE_SCRATCH_DIR_PREFIX));
|
|
56
74
|
return cachedScratchDir;
|
|
57
75
|
}
|
|
76
|
+
/** Both recovery levers, named in every unknown-flag error (the kill-switch
|
|
77
|
+
* contract: a recovery instruction that is false on the path emitting it is
|
|
78
|
+
* a broken rollback contract). */
|
|
79
|
+
const EXEC_JSON_RECOVERY_LEVERS = 'If this codex CLI predates --json/--output-last-message (< 0.20), disable exec-json mode via ' +
|
|
80
|
+
'`intelligence.codexExecJson: false` in .instar/config.json or env INSTAR_CODEX_EXEC_JSON=0.';
|
|
81
|
+
function unknownFlagHint(stderrTail) {
|
|
82
|
+
return /unexpected argument|unrecognized option|unknown (option|flag)/i.test(stderrTail)
|
|
83
|
+
? ` ${EXEC_JSON_RECOVERY_LEVERS}`
|
|
84
|
+
: '';
|
|
85
|
+
}
|
|
86
|
+
/** Env-only default for exec-json mode (default ON). Used when no config
|
|
87
|
+
* closure was threaded (config-less construction sites keep a working
|
|
88
|
+
* rollback lever). */
|
|
89
|
+
function execJsonEnvDefault() {
|
|
90
|
+
return process.env.INSTAR_CODEX_EXEC_JSON !== '0';
|
|
91
|
+
}
|
|
92
|
+
let warnedConfigParseFailure = false;
|
|
93
|
+
/**
|
|
94
|
+
* Build the per-call kill-switch resolver for construction sites that have a
|
|
95
|
+
* project dir. Pinned closure body (spec): a TTL-cached (30 s) raw
|
|
96
|
+
* `readFileSync` + `JSON.parse` of `.instar/config.json` reading ONLY
|
|
97
|
+
* `intelligence.codexExecJson` — never `loadConfig()` (which drags a
|
|
98
|
+
* synchronous SecretStore keychain execFileSync onto every judgment call),
|
|
99
|
+
* and never a boot-time closure over the in-memory config object (no config
|
|
100
|
+
* hot-reload exists, so it would never see a disk flip).
|
|
101
|
+
*
|
|
102
|
+
* Resolution order: the config key wins when the file parses AND the key is
|
|
103
|
+
* present; otherwise — including parse/read failure — fall through to the
|
|
104
|
+
* env lever (itself default-on). An operator hand-editing config under
|
|
105
|
+
* pressure who leaves a JSON slip gets a once-per-process parse-failure
|
|
106
|
+
* warning and a still-working env lever, not a silently-ignored kill-switch.
|
|
107
|
+
* A config flip applies within 30 s, no restart.
|
|
108
|
+
*/
|
|
109
|
+
export function createCodexExecJsonConfigResolver(configPath = join(process.cwd(), '.instar', 'config.json'), ttlMs = 30_000) {
|
|
110
|
+
let cachedAt = 0;
|
|
111
|
+
let cached = null;
|
|
112
|
+
return () => {
|
|
113
|
+
const now = Date.now();
|
|
114
|
+
if (cached !== null && now - cachedAt < ttlMs)
|
|
115
|
+
return cached;
|
|
116
|
+
cachedAt = now;
|
|
117
|
+
let raw = null;
|
|
118
|
+
try {
|
|
119
|
+
raw = readFileSync(configPath, 'utf-8');
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
// @silent-fallback-ok: missing/unreadable config is NORMAL for
|
|
123
|
+
// config-less installs — resolution falls through to the env lever
|
|
124
|
+
// below, which is the designed default, not a degradation
|
|
125
|
+
raw = null;
|
|
126
|
+
}
|
|
127
|
+
if (raw !== null) {
|
|
128
|
+
try {
|
|
129
|
+
const parsed = JSON.parse(raw);
|
|
130
|
+
const v = parsed?.intelligence?.codexExecJson;
|
|
131
|
+
if (typeof v === 'boolean') {
|
|
132
|
+
cached = v;
|
|
133
|
+
return v;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
catch (err) {
|
|
137
|
+
// @silent-fallback-ok: NOT silent — warns once per process; an
|
|
138
|
+
// operator JSON slip keeps a working env lever instead of a
|
|
139
|
+
// silently-ignored kill-switch (the spec's pinned resolution order)
|
|
140
|
+
if (!warnedConfigParseFailure) {
|
|
141
|
+
warnedConfigParseFailure = true;
|
|
142
|
+
console.warn(`[CodexCliIntelligenceProvider] .instar/config.json failed to parse (${err.message}) — ` +
|
|
143
|
+
`intelligence.codexExecJson unavailable; falling back to env INSTAR_CODEX_EXEC_JSON`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
cached = execJsonEnvDefault();
|
|
148
|
+
return cached;
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
// ── usage-parse drift tripwire ──────────────────────────────────────────────
|
|
152
|
+
//
|
|
153
|
+
// Emission is gated to ONCE PER PROCESS LIFETIME (module-level flag):
|
|
154
|
+
// DegradationReporter's legacy path files an external feedback report per
|
|
155
|
+
// event with no feedback-side cooldown, so an hourly emission would spam the
|
|
156
|
+
// maintainer webhook ~24×/day/machine forever (P17). Once-per-boot is
|
|
157
|
+
// sufficient: the durable, always-current surface is usageCoverage in
|
|
158
|
+
// /metrics/features, not the event. The feature string is a FIXED CONSTANT —
|
|
159
|
+
// it is the Telegram dedup key, and a fixed constant prevents the P17
|
|
160
|
+
// unique-source dodge.
|
|
161
|
+
const CODEX_USAGE_DRIFT_FEATURE = 'codex-usage-parse-drift';
|
|
162
|
+
let emittedUsageDrift = false;
|
|
163
|
+
function emitUsageDriftOnce(reasons) {
|
|
164
|
+
if (emittedUsageDrift)
|
|
165
|
+
return;
|
|
166
|
+
emittedUsageDrift = true;
|
|
167
|
+
// Lazy import keeps the provider constructible in contexts where the
|
|
168
|
+
// monitoring layer isn't initialized (CLI one-shots).
|
|
169
|
+
void import('../monitoring/DegradationReporter.js')
|
|
170
|
+
.then(({ DegradationReporter }) => {
|
|
171
|
+
DegradationReporter.getInstance().report({
|
|
172
|
+
feature: CODEX_USAGE_DRIFT_FEATURE,
|
|
173
|
+
primary: 'codex exec --json per-call token usage parsed into the feature metrics ledger',
|
|
174
|
+
fallback: 'call completed but token usage was not (fully) recorded',
|
|
175
|
+
reason: reasons.join(','),
|
|
176
|
+
impact: 'codex-routed calls may be token-blind in /metrics/features (usageCoverage shows the live ratio)',
|
|
177
|
+
});
|
|
178
|
+
})
|
|
179
|
+
.catch(() => {
|
|
180
|
+
/* @silent-fallback-ok: drift reporting must never break the judgment path */
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
/** Test-only seam. */
|
|
184
|
+
export function _resetUsageDriftEmissionForTest() {
|
|
185
|
+
emittedUsageDrift = false;
|
|
186
|
+
warnedConfigParseFailure = false;
|
|
187
|
+
}
|
|
58
188
|
export class CodexCliIntelligenceProvider {
|
|
59
189
|
codexPath;
|
|
60
190
|
sandboxMode;
|
|
191
|
+
resolveExecJson;
|
|
61
192
|
constructor(options) {
|
|
62
193
|
this.codexPath = options.codexPath;
|
|
63
194
|
this.sandboxMode = options.sandboxMode ?? 'read-only';
|
|
195
|
+
this.resolveExecJson = options.resolveExecJson ?? execJsonEnvDefault;
|
|
64
196
|
// options.workingDirectory is intentionally NOT stored: judgment calls
|
|
65
197
|
// always run in an empty scratch dir (resolveIntelligenceScratchDir), so
|
|
66
198
|
// the agent's project identity + hooks never load. The option is retained
|
|
67
199
|
// on the type for API compatibility (the factory still forwards it).
|
|
200
|
+
try {
|
|
201
|
+
if (!this.resolveExecJson()) {
|
|
202
|
+
console.warn('[CodexCliIntelligenceProvider] codex exec-json disabled — codex calls are token-blind ' +
|
|
203
|
+
'(usageCoverage for codex-cli will read 0)');
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
catch {
|
|
207
|
+
/* @silent-fallback-ok: a throwing resolver must never block construction; evaluate() re-reads per call */
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/** Hygiene args shared by BOTH modes (clean-call spec; pinned by the
|
|
211
|
+
* both-modes unit test). */
|
|
212
|
+
hygieneArgs(model, scratchDir) {
|
|
213
|
+
return [
|
|
214
|
+
'--model',
|
|
215
|
+
model,
|
|
216
|
+
'--sandbox',
|
|
217
|
+
this.sandboxMode,
|
|
218
|
+
// Run judgment calls in an empty scratch dir, NOT the agent's project
|
|
219
|
+
// dir. The project dir loads the full ~26 KB AGENTS.md identity AND
|
|
220
|
+
// fires the project's .codex/hooks.json (session_start /
|
|
221
|
+
// user_prompt_submit / stop) on every call. The scratch dir is the
|
|
222
|
+
// Codex analog of ClaudeCliIntelligenceProvider's `--setting-sources
|
|
223
|
+
// user`. See resolveIntelligenceScratchDir + the spec.
|
|
224
|
+
'--cd',
|
|
225
|
+
scratchDir,
|
|
226
|
+
// Belt-and-suspenders: hard-disable project-doc (AGENTS.md) loading
|
|
227
|
+
// even if a stray doc ever lands at or above the scratch path.
|
|
228
|
+
'-c',
|
|
229
|
+
'project_doc_max_bytes=0',
|
|
230
|
+
// Reviewer/sentinel/canary calls are deterministic short prompts
|
|
231
|
+
// that don't depend on the cwd being a trusted git repo. Codex
|
|
232
|
+
// CLI's default behavior is to refuse to run when --cd points at
|
|
233
|
+
// a non-git directory (it surfaces as
|
|
234
|
+
// "Not inside a trusted directory and --skip-git-repo-check was not specified")
|
|
235
|
+
// which breaks every Codex-based agent whose state directory
|
|
236
|
+
// isn't a git checkout. Skip the check — these calls are bounded
|
|
237
|
+
// and never modify the cwd.
|
|
238
|
+
'--skip-git-repo-check',
|
|
239
|
+
];
|
|
68
240
|
}
|
|
69
241
|
async evaluate(prompt, options) {
|
|
70
242
|
const model = resolveCliModelFlag(options?.model);
|
|
71
243
|
// Observable Intelligence: surface the resolved provider/model up front so
|
|
72
|
-
// the metrics funnel attributes the call to codex
|
|
73
|
-
//
|
|
74
|
-
// switching to `exec --json` event-stream parsing — a separate change;
|
|
75
|
-
// account-level codex cost is observable via /codex/usage.)
|
|
244
|
+
// the metrics funnel attributes the call to codex on every path (including
|
|
245
|
+
// failures and the plain mode, which surfaces no token usage).
|
|
76
246
|
try {
|
|
77
247
|
options?.onModel?.({ model, framework: 'codex-cli' });
|
|
78
248
|
}
|
|
79
249
|
catch { /* @silent-fallback-ok: onModel is pure observability — a throw must never break the LLM path */ }
|
|
250
|
+
let execJson;
|
|
251
|
+
try {
|
|
252
|
+
execJson = this.resolveExecJson();
|
|
253
|
+
}
|
|
254
|
+
catch {
|
|
255
|
+
execJson = execJsonEnvDefault(); // a throwing resolver must not take the call down
|
|
256
|
+
}
|
|
257
|
+
if (execJson) {
|
|
258
|
+
return this.evaluateExecJson(prompt, options, model);
|
|
259
|
+
}
|
|
260
|
+
return this.evaluatePlain(prompt, options, model);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Kill-switch path — the pre-exec-json invocation, byte-for-byte (result
|
|
264
|
+
* semantics included: stdout.trim(), empty answer resolves '').
|
|
265
|
+
*
|
|
266
|
+
* SECURITY NOTE (disclosed tradeoff, not a regression): this legacy path
|
|
267
|
+
* passes the prompt as a positional argv element (ps-visible to local
|
|
268
|
+
* users) and execFile's error.message embeds the full command line —
|
|
269
|
+
* including the prompt — into thrown Errors. The exec-json path fixes
|
|
270
|
+
* both (prompt via stdin; errors carry only a bounded stderr tail).
|
|
271
|
+
* Flipping the kill-switch therefore re-opens this pre-existing
|
|
272
|
+
* prompt-disclosure channel in addition to going token-blind.
|
|
273
|
+
*/
|
|
274
|
+
evaluatePlain(prompt, options, model) {
|
|
80
275
|
const scratchDir = resolveIntelligenceScratchDir();
|
|
81
276
|
return new Promise((resolve, reject) => {
|
|
82
277
|
const args = [
|
|
83
278
|
'exec',
|
|
84
|
-
|
|
85
|
-
'--sandbox', this.sandboxMode,
|
|
86
|
-
// Run judgment calls in an empty scratch dir, NOT the agent's project
|
|
87
|
-
// dir. The project dir loads the full ~26 KB AGENTS.md identity AND
|
|
88
|
-
// fires the project's .codex/hooks.json (session_start /
|
|
89
|
-
// user_prompt_submit / stop) on every call. The scratch dir is the
|
|
90
|
-
// Codex analog of ClaudeCliIntelligenceProvider's `--setting-sources
|
|
91
|
-
// user`. See resolveIntelligenceScratchDir + the spec.
|
|
92
|
-
'--cd', scratchDir,
|
|
93
|
-
// Belt-and-suspenders: hard-disable project-doc (AGENTS.md) loading
|
|
94
|
-
// even if a stray doc ever lands at or above the scratch path.
|
|
95
|
-
'-c', 'project_doc_max_bytes=0',
|
|
96
|
-
// Reviewer/sentinel/canary calls are deterministic short prompts
|
|
97
|
-
// that don't depend on the cwd being a trusted git repo. Codex
|
|
98
|
-
// CLI's default behavior is to refuse to run when --cd points at
|
|
99
|
-
// a non-git directory (it surfaces as
|
|
100
|
-
// "Not inside a trusted directory and --skip-git-repo-check was not specified")
|
|
101
|
-
// which breaks every Codex-based agent whose state directory
|
|
102
|
-
// isn't a git checkout. Skip the check — these calls are bounded
|
|
103
|
-
// and never modify the cwd.
|
|
104
|
-
'--skip-git-repo-check',
|
|
279
|
+
...this.hygieneArgs(model, scratchDir),
|
|
105
280
|
// Pass the prompt as a positional arg. Codex CLI reads stdin
|
|
106
281
|
// for very long prompts but the positional path is fine for the
|
|
107
282
|
// narrow prompts reviewers/sentinels send (a few hundred tokens
|
|
@@ -142,5 +317,96 @@ export class CodexCliIntelligenceProvider {
|
|
|
142
317
|
child.stdin?.end();
|
|
143
318
|
});
|
|
144
319
|
}
|
|
320
|
+
/**
|
|
321
|
+
* Default path — `codex exec --json` with streaming usage parse. The
|
|
322
|
+
* result is read from the --output-last-message file, AND ONLY from there
|
|
323
|
+
* (stdout events never become the result: injection surface; Signal vs
|
|
324
|
+
* Authority — events are observability signal, the file is the authority).
|
|
325
|
+
*/
|
|
326
|
+
async evaluateExecJson(prompt, options, model) {
|
|
327
|
+
const scratchDir = resolveIntelligenceScratchDir();
|
|
328
|
+
const outDir = createCodexOutDir();
|
|
329
|
+
// Pinned ABSOLUTE: a relative path would resolve against --cd — i.e.
|
|
330
|
+
// into the long-lived cached scratch dir, which must never hold model
|
|
331
|
+
// output. createCodexOutDir returns an absolute mkdtemp path.
|
|
332
|
+
const outFile = join(outDir, 'last-message.txt');
|
|
333
|
+
const acc = new CodexUsageAccumulator();
|
|
334
|
+
let exitedZero = false;
|
|
335
|
+
try {
|
|
336
|
+
const args = [
|
|
337
|
+
'exec',
|
|
338
|
+
'--json',
|
|
339
|
+
'--output-last-message',
|
|
340
|
+
outFile,
|
|
341
|
+
...this.hygieneArgs(model, scratchDir),
|
|
342
|
+
// The prompt moves OFF argv in --json mode (argv is world-readable
|
|
343
|
+
// via `ps`; macOS ARG_MAX ~1 MB would hard-fail large prompts). The
|
|
344
|
+
// positional becomes `-` and the prompt is written to stdin.
|
|
345
|
+
'-',
|
|
346
|
+
];
|
|
347
|
+
const result = await spawnCodexExecJson(this.codexPath, args, {
|
|
348
|
+
timeoutMs: options?.timeoutMs ?? DEFAULT_TIMEOUT_MS,
|
|
349
|
+
env: buildCodexChildEnv(), // Spec 12 Rule 1a — both modes
|
|
350
|
+
prompt,
|
|
351
|
+
onLine: (line) => acc.feedLine(line),
|
|
352
|
+
onOversizedLine: () => acc.noteOversizedDiscard(),
|
|
353
|
+
});
|
|
354
|
+
if (result.exitCode === 0)
|
|
355
|
+
exitedZero = true;
|
|
356
|
+
if (result.exitCode !== 0) {
|
|
357
|
+
// Bounded stderr tail only — JSONL payloads are never concatenated
|
|
358
|
+
// wholesale into thrown Errors.
|
|
359
|
+
throw new Error(`Codex CLI error (exec --json, exit ${result.exitCode})` +
|
|
360
|
+
(result.stderrTail ? ` — ${result.stderrTail}` : '') +
|
|
361
|
+
unknownFlagHint(result.stderrTail));
|
|
362
|
+
}
|
|
363
|
+
// Result extraction — file only. Missing file after exit 0 rejects:
|
|
364
|
+
// resolving '' would silently mask --output-last-message argument rot,
|
|
365
|
+
// the worse failure (documented asymmetry vs plain mode's empty '').
|
|
366
|
+
let size;
|
|
367
|
+
try {
|
|
368
|
+
size = statSync(outFile).size;
|
|
369
|
+
}
|
|
370
|
+
catch {
|
|
371
|
+
throw new Error('Codex CLI error: --output-last-message file missing after exit 0 ' +
|
|
372
|
+
'(possible argument rot in the codex CLI).' +
|
|
373
|
+
` ${EXEC_JSON_RECOVERY_LEVERS}`);
|
|
374
|
+
}
|
|
375
|
+
if (size > MAX_RESULT_FILE_BYTES) {
|
|
376
|
+
throw new Error(`Codex CLI error: result file is ${size} bytes (cap ${MAX_RESULT_FILE_BYTES}) — refusing unbounded read`);
|
|
377
|
+
}
|
|
378
|
+
// Empty-after-trim with exit 0 resolves '' (mode-equivalent with plain).
|
|
379
|
+
return readFileSync(outFile, 'utf-8').trim();
|
|
380
|
+
}
|
|
381
|
+
finally {
|
|
382
|
+
// Usage accounting runs BEFORE evaluate()'s promise settles (async
|
|
383
|
+
// finally semantics), so the funnel's error row carries already-burned
|
|
384
|
+
// tokens even on timeout/reject. onUsage fires exactly once whenever
|
|
385
|
+
// usage was parsed — independent of whether the call succeeded.
|
|
386
|
+
try {
|
|
387
|
+
const { usage, driftReasons } = acc.finalize({ success: exitedZero });
|
|
388
|
+
if (usage) {
|
|
389
|
+
try {
|
|
390
|
+
options?.onUsage?.({
|
|
391
|
+
inputTokens: usage.inputTokens,
|
|
392
|
+
outputTokens: usage.outputTokens,
|
|
393
|
+
cachedTokens: usage.cachedTokens,
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
catch {
|
|
397
|
+
/* @silent-fallback-ok: onUsage is pure observability */
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
if (driftReasons.length > 0)
|
|
401
|
+
emitUsageDriftOnce(driftReasons);
|
|
402
|
+
}
|
|
403
|
+
finally {
|
|
404
|
+
// finally-cleanup covers ALL outcomes; the bounded stale sweep is the
|
|
405
|
+
// crashed-process backstop. Fire-and-forget — never awaited.
|
|
406
|
+
cleanupCodexOutDir(outDir);
|
|
407
|
+
maybeSweepStaleCodexOutDirs();
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
145
411
|
}
|
|
146
412
|
//# sourceMappingURL=CodexCliIntelligenceProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodexCliIntelligenceProvider.js","sourceRoot":"","sources":["../../src/core/CodexCliIntelligenceProvider.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"CodexCliIntelligenceProvider.js","sourceRoot":"","sources":["../../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AmE;YACnE,uEAAuE;YACvE,qEAAqE;YACrE,gEAAgE;YAChE,IAAI,CAAC;gBACH,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,GAAG,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;gBACtE,IAAI,KAAK,EAAE,CAAC;oBACV,IAAI,CAAC;wBACH,OAAO,EAAE,OAAO,EAAE,CAAC;4BACjB,WAAW,EAAE,KAAK,CAAC,WAAW;4BAC9B,YAAY,EAAE,KAAK,CAAC,YAAY;4BAChC,YAAY,EAAE,KAAK,CAAC,YAAY;yBACjC,CAAC,CAAC;oBACL,CAAC;oBAAC,MAAM,CAAC;wBACP,wDAAwD;oBAC1D,CAAC;gBACH,CAAC;gBACD,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC;oBAAE,kBAAkB,CAAC,YAAY,CAAC,CAAC;YAChE,CAAC;oBAAS,CAAC;gBACT,sEAAsE;gBACtE,6DAA6D;gBAC7D,kBAAkB,CAAC,MAAM,CAAC,CAAC;gBAC3B,2BAA2B,EAAE,CAAC;YAChC,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -20,6 +20,14 @@
|
|
|
20
20
|
* and the env allowlist + billing-var hard-delete live in
|
|
21
21
|
* providers/adapters/gemini-cli/transport/geminiSpawn.ts, imported here so
|
|
22
22
|
* the alive path and the registry adapter can never diverge on safety.
|
|
23
|
+
*
|
|
24
|
+
* CANNOT-SURFACE-USAGE (token-audit-completeness, documented exemption):
|
|
25
|
+
* this provider NEVER invokes options.onUsage — the gemini CLI's one-shot
|
|
26
|
+
* plain-text output carries no per-call token usage block, so there is
|
|
27
|
+
* nothing to parse. gemini-cli is therefore an `exempt: true` row in
|
|
28
|
+
* /metrics/features usageCoverage. If a future gemini CLI gains a usage
|
|
29
|
+
* surface, remove the exemption in FeatureMetricsLedger.USAGE_EXEMPT_FRAMEWORKS
|
|
30
|
+
* and wire the parse — the provider usage-contract test pins this contract.
|
|
23
31
|
*/
|
|
24
32
|
import type { IntelligenceProvider, IntelligenceOptions } from './types.js';
|
|
25
33
|
import { type GeminiCapacityPolicyConfig } from '../providers/adapters/gemini-cli/observability/geminiCapacityPolicy.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeminiCliIntelligenceProvider.d.ts","sourceRoot":"","sources":["../../src/core/GeminiCliIntelligenceProvider.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"GeminiCliIntelligenceProvider.d.ts","sourceRoot":"","sources":["../../src/core/GeminiCliIntelligenceProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAO5E,OAAO,EAIL,KAAK,0BAA0B,EAChC,MAAM,wEAAwE,CAAC;AAKhF,MAAM,WAAW,oCAAoC;IACnD,gDAAgD;IAChD,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,uEAAuE;IACvE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,0BAA0B,CAAC;CAC7C;AAED,qBAAa,6BAA8B,YAAW,oBAAoB;IACxE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAqB;IACpD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAyC;gBAE5D,OAAO,EAAE,oCAAoC;IAQnD,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;CAsE/E"}
|
|
@@ -20,6 +20,14 @@
|
|
|
20
20
|
* and the env allowlist + billing-var hard-delete live in
|
|
21
21
|
* providers/adapters/gemini-cli/transport/geminiSpawn.ts, imported here so
|
|
22
22
|
* the alive path and the registry adapter can never diverge on safety.
|
|
23
|
+
*
|
|
24
|
+
* CANNOT-SURFACE-USAGE (token-audit-completeness, documented exemption):
|
|
25
|
+
* this provider NEVER invokes options.onUsage — the gemini CLI's one-shot
|
|
26
|
+
* plain-text output carries no per-call token usage block, so there is
|
|
27
|
+
* nothing to parse. gemini-cli is therefore an `exempt: true` row in
|
|
28
|
+
* /metrics/features usageCoverage. If a future gemini CLI gains a usage
|
|
29
|
+
* surface, remove the exemption in FeatureMetricsLedger.USAGE_EXEMPT_FRAMEWORKS
|
|
30
|
+
* and wire the parse — the provider usage-contract test pins this contract.
|
|
23
31
|
*/
|
|
24
32
|
import { resolveCliModelFlag } from '../providers/adapters/gemini-cli/models.js';
|
|
25
33
|
import { buildGeminiChildEnv, buildGeminiOneShotArgv, spawnGeminiAndWait, } from '../providers/adapters/gemini-cli/transport/geminiSpawn.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeminiCliIntelligenceProvider.js","sourceRoot":"","sources":["../../src/core/GeminiCliIntelligenceProvider.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"GeminiCliIntelligenceProvider.js","sourceRoot":"","sources":["../../src/core/GeminiCliIntelligenceProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AACjF,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,2DAA2D,CAAC;AACnE,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,4BAA4B,GAE7B,MAAM,wEAAwE,CAAC;AAEhF,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAClC,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,C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AoB;IAgG5B,OAAO,CAAC,qBAAqB;IA8H7B,OAAO,CAAC,2BAA2B;IAoHnC,OAAO,CAAC,iCAAiC;IA6DzC,OAAO,CAAC,4BAA4B;IA0MpC;;;;;;;;;;OAUG;IACH;;;;;;;;;;;OAWG;IAEH,gBAAuB,iCAAiC,EAAE,WAAW,CAAC,MAAM,CAAC,CAsC1E;IAEH;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,8BAA8B;IAiHtC,OAAO,CAAC,uBAAuB;IAwD/B;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,sBAAsB;IAwC9B,OAAO,CAAC,iBAAiB;IAwBzB,OAAO,CAAC,mBAAmB;IAa3B,OAAO,CAAC,8BAA8B;IA6HtC,OAAO,CAAC,+BAA+B;IAuKvC,OAAO,CAAC,oBAAoB;IAY5B,OAAO,CAAC,qBAAqB;IAqO7B,OAAO,CAAC,qBAAqB;IAwI7B,OAAO,CAAC,qBAAqB;IAyN7B,OAAO,CAAC,6BAA6B;IAkLrC,OAAO,CAAC,0BAA0B;IAiClC,OAAO,CAAC,0BAA0B;IA8ElC,OAAO,CAAC,0BAA0B;IA8IlC,OAAO,CAAC,gBAAgB;IAmJxB,OAAO,CAAC,6BAA6B;CAoCtC"}
|
|
@@ -3537,6 +3537,31 @@ Audit what each LLM-driven gate/sentinel actually does: WHICH provider + model r
|
|
|
3537
3537
|
patched = true;
|
|
3538
3538
|
result.upgraded.push('CLAUDE.md: added Per-Feature LLM Metrics (/metrics/features) awareness (llm-feature-metrics + observable-intelligence)');
|
|
3539
3539
|
}
|
|
3540
|
+
// token-audit-completeness (Agent Awareness + Migration Parity): existing
|
|
3541
|
+
// agents must learn the per-model token breakdown, usageCoverage, and the
|
|
3542
|
+
// unlabeled-spend shares. Append-only addendum (house policy — the base
|
|
3543
|
+
// Per-Feature section above is never edited in place). Content-sniff on
|
|
3544
|
+
// the literal `unlabeledCallShare` — a REAL field name the addendum text
|
|
3545
|
+
// emits AND the updated templates.ts base section emits, so a freshly-
|
|
3546
|
+
// initialized agent self-matches and is never double-patched (an earlier
|
|
3547
|
+
// candidate, `unlabeledShare`, is a substring of NEITHER actual field —
|
|
3548
|
+
// an addendum written with the real names would never self-match and the
|
|
3549
|
+
// migration would re-append on every update run, violating idempotency).
|
|
3550
|
+
if (!content.includes('unlabeledCallShare')) {
|
|
3551
|
+
const tokenAuditSection = `
|
|
3552
|
+
### Token-Audit Completeness — per-model token breakdown & usage coverage
|
|
3553
|
+
|
|
3554
|
+
\`/metrics/features\` answers cost questions per feature AND per model (operator directive: an unmetered LLM call is an unaccountable one — see the Token-Audit Completeness standard in the constitution):
|
|
3555
|
+
- Each feature row carries \`byModel\` (feature×model×framework: calls, tokensIn/tokensOut/tokensCached); \`totals.byModel\` is the cross-feature aggregate. \`tokensCached\` is the cache-read SUBSET of \`tokensIn\` (fresh cost = tokensIn − tokensCached).
|
|
3556
|
+
- \`totals.usageCoverage\` reports, per framework, the share of successful calls that recorded REAL token usage. Codex-routed calls report per-call tokens (exec --json); 0 coverage on a non-exempt framework is the drift alarm, not noise. gemini-cli is the documented cannot-surface exemption. Failed calls still carry their already-burned tokens (error rows record cost).
|
|
3557
|
+
- \`totals.unlabeledTokenShare\` + \`totals.unlabeledCallShare\` track unattributed spend — the baseline is ZERO and a lint ratchet keeps every new LLM callsite tagged with \`attribution.component\`.
|
|
3558
|
+
- Rollback lever for codex exec-json mode: \`intelligence.codexExecJson: false\` in \`.instar/config.json\` (or env \`INSTAR_CODEX_EXEC_JSON=0\`) restores the plain invocation — codex calls then go token-blind and \`usageCoverage\` shows it honestly.
|
|
3559
|
+
- **When to use** (PROACTIVE): "how many tokens did feature X spend, on which model?" / "are we audit-blind anywhere?" / before enabling any cost-bearing background feature (e.g. the cartographer freshness sweep) → read \`byModel\` + \`usageCoverage\` instead of guessing. Spec: \`docs/specs/token-audit-completeness.md\`.
|
|
3560
|
+
`;
|
|
3561
|
+
content += '\n' + tokenAuditSection;
|
|
3562
|
+
patched = true;
|
|
3563
|
+
result.upgraded.push('CLAUDE.md: added Token-Audit Completeness (per-model breakdown + usageCoverage) awareness (token-audit-completeness)');
|
|
3564
|
+
}
|
|
3540
3565
|
// correction-capture-backlog (Agent Awareness + Migration Parity): existing
|
|
3541
3566
|
// agents with the Correction & Preference Learning block need to learn that a
|
|
3542
3567
|
// rate-limited capture is now backlogged + distilled later (not dropped), so
|
|
@@ -5126,6 +5151,21 @@ Create worktrees for collaborator repos with \`instar worktree create <branch>\`
|
|
|
5126
5151
|
// KPI. A Codex/Gemini agent that never learns /metrics/learning-velocity
|
|
5127
5152
|
// can't answer "are we actually learning?" with real numbers.
|
|
5128
5153
|
'**Learning-Velocity Metric (EXO 3.0',
|
|
5154
|
+
// Per-Feature LLM Metrics base section (token-audit-completeness): the
|
|
5155
|
+
// shadow mirror never carried it. TWO tail-truncated, line-leading
|
|
5156
|
+
// literals cover both deployed variants — templates' bold-block form and
|
|
5157
|
+
// migrateClaudeMd's H3 form (each CLAUDE.md contains exactly one, so
|
|
5158
|
+
// exactly one literal fires; the other no-ops). Tail-truncation is the
|
|
5159
|
+
// list's sanctioned multi-variant trick (cf. the MTP marker); a
|
|
5160
|
+
// HEAD-truncated bare phrase would anchor mid-heading and match the
|
|
5161
|
+
// phrase inside OTHER sections' body prose, truncating their slices.
|
|
5162
|
+
'**Per-Feature LLM Metrics',
|
|
5163
|
+
'### Per-Feature LLM Metrics',
|
|
5164
|
+
// Token-audit addendum (per-model breakdown + usageCoverage): a Codex/
|
|
5165
|
+
// Gemini agent that never learns byModel/usageCoverage can't answer
|
|
5166
|
+
// "how much did feature X spend on which model?" or spot audit-blind
|
|
5167
|
+
// frameworks.
|
|
5168
|
+
'### Token-Audit Completeness — per-model token breakdown & usage coverage',
|
|
5129
5169
|
];
|
|
5130
5170
|
for (const shadowName of ['AGENTS.md', 'GEMINI.md']) {
|
|
5131
5171
|
const shadowPath = path.join(this.config.projectDir, shadowName);
|