@open-cr-agent/core 0.6.0 → 0.7.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 (204) hide show
  1. package/README.md +1 -1
  2. package/dist/agent/budget.d.ts +0 -1
  3. package/dist/agent/budget.js +0 -1
  4. package/dist/agent/json.d.ts +0 -1
  5. package/dist/agent/json.js +0 -1
  6. package/dist/agent/pool.d.ts +0 -1
  7. package/dist/agent/pool.js +0 -1
  8. package/dist/agent/settings.d.ts +0 -1
  9. package/dist/agent/settings.js +0 -1
  10. package/dist/agent/usage.d.ts +0 -1
  11. package/dist/agent/usage.js +0 -1
  12. package/dist/anchor/anchor.d.ts +0 -1
  13. package/dist/anchor/anchor.js +0 -1
  14. package/dist/anchor/match.d.ts +0 -1
  15. package/dist/anchor/match.js +0 -1
  16. package/dist/anchor/relocate.d.ts +0 -1
  17. package/dist/anchor/relocate.js +0 -1
  18. package/dist/at.d.ts +0 -1
  19. package/dist/at.js +0 -1
  20. package/dist/bounded-file.d.ts +12 -0
  21. package/dist/bounded-file.js +47 -0
  22. package/dist/bundle/bundle.d.ts +0 -1
  23. package/dist/bundle/bundle.js +0 -1
  24. package/dist/bundle/grouping.d.ts +0 -1
  25. package/dist/bundle/grouping.js +0 -1
  26. package/dist/bundle/runtime-grouper.d.ts +0 -1
  27. package/dist/bundle/runtime-grouper.js +0 -1
  28. package/dist/contracts.d.ts +10 -1
  29. package/dist/contracts.js +4 -1
  30. package/dist/diff/hunks.d.ts +0 -1
  31. package/dist/diff/hunks.js +0 -1
  32. package/dist/diff/parse.d.ts +0 -1
  33. package/dist/diff/parse.js +0 -1
  34. package/dist/diff/quoted-path.d.ts +0 -1
  35. package/dist/diff/quoted-path.js +0 -1
  36. package/dist/domain.d.ts +4 -1
  37. package/dist/domain.js +0 -1
  38. package/dist/errors.d.ts +0 -1
  39. package/dist/errors.js +0 -1
  40. package/dist/hash.d.ts +0 -1
  41. package/dist/hash.js +0 -1
  42. package/dist/index.d.ts +5 -5
  43. package/dist/index.js +2 -3
  44. package/dist/internal.d.ts +3 -3
  45. package/dist/internal.js +2 -2
  46. package/dist/judge/judge.d.ts +0 -1
  47. package/dist/judge/judge.js +0 -1
  48. package/dist/judge/prompt.d.ts +0 -1
  49. package/dist/judge/prompt.js +0 -1
  50. package/dist/judge/verdict.d.ts +0 -1
  51. package/dist/judge/verdict.js +0 -1
  52. package/dist/memory/memory.d.ts +0 -1
  53. package/dist/memory/memory.js +0 -1
  54. package/dist/net/proxied-fetch.d.ts +0 -1
  55. package/dist/net/proxied-fetch.js +0 -1
  56. package/dist/pipeline/assemble-report.d.ts +0 -1
  57. package/dist/pipeline/assemble-report.js +0 -1
  58. package/dist/pipeline/check-stage.d.ts +0 -1
  59. package/dist/pipeline/check-stage.js +0 -1
  60. package/dist/pipeline/context.d.ts +0 -1
  61. package/dist/pipeline/context.js +8 -5
  62. package/dist/pipeline/coverage.d.ts +0 -1
  63. package/dist/pipeline/coverage.js +37 -17
  64. package/dist/pipeline/execute-stage.d.ts +0 -1
  65. package/dist/pipeline/execute-stage.js +29 -3
  66. package/dist/pipeline/execute.d.ts +9 -2
  67. package/dist/pipeline/execute.js +90 -9
  68. package/dist/pipeline/filter-stage.d.ts +0 -1
  69. package/dist/pipeline/filter-stage.js +0 -1
  70. package/dist/pipeline/findings.d.ts +0 -1
  71. package/dist/pipeline/findings.js +0 -1
  72. package/dist/pipeline/imports.d.ts +0 -1
  73. package/dist/pipeline/imports.js +0 -1
  74. package/dist/pipeline/matrix.d.ts +0 -1
  75. package/dist/pipeline/matrix.js +0 -1
  76. package/dist/pipeline/options.d.ts +2 -1
  77. package/dist/pipeline/options.js +0 -1
  78. package/dist/pipeline/plan-output.d.ts +0 -1
  79. package/dist/pipeline/plan-output.js +0 -1
  80. package/dist/pipeline/plan.d.ts +1 -2
  81. package/dist/pipeline/plan.js +6 -2
  82. package/dist/pipeline/preview.d.ts +0 -1
  83. package/dist/pipeline/preview.js +0 -1
  84. package/dist/pipeline/provenance.d.ts +0 -1
  85. package/dist/pipeline/provenance.js +0 -1
  86. package/dist/pipeline/resume.d.ts +22 -0
  87. package/dist/pipeline/resume.js +24 -0
  88. package/dist/pipeline/run-id.d.ts +0 -1
  89. package/dist/pipeline/run-id.js +0 -1
  90. package/dist/pipeline/run.d.ts +0 -1
  91. package/dist/pipeline/run.js +0 -1
  92. package/dist/pipeline/task.d.ts +5 -8
  93. package/dist/pipeline/task.js +8 -6
  94. package/dist/plugin/builtin.d.ts +1 -1
  95. package/dist/plugin/builtin.js +12 -3
  96. package/dist/plugin/host.d.ts +0 -1
  97. package/dist/plugin/host.js +0 -1
  98. package/dist/plugin/registry.d.ts +0 -1
  99. package/dist/plugin/registry.js +0 -1
  100. package/dist/plugin/types.d.ts +0 -1
  101. package/dist/plugin/types.js +0 -1
  102. package/dist/report/output-schema.d.ts +39 -1
  103. package/dist/report/output-schema.js +10 -3
  104. package/dist/report/output.d.ts +0 -1
  105. package/dist/report/output.js +7 -4
  106. package/dist/report/provenance.d.ts +0 -1
  107. package/dist/report/provenance.js +0 -1
  108. package/dist/report/read.d.ts +0 -1
  109. package/dist/report/read.js +5 -3
  110. package/dist/report/report.d.ts +26 -3
  111. package/dist/report/report.js +11 -3
  112. package/dist/report/serialize.d.ts +0 -1
  113. package/dist/report/serialize.js +0 -1
  114. package/dist/rereview/presence.d.ts +0 -1
  115. package/dist/rereview/presence.js +0 -1
  116. package/dist/rereview/quote.d.ts +0 -1
  117. package/dist/rereview/quote.js +0 -1
  118. package/dist/rereview/reconcile.d.ts +0 -1
  119. package/dist/rereview/reconcile.js +0 -1
  120. package/dist/review/impact.d.ts +0 -1
  121. package/dist/review/impact.js +0 -1
  122. package/dist/review/plan-phase.d.ts +0 -1
  123. package/dist/review/plan-phase.js +0 -1
  124. package/dist/review/prompt-text.d.ts +0 -1
  125. package/dist/review/prompt-text.js +0 -1
  126. package/dist/review/prompt.d.ts +0 -1
  127. package/dist/review/prompt.js +0 -1
  128. package/dist/review/reviewer.d.ts +0 -1
  129. package/dist/review/reviewer.js +0 -1
  130. package/dist/review/reviewers/agents-md.d.ts +0 -1
  131. package/dist/review/reviewers/agents-md.js +0 -1
  132. package/dist/review/reviewers/correctness.d.ts +0 -1
  133. package/dist/review/reviewers/correctness.js +0 -1
  134. package/dist/review/reviewers/docs.d.ts +0 -1
  135. package/dist/review/reviewers/docs.js +0 -1
  136. package/dist/review/reviewers/performance.d.ts +0 -1
  137. package/dist/review/reviewers/performance.js +0 -1
  138. package/dist/review/reviewers/scopes.d.ts +0 -1
  139. package/dist/review/reviewers/scopes.js +0 -1
  140. package/dist/review/reviewers/security.d.ts +0 -1
  141. package/dist/review/reviewers/security.js +0 -1
  142. package/dist/review/tools.d.ts +0 -1
  143. package/dist/review/tools.js +0 -1
  144. package/dist/rules/builtin/general.d.ts +0 -1
  145. package/dist/rules/builtin/general.js +0 -1
  146. package/dist/rules/builtin/go.d.ts +0 -1
  147. package/dist/rules/builtin/go.js +0 -1
  148. package/dist/rules/builtin/index.d.ts +0 -1
  149. package/dist/rules/builtin/index.js +0 -1
  150. package/dist/rules/builtin/java.d.ts +0 -1
  151. package/dist/rules/builtin/java.js +0 -1
  152. package/dist/rules/builtin/performance.d.ts +0 -1
  153. package/dist/rules/builtin/performance.js +0 -1
  154. package/dist/rules/builtin/python.d.ts +0 -1
  155. package/dist/rules/builtin/python.js +0 -1
  156. package/dist/rules/builtin/security.d.ts +0 -1
  157. package/dist/rules/builtin/security.js +0 -1
  158. package/dist/rules/builtin/typescript.d.ts +0 -1
  159. package/dist/rules/builtin/typescript.js +0 -1
  160. package/dist/rules/languages.d.ts +0 -1
  161. package/dist/rules/languages.js +0 -1
  162. package/dist/rules/repo-rules.d.ts +0 -1
  163. package/dist/rules/repo-rules.js +0 -1
  164. package/dist/rules/resolve.d.ts +0 -1
  165. package/dist/rules/resolve.js +0 -1
  166. package/dist/rules/rule-set.d.ts +0 -1
  167. package/dist/rules/rule-set.js +0 -1
  168. package/dist/runtime/attempt.d.ts +15 -2
  169. package/dist/runtime/attempt.js +47 -1
  170. package/dist/runtime/chain-runner.d.ts +0 -1
  171. package/dist/runtime/chain-runner.js +0 -1
  172. package/dist/runtime/effort-capability.d.ts +0 -1
  173. package/dist/runtime/effort-capability.js +0 -1
  174. package/dist/runtime/failback.d.ts +0 -1
  175. package/dist/runtime/failback.js +38 -9
  176. package/dist/runtime/models.d.ts +0 -1
  177. package/dist/runtime/models.js +14 -13
  178. package/dist/runtime/quota.d.ts +1 -1
  179. package/dist/runtime/quota.js +3 -2
  180. package/dist/runtime/tools.d.ts +0 -1
  181. package/dist/runtime/tools.js +0 -1
  182. package/dist/sarif/candidates.d.ts +0 -1
  183. package/dist/sarif/candidates.js +0 -1
  184. package/dist/sarif/schema.d.ts +0 -1
  185. package/dist/sarif/schema.js +0 -1
  186. package/dist/select/patterns.d.ts +0 -1
  187. package/dist/select/patterns.js +0 -1
  188. package/dist/select/select.d.ts +1 -1
  189. package/dist/select/select.js +16 -3
  190. package/dist/session/jsonl.d.ts +2 -2
  191. package/dist/session/jsonl.js +9 -4
  192. package/dist/session/resume-read.d.ts +2 -0
  193. package/dist/session/resume-read.js +128 -0
  194. package/dist/session/seal.d.ts +5 -0
  195. package/dist/session/seal.js +24 -0
  196. package/dist/triage.d.ts +0 -1
  197. package/dist/triage.js +0 -1
  198. package/dist/vcs.d.ts +0 -1
  199. package/dist/vcs.js +0 -1
  200. package/dist/verify/prompt.d.ts +0 -1
  201. package/dist/verify/prompt.js +0 -1
  202. package/dist/verify/verify.d.ts +0 -1
  203. package/dist/verify/verify.js +0 -1
  204. package/package.json +1 -1
