burnoff 1.2.0 → 1.4.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.
@@ -16,7 +16,19 @@ export const DEFAULT_POLICY = Object.freeze({
16
16
  subagentFanoutAction: 'advisory',
17
17
  subagentMaxBurstCount: 4,
18
18
  subagentBurstWindowSec: 60,
19
- subagentMaxPromptChars: 8000
19
+ subagentMaxPromptChars: 8000,
20
+ det07Enabled: true,
21
+ det07Action: 'ask',
22
+ det07ReadBypassMaxBytes: 16384,
23
+ det07ReadBypassMaxLines: 250,
24
+ det08Enabled: true,
25
+ det08Action: 'ask',
26
+ det08CheckTestSkip: true,
27
+ det08CheckEmptyCatch: true,
28
+ det09Enabled: true,
29
+ det09Action: 'ask',
30
+ det09MaxEditsPerFile: 5,
31
+ det09WindowSec: 300
20
32
  }),
21
33
  readClamp: Object.freeze({
22
34
  enabled: true,
@@ -9,6 +9,7 @@ import path from 'node:path';
9
9
  import { withFileLockSync } from '../storage/file-lock.mjs';
10
10
  import { atomicWriteJsonSync, sleepSync } from '../storage/atomic-io.mjs';
11
11
  import { getBurnoffRuntimeDir, getHomeDir, getWorkspaceStateDir } from '../config/paths.mjs';
12
+ import { isVerificationShellCommand, normalizeEditThrashPath } from './phase5-detectors.mjs';
12
13
 
13
14
  export const DEFAULT_MAX_CONSECUTIVE_FAILURES = 3;
14
15
  export const DEFAULT_SCOPE_LOCK_TTL_MS = 15 * 60 * 1000;
@@ -17,6 +18,12 @@ export const DEFAULT_SUBAGENT_MAX_BURST_COUNT = 4;
17
18
  export const DEFAULT_SUBAGENT_BURST_WINDOW_SEC = 60;
18
19
  export const DEFAULT_SUBAGENT_MAX_PROMPT_CHARS = 8000;
19
20
  const DET04_EXEMPT_READ_TOOLS = /^(?:Read|Grep|Glob)$/i;
21
+ const EDIT_THRASH_TOOL_RE =
22
+ /^(?:Edit|Write|MultiEdit|NotebookEdit|edit_file|write_file|write_to_file|replace_file_content|multi_replace_file_content)$/i;
23
+ const EDIT_THRASH_STORAGE_TTL_MS = 60 * 60 * 1000;
24
+ const EDIT_THRASH_MAX_FILES = 24;
25
+ const EDIT_THRASH_MAX_TIMESTAMPS = 16;
26
+ const EXEMPT_MCP_CONFIG_BASENAME_RE = /^(?:\.mcp\.json|mcp_config\.json)$/i;
20
27
 
21
28
  function readJsonSafe(filePath, fallback = null) {
22
29
  if (!filePath) return fallback;
@@ -214,6 +221,48 @@ export function recordToolOutcomeAtomicSync(
214
221
  if (isStashPush) {
215
222
  next.lastGitStashAtMs = nowMs;
216
223
  }
224
+
225
+ // DET-09: Track successful same-file edits and reset on passing verification runs.
226
+ const prevThrash =
227
+ base.editThrashHistory && typeof base.editThrashHistory === 'object'
228
+ ? { ...base.editThrashHistory }
229
+ : {};
230
+ if (!failed && command && isVerificationShellCommand(command)) {
231
+ next.editThrashHistory = {};
232
+ } else if (
233
+ !failed &&
234
+ EDIT_THRASH_TOOL_RE.test(String(toolName || '')) &&
235
+ filePath &&
236
+ !EXEMPT_MCP_CONFIG_BASENAME_RE.test(path.basename(String(filePath).trim()))
237
+ ) {
238
+ const normKey = normalizeEditThrashPath(filePath, options?.cwd || '');
239
+ if (normKey) {
240
+ const cutoff = nowMs - EDIT_THRASH_STORAGE_TTL_MS;
241
+ const prunedHistory = {};
242
+ const keys = Object.keys(prevThrash).slice(-EDIT_THRASH_MAX_FILES);
243
+ for (const k of keys) {
244
+ const list = Array.isArray(prevThrash[k])
245
+ ? prevThrash[k]
246
+ .map((v) => Number(v))
247
+ .filter((v) => Number.isFinite(v) && v >= cutoff && v <= nowMs)
248
+ : [];
249
+ if (list.length > 0) {
250
+ prunedHistory[k] = list.slice(-EDIT_THRASH_MAX_TIMESTAMPS);
251
+ }
252
+ }
253
+ const currentList = prunedHistory[normKey] ? [...prunedHistory[normKey]] : [];
254
+ currentList.push(nowMs);
255
+ prunedHistory[normKey] = currentList.slice(-EDIT_THRASH_MAX_TIMESTAMPS);
256
+
257
+ const finalKeys = Object.keys(prunedHistory);
258
+ if (finalKeys.length > EDIT_THRASH_MAX_FILES) {
259
+ for (const dropKey of finalKeys.slice(0, finalKeys.length - EDIT_THRASH_MAX_FILES)) {
260
+ if (dropKey !== normKey) delete prunedHistory[dropKey];
261
+ }
262
+ }
263
+ next.editThrashHistory = prunedHistory;
264
+ }
265
+ }
217
266
  return next;
218
267
  },
219
268
  options