@@ -6,4 +6,3 @@ export const GENERAL_RULES = `### General correctness
6
6
  - Concurrency hazards that the code makes reachable: unsynchronized shared state, check-then-act races, missing cancellation or timeouts on blocking work.
7
7
  - Data integrity: lost updates, non-idempotent retries, inconsistent writes across stores, incorrect migrations or backfills.
8
8
  - Security defects visible in the change: injection, missing authorization on a new path, secrets in code or logs, unsafe deserialization.`;
9
- //# sourceMappingURL=general.js.map
@@ -1,2 +1 @@
1
1
  export declare const GO_RULES = "### Go\n- Errors that are ignored, overwritten before being checked, or wrapped with `%v` where callers rely on `errors.Is`/`errors.As`.\n- Typed nil values stored in interfaces and then compared with `nil`; nil map writes; nil pointer dereferences reachable from real inputs.\n- Goroutines that can block forever or outlive their owner; missing cancellation; `context.Background()` used where the caller's context should flow.\n- `WithCancel`/`WithTimeout` whose cancel function is never called; timers or tickers left running.\n- Data races on maps, slices or counters shared between goroutines; locks held across blocking I/O; copying values that contain a `sync.Mutex`.\n- `defer` inside loops that delays cleanup until function exit; deferred `Close` errors dropped on write paths.\n- Loop variable capture in goroutines or closures when the module targets Go older than 1.22.";
2
- //# sourceMappingURL=go.d.ts.map
@@ -6,4 +6,3 @@ export const GO_RULES = `### Go
6
6
  - Data races on maps, slices or counters shared between goroutines; locks held across blocking I/O; copying values that contain a \`sync.Mutex\`.
7
7
  - \`defer\` inside loops that delays cleanup until function exit; deferred \`Close\` errors dropped on write paths.
8
8
  - Loop variable capture in goroutines or closures when the module targets Go older than 1.22.`;
9
- //# sourceMappingURL=go.js.map
@@ -2,4 +2,3 @@ import type { RuleSet } from "../rule-set.js";
2
2
  export { PERFORMANCE_RULES } from "./performance.js";
3
3
  export { SECURITY_RULES } from "./security.js";
4
4
  export declare const CORRECTNESS_RULES: RuleSet;
5
- //# sourceMappingURL=index.d.ts.map
@@ -12,4 +12,3 @@ const LANGUAGE_RULES = {
12
12
  java: JAVA_RULES,
13
13
  };
14
14
  export const CORRECTNESS_RULES = { general: GENERAL_RULES, languages: LANGUAGE_RULES };
15
- //# sourceMappingURL=index.js.map
@@ -1,2 +1 @@
1
1
  export declare const JAVA_RULES = "### Java\n- `equals`/`hashCode` inconsistencies, reference comparison (`==`) of strings or boxed numbers, and unboxing of possibly-null values.\n- Resources not closed with try-with-resources on paths that can throw; streams, connections or locks leaked on error.\n- Exceptions caught and ignored, logged and then treated as success, or rethrown without the cause.\n- Shared mutable state accessed from multiple threads without synchronization; non-thread-safe types (`SimpleDateFormat`, `HashMap`) in shared fields; double-checked locking without `volatile`.\n- `Optional.get()` or collection access without checking presence; modification of a collection while iterating it.\n- Transaction boundaries that do not cover all related writes; `@Transactional` on private or self-invoked methods.\n- SQL or JPQL built by string concatenation from input; deserialization of untrusted data.";
2
- //# sourceMappingURL=java.d.ts.map
@@ -6,4 +6,3 @@ export const JAVA_RULES = `### Java
6
6
  - \`Optional.get()\` or collection access without checking presence; modification of a collection while iterating it.
7
7
  - Transaction boundaries that do not cover all related writes; \`@Transactional\` on private or self-invoked methods.
8
8
  - SQL or JPQL built by string concatenation from input; deserialization of untrusted data.`;
9
- //# sourceMappingURL=java.js.map
@@ -1,2 +1 @@
1
1
  export declare const PERFORMANCE_RULES = "### Performance\n- Algorithmic complexity that grows with input the code cannot bound: nested loops over the same collections, repeated linear searches or `includes` inside loops where a set or map fits, sorting inside loops.\n- Round trips in loops: database queries, HTTP calls or file reads per item (N+1) where one batched call works; queries on new filters that fetch unbounded result sets without a limit or pagination.\n- Blocking work on latency-sensitive paths: synchronous file, network or CPU-heavy work in request handlers, event loops, UI threads or `async` functions.\n- Memory: whole files, streams or result sets buffered when their size is external; caches, maps or listener lists that grow without eviction or removal.\n- Repeated work on hot paths: recomputation or re-parsing inside loops, regular expressions or serializers rebuilt per call, React renders triggered by unstable dependencies or props.\n- Concurrency: independent I/O awaited one after another on a latency-critical path; unbounded parallelism that overwhelms a pool, a rate limit or memory.\n- Regressions of existing optimizations: removed indexes, caches, batching, streaming or early exits.";
2
- //# sourceMappingURL=performance.d.ts.map
@@ -6,4 +6,3 @@ export const PERFORMANCE_RULES = `### Performance
6
6
  - Repeated work on hot paths: recomputation or re-parsing inside loops, regular expressions or serializers rebuilt per call, React renders triggered by unstable dependencies or props.
7
7
  - Concurrency: independent I/O awaited one after another on a latency-critical path; unbounded parallelism that overwhelms a pool, a rate limit or memory.
8
8
  - Regressions of existing optimizations: removed indexes, caches, batching, streaming or early exits.`;
9
- //# sourceMappingURL=performance.js.map
@@ -1,2 +1 @@
1
1
  export declare const PYTHON_RULES = "### Python\n- Mutable default arguments or class attributes shared across calls or instances when per-call state was intended.\n- Broad `except` (bare or `Exception`) that swallows errors, including `KeyboardInterrupt`/`SystemExit` via bare `except`, or re-raises without the original cause.\n- Resources opened without `with` or `try/finally` on paths that can raise.\n- Blocking calls inside `async def` code, coroutines that are never awaited, or tasks created without keeping a reference.\n- Truthiness checks that misclassify valid values (`0`, `\"\"`, empty collections) where `is None` was meant.\n- Late-binding closures in loops, iteration while mutating the same collection, integer vs float division mistakes.\n- SQL, shell or template strings built from input instead of parameters; `pickle`/`yaml.load` on untrusted data.";
2
- //# sourceMappingURL=python.d.ts.map
@@ -6,4 +6,3 @@ export const PYTHON_RULES = `### Python
6
6
  - Truthiness checks that misclassify valid values (\`0\`, \`""\`, empty collections) where \`is None\` was meant.
7
7
  - Late-binding closures in loops, iteration while mutating the same collection, integer vs float division mistakes.
8
8
  - SQL, shell or template strings built from input instead of parameters; \`pickle\`/\`yaml.load\` on untrusted data.`;
9
- //# sourceMappingURL=python.js.map
@@ -1,2 +1 @@
1
1
  export declare const SECURITY_RULES = "### Security\n- Injection from input that reaches an interpreter: SQL or NoSQL built from strings, shell commands, template rendering, LDAP or XPath, HTML without escaping (XSS), headers or log lines with raw newlines.\n- Server-side request forgery and path traversal: URLs, hosts or file paths built from input without an allow-list or containment check, including archive extraction.\n- Authentication and authorization: new routes, handlers, jobs or queries without the checks their neighbours apply; object access by id without an ownership or tenant check (IDOR); privilege or role checks that can be bypassed or were weakened.\n- Secrets and sensitive data: credentials or tokens in code or config, secrets or personal data written to logs, errors, analytics or responses; session tokens or API keys exposed to the client.\n- Cryptography: home-made crypto, weak or misused algorithms (MD5/SHA-1 for passwords, ECB, static IVs), non-cryptographic randomness for tokens, disabled certificate or signature verification, timing-unsafe secret comparison.\n- Unsafe parsing: deserialization of untrusted data (pickle, Java serialization, YAML full loaders), XML external entities, prototype pollution through deep merges, regular expressions with catastrophic backtracking on input.\n- Resource exhaustion from untrusted input: unbounded sizes, counts, recursion or allocation that an external caller controls.\n- Configuration: permissive CORS with credentials, cookies without Secure/HttpOnly/SameSite where they carry sessions, debug modes or verbose errors enabled in production paths, world-writable files.\n- CI and supply chain: untrusted pull request text or branch names interpolated into workflow `run:` steps, `pull_request_target` checking out untrusted code with secrets, broadened workflow permissions, new dependencies from unexpected sources or install scripts.";
2
- //# sourceMappingURL=security.d.ts.map
@@ -8,4 +8,3 @@ export const SECURITY_RULES = `### Security
8
8
  - Resource exhaustion from untrusted input: unbounded sizes, counts, recursion or allocation that an external caller controls.
9
9
  - Configuration: permissive CORS with credentials, cookies without Secure/HttpOnly/SameSite where they carry sessions, debug modes or verbose errors enabled in production paths, world-writable files.
10
10
  - CI and supply chain: untrusted pull request text or branch names interpolated into workflow \`run:\` steps, \`pull_request_target\` checking out untrusted code with secrets, broadened workflow permissions, new dependencies from unexpected sources or install scripts.`;
11
- //# sourceMappingURL=security.js.map
@@ -1,2 +1 @@
1
1
  export declare const TYPESCRIPT_RULES = "### TypeScript and JavaScript\n- Promises that are neither awaited, returned nor explicitly handled, so failures become unhandled rejections or ordering is lost; `forEach` with async callbacks that callers assume completed.\n- `await` inside loops where independent work was meant to run concurrently, or `Promise.all` over work that must be sequential or bounded.\n- Truthiness checks that misclassify valid values (`0`, `\"\"`, `NaN`, `false`) where `??` or an explicit comparison was needed; `==` comparisons with surprising coercion.\n- Type assertions (`as`, non-null `!`, `any`) that bypass a check the runtime data can actually fail; parsed external data used without validation.\n- Mutation of arguments, shared module state or React state/props in place; missing or wrong hook dependencies that cause stale values or infinite loops.\n- Floating timers, listeners or subscriptions without cleanup on unmount, abort or error.\n- `JSON.parse`, `new URL`, `BigInt` and similar calls on external input without handling their exceptions.";
2
- //# sourceMappingURL=typescript.d.ts.map
@@ -6,4 +6,3 @@ export const TYPESCRIPT_RULES = `### TypeScript and JavaScript
6
6
  - Mutation of arguments, shared module state or React state/props in place; missing or wrong hook dependencies that cause stale values or infinite loops.
7
7
  - Floating timers, listeners or subscriptions without cleanup on unmount, abort or error.
8
8
  - \`JSON.parse\`, \`new URL\`, \`BigInt\` and similar calls on external input without handling their exceptions.`;
9
- //# sourceMappingURL=typescript.js.map
@@ -1,3 +1,2 @@
1
1
  export type Language = "typescript" | "python" | "go" | "java";
2
2
  export declare function detectLanguage(path: string): Language | undefined;
3
- //# sourceMappingURL=languages.d.ts.map
@@ -17,4 +17,3 @@ export function detectLanguage(path) {
17
17
  const dot = name.lastIndexOf(".");
18
18
  return dot > 0 ? EXTENSIONS[name.slice(dot + 1).toLowerCase()] : undefined;
19
19
  }
20
- //# sourceMappingURL=languages.js.map
@@ -10,4 +10,3 @@ export type SourcedRule = RepoRule & {
10
10
  };
11
11
  export declare const REPO_RULES_PATH = ".ocra/rules.json";
12
12
  export declare function parseRepoRules(json: string): RepoRule[];
13
- //# sourceMappingURL=repo-rules.d.ts.map
@@ -20,4 +20,3 @@ export function parseRepoRules(json) {
20
20
  }
21
21
  return parsed.data.rules;
22
22
  }
23
- //# sourceMappingURL=repo-rules.js.map
@@ -1,4 +1,3 @@
1
1
  import type { RepoRule } from "./repo-rules.js";
2
2
  import type { RuleSet } from "./rule-set.js";
3
3
  export declare function resolveRules(paths: readonly string[], repoRules: readonly RepoRule[], builtin?: RuleSet): string;
4
- //# sourceMappingURL=resolve.d.ts.map
@@ -24,4 +24,3 @@ export function resolveRules(paths, repoRules, builtin = {}) {
24
24
  }
25
25
  return sections.join("\n\n");
26
26
  }
27
- //# sourceMappingURL=resolve.js.map
@@ -3,4 +3,3 @@ export interface RuleSet {
3
3
  general?: string;
4
4
  languages?: Partial<Record<Language, string>>;
5
5
  }
6
- //# sourceMappingURL=rule-set.d.ts.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=rule-set.js.map
@@ -1,4 +1,4 @@
1
- import type { Usage } from "../contracts.js";
1
+ import type { AttemptRecord, IncompleteEnding, Usage } from "../contracts.js";
2
2
  import type { QuotaError } from "./quota.js";
3
3
  export declare const MAX_AGENT_STEPS = 30;
4
4
  export declare const RESUME_MESSAGE: string;
@@ -9,6 +9,9 @@ export interface AttemptOutcome {
9
9
  toolCalls: string[];
10
10
  text: string;
11
11
  resumed?: true;
12
+ atStepCap?: true;
13
+ read?: string[];
14
+ searched?: string[];
12
15
  usage: Usage;
13
16
  error?: AttemptError;
14
17
  }
@@ -19,4 +22,14 @@ export interface AttemptError {
19
22
  }
20
23
  export declare function attemptSummary(model: string, outcome: AttemptOutcome): string;
21
24
  export declare function toolSummary(toolCalls: readonly string[]): string;
22
- //# sourceMappingURL=attempt.d.ts.map
25
+ export type AttemptEnding = "done" | IncompleteEnding | "error";
26
+ export declare function attemptEnding(outcome: AttemptOutcome): AttemptEnding;
27
+ export interface ToolUse {
28
+ name: string;
29
+ input: unknown;
30
+ }
31
+ export declare function exploredBy(uses: readonly ToolUse[]): {
32
+ read: string[];
33
+ searched: string[];
34
+ };
35
+ export declare function attemptRecord(model: string, outcome: AttemptOutcome): AttemptRecord;
@@ -1,3 +1,4 @@
1
+ import { z } from "zod";
1
2
  import { REVIEW_TOOLS } from "../review/tools.js";
2
3
  // Each step resends the whole conversation, so an unbounded loop is the
3
4
  // largest cost risk. At 20 steps a quarter of the review tasks on Vertex
@@ -34,4 +35,49 @@ export function toolSummary(toolCalls) {
34
35
  const finished = names.includes(REVIEW_TOOLS.taskDone) ? "" : "; no task_done";
35
36
  return `${toolCalls.length} tool call(s) (${byUse.map(([n, c]) => `${n} ${c}`).join(", ")}${finished})`;
36
37
  }
37
- //# sourceMappingURL=attempt.js.map
38
+ export function attemptEnding(outcome) {
39
+ if (outcome.error)
40
+ return "error";
41
+ if (outcome.toolCalls.includes(REVIEW_TOOLS.taskDone))
42
+ return "done";
43
+ return outcome.atStepCap ? "step_cap" : "stopped_early";
44
+ }
45
+ // A model chooses these strings, so the session log keeps a bounded number
46
+ // of bounded ones.
47
+ const MAX_EXPLORED = 200;
48
+ const MAX_EXPLORED_CHARS = 500;
49
+ const MAX_TEXT_CHARS = 4_000;
50
+ // The files an attempt read and what it searched for, from its tool calls.
51
+ export function exploredBy(uses) {
52
+ return {
53
+ read: distinct(uses, REVIEW_TOOLS.readFile, (input) => readInput.safeParse(input).data?.path),
54
+ searched: distinct(uses, REVIEW_TOOLS.codeSearch, (input) => searchInput.safeParse(input).data?.literal),
55
+ };
56
+ }
57
+ const readInput = z.object({ path: z.string() });
58
+ const searchInput = z.object({ literal: z.string() });
59
+ function distinct(uses, tool, pick) {
60
+ const values = new Set();
61
+ for (const use of uses) {
62
+ const value = use.name === tool ? pick(use.input) : undefined;
63
+ if (value !== undefined)
64
+ values.add(cut(value, MAX_EXPLORED_CHARS));
65
+ if (values.size >= MAX_EXPLORED)
66
+ break;
67
+ }
68
+ return [...values];
69
+ }
70
+ export function attemptRecord(model, outcome) {
71
+ return {
72
+ model,
73
+ read: outcome.read ?? [],
74
+ searched: outcome.searched ?? [],
75
+ // The end of an answer is where a reviewer concludes.
76
+ text: outcome.text.length > MAX_TEXT_CHARS
77
+ ? `…${outcome.text.slice(-MAX_TEXT_CHARS)}`
78
+ : outcome.text,
79
+ };
80
+ }
81
+ function cut(text, max) {
82
+ return text.length > max ? `${text.slice(0, max)}…` : text;
83
+ }
@@ -16,4 +16,3 @@ export declare class ChainRunner {
16
16
  complete(request: CompletionRequest, signal: AbortSignal): Promise<CompletionResult>;
17
17
  private refusal;
18
18
  }
19
- //# sourceMappingURL=chain-runner.d.ts.map
@@ -60,4 +60,3 @@ export class ChainRunner {
60
60
  function noModel(tier) {
61
61
  return new OcraError("CONFIG_INVALID", `No model configured for the "${tier}" tier; set models.${tier} in .ocra/config.json or OCRA_MODEL_${tier.toUpperCase()}`);
62
62
  }
63
- //# sourceMappingURL=chain-runner.js.map
@@ -11,4 +11,3 @@ export interface EffortCapability {
11
11
  export declare function effortCapability(model: string): EffortCapability | undefined;
12
12
  export declare const FALLBACK_OUTPUT_LIMIT = 32000;
13
13
  export declare function thinkingBudget(capability: EffortCapability, level: Effort, outputLimit?: number): number | undefined;
14
- //# sourceMappingURL=effort-capability.d.ts.map
@@ -67,4 +67,3 @@ export function thinkingBudget(capability, level, outputLimit) {
67
67
  return undefined;
68
68
  return Math.min(max, Math.max(min, Math.floor(limit * BUDGET_SHARE[level])));
69
69
  }
70
- //# sourceMappingURL=effort-capability.js.map
@@ -20,4 +20,3 @@ export interface CompleteOptions {
20
20
  attempt(model: string): Promise<AttemptOutcome>;
21
21
  }
22
22
  export declare function completeWithFailback(options: CompleteOptions): Promise<CompletionResult>;
23
- //# sourceMappingURL=failback.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import { addUsage, emptyUsage } from "../agent/usage.js";
2
2
  import { CompletionError } from "../errors.js";
3
- import { attemptSummary } from "./attempt.js";
3
+ import { attemptEnding, attemptRecord, attemptSummary, } from "./attempt.js";
4
4
  import { sleep } from "./quota.js";
5
5
  // Findings from a failed attempt are still emitted: the pipeline deduplicates
6
6
  // by fingerprint, so a retry on the next model cannot double-report them.
@@ -18,10 +18,13 @@ export async function* withFailback(options) {
18
18
  taskId,
19
19
  message: `${model} is rate limited; waiting ${Math.ceil(pause / 1000)}s`,
20
20
  };
21
- await sleep(pause, signal);
21
+ await pauseOver(health, model, signal);
22
22
  if (signal.aborted)
23
23
  return;
24
24
  }
25
+ // Another task may have found it out of quota since the chain was read.
26
+ if (health.isOutOfQuota(model))
27
+ break;
25
28
  yield { type: "progress", taskId, message: `reviewing with ${model}` };
26
29
  // Spend is reported while the attempt runs, so a run's spend limit
27
30
  // can stop it; the finished attempt's total settles the rest.
@@ -32,18 +35,27 @@ export async function* withFailback(options) {
32
35
  yield { type: "usage", taskId, ...live.take() };
33
36
  }
34
37
  const outcome = await running;
38
+ const ended = attemptEnding(outcome);
35
39
  yield { type: "usage", taskId, ...live.rest(outcome.usage) };
36
- yield { type: "progress", taskId, message: attemptSummary(model, outcome) };
40
+ yield {
41
+ type: "progress",
42
+ taskId,
43
+ message: attemptSummary(model, outcome),
44
+ attempt: attemptRecord(model, outcome),
45
+ };
37
46
  for (const finding of outcome.findings)
38
47
  yield { type: "finding", taskId, finding, model };
39
- // A cancelled attempt is neither finished nor the model's fault.
40
- if (signal.aborted)
41
- return;
48
+ // Ended without an error, the attempt finished even if the task was
49
+ // stopped meanwhile, as when the spend its last report added reached
50
+ // the run's limit: the pipeline decides what that stop means.
42
51
  if (!outcome.error) {
43
52
  health.recordSuccess(model);
44
- yield { type: "done", taskId };
53
+ yield doneEvent(taskId, ended);
45
54
  return;
46
55
  }
56
+ // A cancelled attempt is neither finished nor the model's fault.
57
+ if (signal.aborted)
58
+ return;
47
59
  if (!outcome.error.retryable) {
48
60
  yield {
49
61
  type: "error",
@@ -72,6 +84,11 @@ export async function* withFailback(options) {
72
84
  retryable: true,
73
85
  };
74
86
  }
87
+ function doneEvent(taskId, ended) {
88
+ return ended === "step_cap" || ended === "stopped_early"
89
+ ? { type: "done", taskId, ended }
90
+ : { type: "done", taskId };
91
+ }
75
92
  // Hands out what an attempt has spent in increments, each what grew since the
76
93
  // last one; `rest` settles the finished attempt's total, so the increments
77
94
  // add up to it and nothing is counted twice.
@@ -141,9 +158,11 @@ export async function completeWithFailback(options) {
141
158
  let lastError = "";
142
159
  for (const model of health.order(options.chain)) {
143
160
  for (;;) {
144
- await sleep(health.pausedFor(model), signal);
161
+ await pauseOver(health, model, signal);
145
162
  if (signal.aborted)
146
163
  throw new CompletionError("cancelled", usage);
164
+ if (health.isOutOfQuota(model))
165
+ break;
147
166
  const outcome = await options.attempt(model);
148
167
  usage = addUsage(usage, outcome.usage);
149
168
  if (!outcome.error) {
@@ -167,9 +186,19 @@ export async function completeWithFailback(options) {
167
186
  }
168
187
  throw new CompletionError(`every ${chainName(options)} failed (${lastError})`, usage);
169
188
  }
189
+ // Waits until the model's pause ends as it stands on waking, not as it stood
190
+ // on falling asleep: another task's limit may have lengthened it, and a
191
+ // request sent inside it would only join it again.
192
+ async function pauseOver(health, model, signal) {
193
+ for (;;) {
194
+ const pause = health.pausedFor(model);
195
+ if (pause <= 0 || signal.aborted || health.isOutOfQuota(model))
196
+ return;
197
+ await sleep(pause, signal);
198
+ }
199
+ }
170
200
  function chainName(options) {
171
201
  return options.agent === undefined
172
202
  ? `${options.tier} model`
173
203
  : `model of ${options.agent}'s own chain`;
174
204
  }
175
- //# sourceMappingURL=failback.js.map
@@ -29,4 +29,3 @@ export declare class ModelHealth {
29
29
  isOutOfQuota(model: string): boolean;
30
30
  recordQuota(model: string, quota: QuotaError): "wait" | "out_of_quota";
31
31
  }
32
- //# sourceMappingURL=models.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { OcraError } from "../errors.js";
2
- import { MAX_QUOTA_WAIT_MS, QUOTA_RETRIES } from "./quota.js";
2
+ import { MAX_QUOTA_WAIT_MS, QUOTA_RETRIES, UNSTATED_QUOTA_WAIT_MS, } from "./quota.js";
3
3
  export function parseModel(model) {
4
4
  const slash = model.indexOf("/");
5
5
  if (slash <= 0 || slash === model.length - 1) {
@@ -73,23 +73,24 @@ export class ModelHealth {
73
73
  isOutOfQuota(model) {
74
74
  return this.outOfQuota.has(model);
75
75
  }
76
- // A rate limit with a short, stated wait pauses the model for every task;
77
- // a daily limit, no stated wait, a long one, or too many waits in a row
78
- // mean the model is out of quota for the rest of the run.
76
+ // A rate limit with a short wait pauses the model for every task; a daily
77
+ // limit, a long stated wait, or too many waits in a row mean the model is
78
+ // out of quota for the rest of the run. Vertex AI's shared quota answers
79
+ // 429 without a wait when it is busy, so a missing wait backs off instead.
80
+ // Tasks running at once are refused together: a limit that arrives while
81
+ // the model is paused joins that pause rather than counting another wait,
82
+ // and only a wait it states can lengthen the pause.
79
83
  recordQuota(model, quota) {
84
+ const now = this.now();
80
85
  const state = this.quotas.get(model) ?? { waits: 0, pausedUntil: 0 };
81
- const wait = quota.retryAfterMs;
82
- if (quota.daily ||
83
- wait === undefined ||
84
- wait > MAX_QUOTA_WAIT_MS ||
85
- state.waits >= QUOTA_RETRIES) {
86
+ const joins = state.pausedUntil > now;
87
+ const waits = joins ? state.waits : state.waits + 1;
88
+ const wait = quota.retryAfterMs ?? (joins ? 0 : UNSTATED_QUOTA_WAIT_MS * 2 ** (waits - 1));
89
+ if (quota.daily || wait > MAX_QUOTA_WAIT_MS || waits > QUOTA_RETRIES) {
86
90
  this.outOfQuota.add(model);
87
91
  return "out_of_quota";
88
92
  }
89
- state.waits += 1;
90
- state.pausedUntil = Math.max(state.pausedUntil, this.now() + wait);
91
- this.quotas.set(model, state);
93
+ this.quotas.set(model, { waits, pausedUntil: Math.max(state.pausedUntil, now + wait) });
92
94
  return "wait";
93
95
  }
94
96
  }
95
- //# sourceMappingURL=models.js.map
@@ -3,7 +3,7 @@ export interface QuotaError {
3
3
  daily: boolean;
4
4
  }
5
5
  export declare const MAX_QUOTA_WAIT_MS = 90000;
6
+ export declare const UNSTATED_QUOTA_WAIT_MS = 15000;
6
7
  export declare const QUOTA_RETRIES = 3;
7
8
  export declare function parseQuotaError(message: string, statusCode?: number): QuotaError | undefined;
8
9
  export declare function sleep(ms: number, signal: AbortSignal): Promise<void>;
9
- //# sourceMappingURL=quota.d.ts.map
@@ -1,11 +1,13 @@
1
1
  // Longest wait for a rate limit inside a run; per-minute limits ask for less.
2
2
  export const MAX_QUOTA_WAIT_MS = 90_000;
3
+ // First wait for a rate limit that states none, doubled on each repeat.
4
+ export const UNSTATED_QUOTA_WAIT_MS = 15_000;
3
5
  // Waits per model before it counts as out of quota for the rest of the run.
4
6
  export const QUOTA_RETRIES = 3;
5
7
  const QUOTA_MESSAGE = /exceeded your current quota|quota exceeded|resource[_ ]exhausted|rate limit/i;
6
8
  const RETRY_IN = /retry in ([\d.]+)\s*(ms|s)\b/i;
7
9
  const RETRY_DELAY = /"retryDelay"\s*:\s*"([\d.]+)s"/i;
8
- const DAILY = /per ?day|daily/i;
10
+ const DAILY = /per[- ]?day|daily/i;
9
11
  export function parseQuotaError(message, statusCode) {
10
12
  if (statusCode !== 429 && !QUOTA_MESSAGE.test(message))
11
13
  return undefined;
@@ -35,4 +37,3 @@ export function sleep(ms, signal) {
35
37
  signal.addEventListener("abort", done, { once: true });
36
38
  });
37
39
  }
38
- //# sourceMappingURL=quota.js.map
@@ -2,4 +2,3 @@ import type { ToolDefinition } from "../plugin/types.js";
2
2
  export declare const MAX_LINE_CHARS = 2000;
3
3
  export declare const MAX_RESULT_CHARS = 50000;
4
4
  export declare const reviewTools: readonly ToolDefinition[];
5
- //# sourceMappingURL=tools.d.ts.map
@@ -110,4 +110,3 @@ export const reviewTools = [
110
110
  reportFinding,
111
111
  taskDone,
112
112
  ];
113
- //# sourceMappingURL=tools.js.map
@@ -25,4 +25,3 @@ export interface SarifCandidates {
25
25
  }
26
26
  export declare function sarifCandidates(run: SarifRun): SarifCandidates;
27
27
  export {};
28
- //# sourceMappingURL=candidates.d.ts.map
@@ -99,4 +99,3 @@ function repositoryPath(uri, base) {
99
99
  return undefined;
100
100
  return path;
101
101
  }
102
- //# sourceMappingURL=candidates.js.map
@@ -141,4 +141,3 @@ export declare class SarifError extends OcraError {
141
141
  }
142
142
  export declare function parseSarifLog(text: string): SarifLog;
143
143
  export {};
144
- //# sourceMappingURL=schema.d.ts.map
@@ -68,4 +68,3 @@ export function parseSarifLog(text) {
68
68
  throw new SarifError(`not a SARIF 2.1.0 log: ${z.prettifyError(parsed.error)}`);
69
69
  return parsed.data;
70
70
  }
71
- //# sourceMappingURL=schema.js.map
@@ -3,4 +3,3 @@ export declare const ENV_TEMPLATE_PATTERNS: string[];
3
3
  export declare const NON_REVIEWABLE_EXTENSIONS: string[];
4
4
  export declare const GENERATED_PATTERNS: string[];
5
5
  export declare const MIGRATION_PATTERNS: string[];
6
- //# sourceMappingURL=patterns.d.ts.map
@@ -129,4 +129,3 @@ export const GENERATED_PATTERNS = [
129
129
  "**/__snapshots__/**",
130
130
  ];
131
131
  export const MIGRATION_PATTERNS = ["**/migrations/**", "**/migrate/**", "**/*.migration.*"];
132
- //# sourceMappingURL=patterns.js.map
@@ -25,5 +25,5 @@ export interface SelectionPolicy {
25
25
  }
26
26
  export declare const defaultSelectionPolicy: SelectionPolicy;
27
27
  export declare function isSecretPath(path: string): boolean;
28
+ export declare function foldPath(path: string): string;
28
29
  export declare function selectFiles(diffs: readonly FileDiff[], policy?: SelectionPolicy): FileDecision[];
29
- //# sourceMappingURL=select.d.ts.map
@@ -20,8 +20,22 @@ const isSecret = picomatch(SECRET_PATTERNS, { ...globOptions, ignore: ENV_TEMPLA
20
20
  const isGenerated = picomatch(GENERATED_PATTERNS, globOptions);
21
21
  const isMigration = picomatch(MIGRATION_PATTERNS, globOptions);
22
22
  const nonReviewableExtensions = new Set(NON_REVIEWABLE_EXTENSIONS);
23
+ // The raw path is matched too: NFKC can fold a character into "/", which a
24
+ // pattern's "*" matches only in the raw path.
23
25
  export function isSecretPath(path) {
24
- return isSecret(path);
26
+ return isSecret(path) || isSecret(foldPath(path));
27
+ }
28
+ const IGNORABLE = /\p{Default_Ignorable_Code_Point}/gu;
29
+ // A case-insensitive file system opens a file under any name that folds to
30
+ // the same as its own. APFS normalizes and applies full Unicode case folding,
31
+ // so a Kelvin sign opens "k", a long s "s", "ß" "ss" and a ligature its
32
+ // letters; HFS+ also skips some invisible characters. The access policy
33
+ // compares this form, which folds the ASCII names it refuses at least as far,
34
+ // so that no spelling of such a name passes. NFKC takes the Kelvin sign, the
35
+ // long s and ligatures to ASCII; upper-casing expands "ß" (and "ẞ", once
36
+ // lower-cased), which lower-casing keeps.
37
+ export function foldPath(path) {
38
+ return path.normalize("NFKC").replace(IGNORABLE, "").toLowerCase().toUpperCase().toLowerCase();
25
39
  }
26
40
  export function selectFiles(diffs, policy = defaultSelectionPolicy) {
27
41
  const isUserExcluded = matcher(policy.exclude);
@@ -35,7 +49,7 @@ function exclusionReason(diff, policy, isUserExcluded, isUserIncluded) {
35
49
  const path = diff.newPath;
36
50
  if (diff.isBinary)
37
51
  return "binary";
38
- if (isSecret(diff.oldPath) || isSecret(path))
52
+ if (isSecretPath(diff.oldPath) || isSecretPath(path))
39
53
  return "secret";
40
54
  if (diff.kind === "deleted")
41
55
  return "deleted";
@@ -59,4 +73,3 @@ function extension(path) {
59
73
  const dot = name.lastIndexOf(".");
60
74
  return dot > 0 ? name.slice(dot + 1).toLowerCase() : "";
61
75
  }
62
- //# sourceMappingURL=select.js.map
@@ -4,7 +4,7 @@ export declare const REPORT_FILE = "report.json";
4
4
  export declare class JsonlSessionWriter {
5
5
  readonly dir: string;
6
6
  readonly id: string;
7
- constructor(sessionsDir: string, id?: string);
7
+ private readonly sealKey;
8
+ constructor(sessionsDir: string, id?: string, sealKey?: string);
8
9
  write(event: ReviewEvent): void;
9
10
  }
10
- //# sourceMappingURL=jsonl.d.ts.map
@@ -4,15 +4,20 @@ import { isNotFound, OcraError } from "../errors.js";
4
4
  import { newRunId } from "../pipeline/run-id.js";
5
5
  import { toReportOutput } from "../report/output.js";
6
6
  import { serializeOutput } from "../report/serialize.js";
7
+ import { sealLine } from "./seal.js";
7
8
  export const EVENTS_FILE = "events.jsonl";
8
9
  export const REPORT_FILE = "report.json";
9
10
  // Events are appended synchronously, one JSON object per line, so the log
10
- // stays valid and ordered even if the process dies mid-run.
11
+ // stays valid and ordered even if the process dies mid-run. With a seal key
12
+ // (this machine's, seal.ts), each line is sealed so that --resume can tell
13
+ // it from a line a change brought into the tree.
11
14
  export class JsonlSessionWriter {
12
15
  dir;
13
16
  id;
14
- constructor(sessionsDir, id = newRunId()) {
17
+ sealKey;
18
+ constructor(sessionsDir, id = newRunId(), sealKey) {
15
19
  this.id = id;
20
+ this.sealKey = sealKey;
16
21
  // The sessions directory lives in the reviewed tree, which may carry
17
22
  // links planted to send the logs, or the .gitignore write, elsewhere.
18
23
  for (const dir of [dirname(sessionsDir), sessionsDir])
@@ -30,7 +35,8 @@ export class JsonlSessionWriter {
30
35
  }
31
36
  }
32
37
  write(event) {
33
- const line = serializeOutput({ time: new Date().toISOString(), ...event }, 0);
38
+ const serialized = serializeOutput({ time: new Date().toISOString(), ...event }, 0);
39
+ const line = this.sealKey ? sealLine(this.sealKey, this.id, serialized) : serialized;
34
40
  appendFileSync(join(this.dir, EVENTS_FILE), `${line}\n`);
35
41
  if (event.type === "run_finished") {
36
42
  const report = toReportOutput(event.report);
@@ -49,4 +55,3 @@ function refuseSymlink(path) {
49
55
  throw error;
50
56
  }
51
57
  }
52
- //# sourceMappingURL=jsonl.js.map
@@ -0,0 +1,2 @@
1
+ import type { ResumedRun } from "../pipeline/resume.js";
2
+ export declare function readResumedRun(sessionsDir: string, runId: string, sealKey: string, warn?: (message: string) => void): Promise<ResumedRun>;