diff-sentry 0.15.0__tar.gz → 0.17.0__tar.gz

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 (165) hide show
  1. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/.claude/rules/detect-setup.md +1 -0
  2. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/.claude/rules/monitoring.md +7 -2
  3. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/.env.example +8 -0
  4. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/AGENTS.md +4 -4
  5. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/CHANGELOG.md +32 -0
  6. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/PKG-INFO +4 -4
  7. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/README.md +2 -2
  8. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/action.yml +1 -1
  9. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/__init__.py +1 -1
  10. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/cli.py +95 -15
  11. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/config.py +28 -1
  12. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/deep_classify.py +12 -4
  13. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/detect.py +12 -3
  14. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/emit.py +2 -0
  15. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/images.py +6 -1
  16. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/indicators.py +7 -1
  17. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/normalize.py +40 -3
  18. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/releases.py +62 -5
  19. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/response.py +8 -3
  20. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/schema.py +4 -0
  21. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/skills/ci-and-workflows.md +1 -1
  22. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/skills/package-and-build-hooks.md +2 -2
  23. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/skills/runtime-droppers-and-exfil.md +5 -1
  24. diff_sentry-0.17.0/diff_sentry/skills/triage-a-change.md +148 -0
  25. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/watch.py +379 -42
  26. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/docs/how-it-works.md +1 -1
  27. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/docs/release-watch.md +22 -2
  28. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/docs/watch.md +9 -1
  29. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/pyproject.toml +2 -2
  30. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/studio/DESIGN.md +1 -1
  31. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/studio/static/app.js +1 -0
  32. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/studio/tests/test_app.py +2 -1
  33. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/corpus/change_corpus.json +38 -0
  34. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_cli_watch.py +8 -0
  35. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_config.py +31 -1
  36. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_deep_classify.py +15 -0
  37. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_detection_quality.py +3 -3
  38. diff_sentry-0.17.0/tests/test_release_final.py +709 -0
  39. diff_sentry-0.17.0/tests/test_sft_trace.py +99 -0
  40. diff_sentry-0.17.0/tests/test_skills.py +147 -0
  41. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_watch.py +123 -0
  42. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_watch_pool.py +19 -4
  43. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/uv.lock +5 -5
  44. diff_sentry-0.15.0/diff_sentry/skills/triage-a-change.md +0 -59
  45. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/.claude/rules/handoff.md +0 -0
  46. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/.claude/rules/indicators.md +0 -0
  47. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/.claude/rules/rubric-and-eval.md +0 -0
  48. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/.claude/skills/release/SKILL.md +0 -0
  49. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/.github/workflows/ci.yml +0 -0
  50. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/.github/workflows/release.yml +0 -0
  51. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/.gitignore +0 -0
  52. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/.python-version +0 -0
  53. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/LICENSE +0 -0
  54. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/VENDOR.md +0 -0
  55. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/__main__.py +0 -0
  56. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/actors.py +0 -0
  57. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/assemble.py +0 -0
  58. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/dbutil.py +0 -0
  59. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/fetch_tool.py +0 -0
  60. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/history.py +0 -0
  61. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/hosts.py +0 -0
  62. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/ingest.py +0 -0
  63. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/linewide.py +0 -0
  64. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/npm.py +0 -0
  65. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/pycheck.py +0 -0
  66. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/rl_export.py +0 -0
  67. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/rubric.py +0 -0
  68. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/shelllex.py +0 -0
  69. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/skills/concealment-and-provenance.md +0 -0
  70. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/skills/developer-autorun.md +0 -0
  71. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/skills/llm-directed-text.md +0 -0
  72. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/diff_sentry/snapshot.py +0 -0
  73. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/docs/development.md +0 -0
  74. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/docs/limits.md +0 -0
  75. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/eval/README.md +0 -0
  76. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/eval/diff_sentry_eval/__init__.py +0 -0
  77. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/eval/diff_sentry_eval/__main__.py +0 -0
  78. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/eval/diff_sentry_eval/cli.py +0 -0
  79. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/eval/diff_sentry_eval/judge.py +0 -0
  80. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/eval/diff_sentry_eval/schema.py +0 -0
  81. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/eval/diff_sentry_eval/score.py +0 -0
  82. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/eval/diff_sentry_eval/taskset.py +0 -0
  83. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/eval/pyproject.toml +0 -0
  84. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/eval/taskset.example.json +0 -0
  85. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/eval/tests/conftest.py +0 -0
  86. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/eval/tests/test_boundary.py +0 -0
  87. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/eval/tests/test_cli.py +0 -0
  88. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/eval/tests/test_judge.py +0 -0
  89. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/eval/tests/test_schema.py +0 -0
  90. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/eval/tests/test_score.py +0 -0
  91. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/eval/tests/test_taskset.py +0 -0
  92. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/studio/README.md +0 -0
  93. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/studio/diff_sentry_studio/__init__.py +0 -0
  94. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/studio/diff_sentry_studio/app.py +0 -0
  95. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/studio/diff_sentry_studio/iterations.py +0 -0
  96. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/studio/diff_sentry_studio/live.py +0 -0
  97. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/studio/diff_sentry_studio/mapper.py +0 -0
  98. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/studio/pyproject.toml +0 -0
  99. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/studio/static/index.html +0 -0
  100. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/studio/static/replay-core.js +0 -0
  101. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/studio/static/run-core.js +0 -0
  102. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/studio/static/style.css +0 -0
  103. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/studio/static/trajectory.js +0 -0
  104. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/studio/static/vendor/fonts/jetbrains-mono-400.woff2 +0 -0
  105. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/studio/static/vendor/fonts/jetbrains-mono-700.woff2 +0 -0
  106. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/studio/tests/replay-core.test.js +0 -0
  107. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/studio/tests/run-core.test.js +0 -0
  108. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/studio/tests/static-contract.test.js +0 -0
  109. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/studio/tests/test_iterations.py +0 -0
  110. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/studio/tests/test_live.py +0 -0
  111. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/studio/tests/test_mapper.py +0 -0
  112. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/studio/tests/trajectory.test.js +0 -0
  113. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/__init__.py +0 -0
  114. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/conftest.py +0 -0
  115. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/corpus/hackerbot_claw_campaign.json +0 -0
  116. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/corpus/hackerbot_claw_incident.json +0 -0
  117. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/fixtures/known-malicious.diff +0 -0
  118. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/oracle/__init__.py +0 -0
  119. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/oracle/grammar.py +0 -0
  120. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/oracle/harness.py +0 -0
  121. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/oracle/lexrunner.py +0 -0
  122. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/oracle/programs.py +0 -0
  123. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/oracle/runner.py +0 -0
  124. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_actors.py +0 -0
  125. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_adversarial_input.py +0 -0
  126. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_assemble.py +0 -0
  127. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_campaign_replay.py +0 -0
  128. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_cli.py +0 -0
  129. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_detect.py +0 -0
  130. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_dogfood_gate.py +0 -0
  131. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_emit.py +0 -0
  132. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_enclosure.py +0 -0
  133. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_export.py +0 -0
  134. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_fetch_tool.py +0 -0
  135. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_file_scope.py +0 -0
  136. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_file_structure.py +0 -0
  137. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_forward_offline.py +0 -0
  138. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_gate_edges.py +0 -0
  139. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_grounding.py +0 -0
  140. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_history.py +0 -0
  141. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_hosts.py +0 -0
  142. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_images.py +0 -0
  143. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_incident_hackerbot_claw.py +0 -0
  144. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_indicators.py +0 -0
  145. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_ingest.py +0 -0
  146. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_ingest_metadata.py +0 -0
  147. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_injection_offline.py +0 -0
  148. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_inline_exec_and_bidi.py +0 -0
  149. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_linewide.py +0 -0
  150. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_lookalike_owner.py +0 -0
  151. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_metadata_rules.py +0 -0
  152. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_normalize.py +0 -0
  153. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_npm.py +0 -0
  154. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_oracle.py +0 -0
  155. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_oracle_harness.py +0 -0
  156. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_provenance.py +0 -0
  157. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_python_loader.py +0 -0
  158. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_releases.py +0 -0
  159. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_response.py +0 -0
  160. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_rubric.py +0 -0
  161. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_schema.py +0 -0
  162. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_shelllex.py +0 -0
  163. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_snapshot.py +0 -0
  164. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_subscription.py +0 -0
  165. {diff_sentry-0.15.0 → diff_sentry-0.17.0}/tests/test_workflows.py +0 -0
@@ -14,6 +14,7 @@ paths:
14
14
  - **An empty answer at the cap is a planner that thought too long, not one that cannot follow the format.** A reasoning planner whose call ends `finish_reason=length` with empty content fails the run with `AdapterParseError`. Its message starts "This reply carried no content" when the reply quoted is the promoted reasoning channel, and quotes any other reply as the model wrote it; the raw call's `finish_reason` tells a cut at the cap from a reply that ignored the format. The fix is a thinking budget below `DS_PLANNER_MAX_TOKENS` through `DS_ROOT_LM_KWARGS`, never a whole-run retry or a different adapter.
15
15
  - **`DS_ROOT_LM_KWARGS` / `DS_SUB_LM_KWARGS` are aliases of rlm-harness's `RLM_MAIN_LM_KWARGS` / `RLM_SUB_LM_KWARGS`.** `setup` builds the kit's config itself and never calls the kit's `from_env`, the only reader of those two; `DetectConfig.from_env` reads both names and refuses them set to different values. It also refuses the keys the kit owns (model, endpoint, timeout), so a bad value stops the process rather than failing every run. The analyst's parameters never reach the classifier, which builds its own request.
16
16
  - **`DS_CLASSIFIER_LM_KWARGS` is the classifier's own**, over its `temperature=0.1`. `from_env` refuses the keys its settings own (model, messages, stream, n, timeout, max_tokens, max_completion_tokens) and, when the `classify` extra is installed, any key the OpenAI client does not take, so a bad value stops the process rather than failing every call.
17
+ - **`DS_CLASSIFIER_OMIT_PARAMS` leaves `temperature` and/or `max_tokens` out of the classifier's request**, for an endpoint that refuses them; nothing else may be named, and naming one that `DS_CLASSIFIER_LM_KWARGS` (its `extra_body` included) or `DS_CLASSIFIER_MAX_TOKENS` sets is refused by `from_env`. It removes what the request would send and never stands in for a parameter the endpoint lacks: the endpoint's contract is kept, not faked. A reply cut with no `max_tokens` sent names the endpoint's own limit (`_CutReply.limit is None`).
17
18
  - **A classifier reply cut at `max_tokens` is an unusable reply that names the cut** (`deep_classify._CutReply`, read by the validator), not an endpoint error. The same request is cut the same way, so it is not re-sent, and a classifier that keeps thinking through its budget trips the circuit breaker. A reply cut after a whole verdict still counts. The tool_call records `cut: true`. The fix is a thinking budget in `DS_CLASSIFIER_LM_KWARGS` (raising `DS_CLASSIFIER_MAX_TOKENS` alone can turn a slow model's cut into a timeout).
18
19
  - **An error status that repeats is not re-sent** (`deep_classify.is_fast_fail_http`, passed to `make_model_tool` as `is_fast_fail`): a 400, 401, 403, 404 or 422 from the classifier's endpoint is an endpoint error after one call, and it counts toward the circuit breaker, so a wrong model name, key or request stops being called. A timeout, a transport error, a 408, 409, 429 or 5xx keeps the transient retry and never counts. The eval judge holds its own copy without 400 and 422: its breaker spans a whole batch, and a status one oversized change earns there would leave the later runs unscored.
19
20
  - **Subscription auth is a lazy, opt-in branch.** A role whose model is `claude-agent-sdk/<id>` runs on rlm-harness's `ClaudeAgentLM`, imported only inside `detect._maybe_subscription_lm` and never from `__init__.py`, so `import diff_sentry` stays dspy-free and a proxy-only install never touches the SDK.
@@ -28,11 +28,12 @@ paths:
28
28
  - **The first copy is kept.** `SnapshotStore.put` runs before anything else touches a change; objects are never rewritten and the index is append-only. An edit is a new revision with its own run id (`-r1`), so its trace never overwrites the original's, and `prior_indicators` carry the earlier hits forward so a removed payload cannot remove the evidence. `evidence-scrubbed` fires when a floor-level hit of an earlier revision is gone (matched by rule and location, not id; a payload rewritten to read as prose counts as gone) and names the vanished hit ids, so a later edit that still lacks them is the same finding and does not page again. Snapshot the event as ingested, before correlation attaches facts, so the archive holds what GitHub said and not what we derived.
29
29
  - **Time is the cost, not money.** With a local model every change reaches the model by default; the screen sets the order (`_priority`), not eligibility. The caps (`deep_min_severity`, `max_queue`, `max_deep_per_hour`) default off. A shed change keeps its `screened/` record and a `shed` state.
30
30
  - **The screen is not a trajectory.** `cli.screen` writes `screened/{run_id}.json`, never a trace, so the rollout corpus stays trajectories. Its early alert is `stage=screen`; the run's own is `stage=final`.
31
- - **A run never shares a thread.** dspy's global configuration is bound to the thread that first set it up. With `workers=1` the worker thread runs the model itself; with more, each run goes to a `spawn` process of a `ProcessPoolExecutor` (its own interpreter and dspy), and the worker thread keeps every read and write of the state (claim, settle, finalize). Never run the model in a thread pool. A child that dies breaks the pool: every run in it counts as a failed attempt and the pool is rebuilt; a run that finished first keeps its result. A stopped pool terminates its children and leaves their rows claimed for `recover()`; an unexpected error settles them as a failed attempt, so a long-lived watcher strands nothing. A claim or a submit that fails touches its own row only. Whatever a child's future raises, a Ctrl-C included, is that run failing, never the worker thread's end. A child exits as soon as its watcher is gone (`_child_init`), so a watcher killed outright cannot leave a run going while a restart runs the same run id again. A run sets the change's state only while it is the change's latest revision (`_mark`). An examined change's row, its queue row and the change shed to make room are written in one transaction (`record_examined`): a change never reads `queued` without a queue row (the next poll would call it unchanged and never run it), and a worker never claims a change without a row. A claim that cannot be followed through is given back (`unclaim`). A stop or a Ctrl-C leaves the runs it cuts off claimed; only an error settles them. More than one worker needs a runner and poster that pickle, checked before any file is opened. The poller is a separate thread and touches no model.
31
+ - **A run never shares a thread.** dspy's global configuration is bound to the thread that first set it up. With `workers=1` the worker thread runs the model itself; with more, each run goes to a `spawn` process of a `ProcessPoolExecutor` (its own interpreter and dspy), and the worker thread keeps every read and write of the state (claim, settle, finalize). Never run the model in a thread pool. A child that dies breaks the pool: every run in it counts as a failed attempt and the pool is rebuilt; a run that finished first keeps its result. A stopped pool terminates its children and leaves their rows claimed for `recover()`; an unexpected error settles them as a failed attempt, so a long-lived watcher strands nothing. A claim or a submit that fails touches its own row only. Whatever a child's future raises, a Ctrl-C included, is that run failing, never the worker thread's end. A child exits as soon as its watcher is gone (`_child_init`), so a watcher killed outright cannot leave a run going while a restart runs the same run id again. A run sets the change's state only while it is the change's latest revision (`_mark`). An examined change's row, its queue row and the change shed to make room are written in one transaction (`record_examined`): a change never reads `queued` without a queue row (the next poll would call it unchanged and never run it), and a worker never claims a change without a row. A claim whose bookkeeping fails backs off like a failed run (`retry`, then `bury` after `_MAX_ATTEMPTS`) and its change reads `queued` again: given back at once, it would come first on the next claim and hold up every run behind it. A stop or a Ctrl-C leaves the runs it cuts off claimed; only an error settles them. More than one worker needs a runner and poster that pickle, checked before any file is opened. The poller is a separate thread and touches no model.
32
32
  - **A failed change must not block the ones behind it, and must be retried.** A failure holds the watermark below it and withholds the page-1 ETag (otherwise the next listing answers 304 and it is never retried), backs off exponentially, and after `_MAX_FAILS` is parked as `error` so it stops holding the listing. The others are skipped by their stored `updated_at`. A listing deeper than `_MAX_PAGES` is reported as truncated, never advanced past silently. A rate-limit refusal (`429`, or `403` saying so) is not a failure of the change: wait for the reset, and `_ingest` subtracts the calls it made from the budget the list responses report.
33
33
  - **A read that failed is not a change.** `_comments` returns None on failure and the event carries `comments_incomplete`; the watcher then keeps what it has instead of judging the empty thread as an edit. Anything that feeds the digest must distinguish "none" from "could not read".
34
- - **Run ids are unambiguous.** `owner__name-pr-7` (`-r1` per revision). Owners cannot contain `_`, so two repositories never collide; the one-off `pr`/`issue` commands keep the `owner-name-pr-7` scheme, which can collide.
34
+ - **Run ids are unambiguous.** `owner__name-pr-7` (`-r1` per revision); a release's are `pypi__`, `npm__` and `oci__` ids, and a GitHub owner named `pypi`, `npm` or `oci` (case-folded: `PyPI__x` and `pypi__x` are one file on a case-insensitive disk) is written `<owner>_gh__` (`watch._ARTIFACT_NAMESPACES`), so a polled change and a release never share an id, a `screened/`, `responses/` or `traces/` file, or a queue row. Owners cannot contain `_`, so no other repository writes `<owner>_gh` and two repositories never collide. The import still refuses a release whose id a polled change uses (`names_change`, in any case), which only a change stored before the `_gh` form can. A queue row's repository stays its event's (`pypi/x` is both a GitHub repository and a package, as the pause reads it). The one-off `pr`/`issue` commands keep the `owner-name-pr-7` scheme, which can collide.
35
35
  - **A failed model run is retried, and pages nothing.** It backs off up to `_MAX_ATTEMPTS` (about four hours, so a local model restarting does not fail the queue) with `cli.run` told `emit_failed=False`, then is buried (`claimed=2`, event kept) for `--requeue-failed`. Claiming counts as an attempt, so an input that kills the process cannot loop across restarts. The queue row stays claimed until the run completes, and `recover()` (called by `serve` and `--once`, never by a read-only look) requeues it under a per-directory `flock`. Neither thread may die on an unexpected exception.
36
+ - **A paused repository is held, never cleared.** `WatchConfig.paused` (`DS_WATCH_PAUSED_REPOS`, `parse_paused`, lower-cased; an `owner/name` is kept as written, and a `pypi/`, `npm/` or `oci/` entry also adds the queue `repo` its release carries when it parses: `releases.parse_packages`' normalized name, `npm.parse_npm_packages`' name, `images.parse_image`'s label; an entry neither form reads is refused, and `--repos` stays `owner/name` only) leaves it out of polling, `due_checks`, `pending_alerts` (before the per-poll slice, so it holds no retry slot), `claim`, and the queue cap's `queue_size`/`lowest` (so it is never shed for another's change). A queue row's repository is read from its event (`json_extract`), never its run id's prefix, which `owner/name-pr` shares. Nothing it stores is written: no row deleted or shed, no watermark, ETag or snapshot touched (only `recover` still buries a run a stop cut off on its last attempt, as for any repository). A pause may name a repository no longer in `repos` (that is the point: its queue outlives the listing), so it is never checked against `repos`; the watcher logs what it holds at start and `stats(paused)` counts it as `queued_paused`.
36
37
  - **Undelivered alerts are retried a few at a time.** `_retry_alerts` re-sends at most `_ALERT_RETRIES_PER_POLL` (5) per poll, so a SIEM that hangs (a POST is bounded by 15 s) cannot stall polling for a whole backlog.
37
38
  - **An alert counts once delivered.** `changes.alerted` gains ids only after the SIEM answered 2xx (`EmitResult.ok`); a refusal or outage leaves `alert_pending`, re-sent from `screened/{run_id}.json` on later polls. `emitted` alone is also True for a 5xx.
38
39
  - **State files are versioned.** `dbutil.open_versioned` stamps `PRAGMA user_version` and refuses a file with tables but another stamp; there is no migration, and the error says to move the directory aside.
@@ -47,6 +48,10 @@ paths:
47
48
 
48
49
  ## Release watch (`releases.py`, `release-watch`)
49
50
 
51
+ - **`release-watch --final` hands over; only `watch` queues and runs.** A recorded comparison (`on_screened`, never a `--check`, `_give_up`, `_screen_tag` or an image's `_failed`) that `releases.final_eligible` passes (files; a grounded hit at `DS_RELEASE_FINAL_MIN_SEVERITY`, `high` or `critical`, that is not only one of `_NOT_READ_RULES`; at most 8 MiB rendered) is written by `watch.spool_final` to `<state>/final-queue/<run_id>.json` (atomically; the temporary file has no `.json` suffix) before its files are recorded. `release-watch` never opens `watch.db`, so a busy or older one cannot fail a comparison, and an older `watch` never sees the file. `Watcher.import_spool` (under `_import_lock`, at the start of `poll_once` before the rate-limit return, of `drain` and of `_run_pool`; never `--stats` or `--requeue-failed`) moves each file to `accepted/` and `offer`s a stub (`repo`, `kind`, `number: null`, `spooled`) with `INSERT OR IGNORE`, so a claimed or buried row is never reset and neither the claim nor the cap reads a large event. It skips a run with a `responses/` file, refuses (`rejected/`) a run id a polled change uses and an unreadable file, and re-offers an accepted file with no queue row and no response. `_claim` loads the event from `accepted/` and buries the row at once when it cannot; `_settle` deletes the file once the row completes. A release row has no change row and no sighting (`_mark` and `finalize` skip it), is never shed and does not count toward `max_queue` (`_SHEDDABLE`), and is paused by its `repo`. Each import writes `final-queue/.consumer` (`runs_model`, `at`); `release-watch --final` refuses to start without a `runs_model: true` marker and warns when it is over an hour old; a `--screen-only` watch writes `false` and imports nothing. `watch --queue-only` polls nothing. An image is handed over once per comparison: `_final_hand_over` skips one whose image, digest and compared image another tag already handed over (`watch.image_handed_over`, a marker `final-queue/images/<sha256>` naming the first run id, written after the spool file, best-effort both ways, never expired, ignored when that run id sits in `rejected/`); `import_spool` never reads the directory. Its screen and `stage=screen` alert are unchanged. With `max_deep_per_hour` set (and not `--screen-only`, which never claims), `_InstanceLock` fails closed where there is no `fcntl`.
52
+ - **A release names itself in the payload.** `releases.artifact_echo(event)` is computed host-side into `run_start` meta (`artifact`) by `cli.run` and `cli.screen`, read back by every response builder (`DetectionResponse.artifact`, None for a PR, an issue, or a stored response that predates it) and sent by `signal_payload` only when present. `source_repo` is a configured `--sources` repository only (`source_configured`), never a publisher or an image's unsigned `vcs:source`, which have names of their own.
53
+ - **What a release's run is shown.** `normalize_event` renders `### RELEASE FACTS` (allow-listed keys of `event["release"]` and an image's, as escaped JSON, bounded) after the files and before any comment, only for a release with files, so the facts never decide whether a release has groundable content (`has_groundable_content`; a release's title already gives it some, as before). It is in the untrusted body, never the MF1 metadata or `raw_content`. `indicators._Change` grounds against `normalize_event(event, facts=False)`, so a planner scan of the facts is `grounded: false`; the planner's `scan_indicators` applies `release_scope` to a release's hits as the baseline does; `detect._withheld` counts `unread_code` and notes, so the planner may answer `inconclusive`.
54
+
50
55
  - **A release is a change.** `release_event` builds a `kind="release"` event (`repo` `pypi/<name>`, run id `pypi__<name>-<version>`, `-r<n>` for files added to a release later) whose files are the members of the new artifacts with content the previous release lacked, labelled `<kind>/<path>` (`wheel/cook.pth`, `sdist/pyproject.toml`), with a unified diff as the patch. It goes through `cli.screen`, so every text and file-structure rule reads it; never add a second scanning path for releases.
51
56
  - **Release facts are host-side facts.** `scan_release` turns `event["release"]` into baseline hits beside `scan_provenance` in `cli._baseline_indicators`: `release-new-install-root` (medium), `release-new-dependency` (low), `release-attestation-dropped` (`high`: the previous release had attestations, all of its files or any, and these files have none), `release-publisher-changed` (`high`: a Trusted Publisher, as kind, repository, workflow, environment and a Google publisher's email, case-folded, that the previous release's attestations did not name; it names the repository whose workflow uploaded, not the source it built from, and needs an attested previous release; read from PyPI's provenance URL in the index, retried when PyPI does not serve it) and `release-publisher-lookalike` (`critical`: that publisher's owner differs from a previous one's only by hyphens), and what was not read, all `high`: `release-shadowed-member` (two members of one artifact install to one path, which pip resolves to the `.data` copy), `release-code-not-read` (a changed member that runs, by suffix or as a build file or script, and was not shown as text: too large, past the diff's 20,000 lines, past a text or patch budget, compiled bytecode, a source file declaring a coding it cannot be read in, and a native module whose name, without its ABI tag, the previous release did not have), and `release-not-fully-read` (an artifact not downloaded, not matching its sha256, not read to its end for any reason, or a comparison given up after five attempts, which is screened and alerts on its own). `scan_release_change` is `scan_change` with `release_scope`, which keeps the mention rules (`prompt-injection`, `codeowners-tamper`, `workflow-tamper`, `privileged-fork-trigger`, `ci-bypass`) at `medium` anywhere in a release: a package's files are read by the programs that import them, a package governs no repository, and a comment mentions these as readily as code. The workflow-content rules (`pwn-request`, `workflow-permission-escalation`) keep their severity in every file, a workflow file of the sdist included: wherever a package carries that content, its code or its build can push it into someone's repository (a worm's shape), and every narrower reading tried had a spelling that hid one. Package code that writes only a code-owners file is a known gap.
52
57
  - **Artifacts are data.** Download only from `pypi.org` and `files.pythonhosted.org` (and the tag comparison's refs and trees from `github.com` and `api.github.com`) over https, no redirects, each body checked against the index's sha256; read archives in memory, never extract, never install. Bounds: a download (`DS_RELEASE_MAX_ARTIFACT_MB`, 256), a release (1 GiB or four downloads), a zip's central directory (32 MiB: the largest of the size the end record states and the zip64 records whenever a locator sits before it, the one zipfile reads right before the locator and the one the locator names; never the member count, which zipfile ignores), members per artifact (50,000, a cut noted), decompressed bytes per artifact (256 MiB, counted by a capped stream so a tar header is bounded too), text kept per comparison (256 MiB), text per member (1 MiB; a larger one is compared by its sha256), patch text per event (16 MiB). A download PyPI does not serve is retried, never judged on part of a release.
@@ -41,11 +41,15 @@ DS_API_KEY=sk-...
41
41
  # Extra request parameters (JSON object, single-quoted) apply over the default temperature of 0.1.
42
42
  # Model, messages, stream, n, timeout, max_tokens and max_completion_tokens are refused (the settings above own them). So is a key the OpenAI client does not take: a parameter only your server knows goes under extra_body.
43
43
  # DS_CLASSIFIER_LM_KWARGS='{"temperature":1,"extra_body":{"thinking_token_budget":1024}}'
44
+ # An endpoint that refuses temperature or max_tokens: leave them out of the request (only these two; off by default).
45
+ # Without max_tokens the reply is bounded by the endpoint's own limit and DS_CLASSIFIER_TIMEOUT.
46
+ # DS_CLASSIFIER_OMIT_PARAMS=temperature,max_tokens
44
47
 
45
48
  # --- RLM runtime ---
46
49
  # DS_INTERPRETER=pyodide # read-not-execute: the sandbox never runs the change. `deno` is an alias.
47
50
  # DS_MAX_ITERATIONS=25
48
51
  # DS_MAX_LLM_CALLS=8 # caps only analyst (llm_query) escalations
52
+ # DS_RUN_TAG=teacher-b25-t0.7 # a label on every recorded planner call (`classify --run-tag` overrides it)
49
53
  # DS_ADAPTER=json # portable structured output (OpenAI + vLLM/NIM)
50
54
  # DS_PLANNER_MAX_TOKENS=16384 # generous, so a reasoning planner isn't truncated to empty content
51
55
  # Extra request parameters per role (JSON object, passed as-is; single-quote it, because `uv --env-file` strips double quotes).
@@ -67,6 +71,8 @@ DS_API_KEY=sk-...
67
71
  # --- Watching a watchlist (`diff-sentry watch`) ---
68
72
  # Time is the only cost with a local model, so the caps are OFF unless set.
69
73
  # DS_WATCH_REPOS=owner/name,other/name # or --repos / --repos-file
74
+ # DS_WATCH_PAUSED_REPOS=owner/name # held, any case: not polled, re-checked, re-alerted or run; its queue waits
75
+ # # (also pypi/<pkg>, npm/@scope/<pkg>, oci/ghcr.io/<owner>/<image>: a --final release's model runs)
70
76
  # DS_WATCH_STATE_DIR=./output/state # watch.db, actors.db, snapshots/
71
77
  # DS_ACCOUNT_HISTORY=clickhouse # watch/pr/issue/actor: look up authors' public history in GH Archive via ClickHouse's public playground (sends the login there; off by default)
72
78
  # DS_WATCH_INTERVAL=60 # seconds between polls (raised if GitHub sends X-Poll-Interval)
@@ -85,3 +91,5 @@ DS_API_KEY=sk-...
85
91
  # DS_RELEASE_IMAGES=ghcr.io/owner/name # release-watch: container images compared by build provenance (or --images)
86
92
  # DS_RELEASE_MAX_LAYER_MB=1024 # release-watch: a larger image layer is not read, which alerts
87
93
  # DS_RELEASE_IMAGE_TAGS=latest # release-watch: floating tags whose moves are judged (or --image-tags)
94
+ # DS_RELEASE_FINAL=1 # release-watch: hand releases screened at the floor to the model via watch's queue (or --final; off)
95
+ # DS_RELEASE_FINAL_MIN_SEVERITY=high # release-watch --final: high or critical
@@ -16,13 +16,13 @@ rlm-harness is an exact PyPI pin (`rlm-harness==X.Y.Z` in `pyproject.toml`, lock
16
16
 
17
17
  - Run via `cli` (`pr` / `issue` / `classify`), never an ad-hoc script. `cli.run(event, …)` is the programmatic entry: it records `<out>/traces/{run_id}.jsonl` (dropping a stale one first, since TraceRecorder appends), writes `<out>/responses/{run_id}.json`, and emits the SIEM signal host-side after the run. It never raises: a crash still writes a `status=failed` response that can signal off the evidence floor. Extend `cli.py` rather than driving `detect_from_event` / `build_response` directly.
18
18
  - Offline: `python -m diff_sentry render <trace> <run_id>` re-renders a response; `python -m diff_sentry export "output/traces/*.jsonl" ds.json` exports the reward-free dataset; `actor <login>` prints an account's dossier and `archive verify` re-hashes the snapshot archive.
19
- - Continuous collection goes through `watch` and `release-watch`, which call `cli.run` (model) or `cli.screen` (deterministic, no creds) and never `detect_from_event` directly. `--screen-only` needs no model roles.
19
+ - Continuous collection goes through `watch` and `release-watch`, which call `cli.run` (model) or `cli.screen` (deterministic, no creds) and never `detect_from_event` directly. `--screen-only` needs no model roles. `release-watch` only screens; with `--final` it hands a release to `watch`'s queue (a spool file under the state directory), and `watch` runs it.
20
20
 
21
21
  ## Hard invariants: do not break
22
22
 
23
23
  - **The change is DATA: read, never execute.** It is a REPL variable under the default `pyodide` interpreter; nothing in it is run, built, or fetched-and-run. An embedded instruction is a `prompt-injection` signal, never a command. Never route the interpreter to `local`.
24
24
  - **Judgement-only SUBMIT; evidence is unioned on read (MF3).** `ChangeVerdict` has no hits field; the planner may only CITE ids (`indicator_ids`). `assemble.assemble_verdict` unions every hit in the trace (run_start `baseline_indicators` ∪ each `scan_indicators` tool_call) and derives `signal = verdict ∈ emit_on OR max severity ≥ SIGNAL_SEVERITY_FLOOR`. A false-benign verdict cannot suppress evidence; a cited id with no recorded hit lands in `cited_unknown_ids`. The floor reads GROUNDED hits only (`floor_indicator_severity`; `max_indicator_severity` reads every hit). The baseline is always grounded. A planner scan is grounded when its region is copied from the change, decoded from a span the change holds (`decoded_from`), or decoded from a value an earlier call of the run decoded (each layer of a multi-layer encoding; the run remembers only decoded values, by digest for the whole run and as text newest-first for a layer cut from a slice). The tool decides this, because it holds the change, and records it on the call. Nothing requires that span to look encoded: the change's author picks the encoding. A hit on text the planner wrote stays in the evidence, marked `grounded: false`, and never lifts a grounded sighting of the same id; a trace without the field reads as grounded. The same assembly runs on every read path (live, re-render, `rl_export`). Never add a hits/severity/signal field to the SUBMIT type or a second signal derivation.
25
- - **An ungroundable input yields `inconclusive`, never a confident verdict.** `inconclusive` is a sanctioned 4th SUBMIT value (`schema.INCONCLUSIVE_VERDICT`) mapped to `status="inconclusive"` + `RefusalInfo(reason="insufficient_evidence")`. The host-side backstop `normalize.has_groundable_content` downgrades even a confident verdict when no groundable content exists. It is a reward-free negative outcome, not an escape hatch for a hard-but-real change, and not in `emit_on`, so hard indicator evidence still signals on its own. The converse is enforced in the loop: on a change with groundable content and nothing GitHub withheld (a patch, or files past its list cap), `ClassifyChange` swaps in `schema.decisive_verdict_model`, which refuses an `inconclusive` SUBMIT twice with a message naming the content; dspy hands the refusal back as the step's output, so the planner decides in the same trajectory (no retry), and the third stands. dspy's extract fallback at the iteration cap runs under `schema.no_refusal` (`detect._FinalExtract`): no turn is left there to answer one.
25
+ - **An ungroundable input yields `inconclusive`, never a confident verdict.** `inconclusive` is a sanctioned 4th SUBMIT value (`schema.INCONCLUSIVE_VERDICT`) mapped to `status="inconclusive"` + `RefusalInfo(reason="insufficient_evidence")`. The host-side backstop `normalize.has_groundable_content` downgrades even a confident verdict when no groundable content exists. It is a reward-free negative outcome, not an escape hatch for a hard-but-real change, and not in `emit_on`, so hard indicator evidence still signals on its own. The converse is enforced in the loop: on a change with groundable content and nothing withheld (a file GitHub sent without its patch, files past its list cap, or a release's `unread_code` or notes, an image's included: `detect._withheld`), `ClassifyChange` swaps in `schema.decisive_verdict_model`, which refuses an `inconclusive` SUBMIT twice with a message naming the content; dspy hands the refusal back as the step's output, so the planner decides in the same trajectory (no retry), and the third stands. dspy's extract fallback at the iteration cap runs under `schema.no_refusal` (`detect._FinalExtract`): no turn is left there to answer one.
26
26
  - **MF1: the metadata sandwich in `normalize_event`.** dspy previews ~1000 chars of head+tail, so an identical derived-metadata header and footer deny the attacker those edges, and attacker-authored metadata fields are capped (`_MAX_META_*`). The title/author ride in `raw_content` so the host-side baseline catches a title-borne injection that skews the planner. Don't flatten the sandwich or lift the caps.
27
27
  - **MF2: enrichment fetch is GitHub-allowlisted and off by default** (`enable_fetch=False`). An injected instruction could steer a fetcher to `https://attacker.tld/?leak=…`: the kit's SSRF guard blocks internal targets, and the `github_hosts` allowlist blocks external ones, re-checked on every redirect hop. Never add a general-purpose fetch or fetch a URL the change names. `fetch_allow_cidrs` only relaxes the resolved-IP layer (fake-IP proxy / split DNS); the syntactic guard still refuses localhost/metadata.
28
28
  - **Indicators are deterministic, pure Python, and in-loop safe.** Rule-level invariants (severity tuning, per-file pairing, `pwn-request`, the tool name) live in `.claude/rules/indicators.md`.
@@ -35,7 +35,7 @@ rlm-harness is an exact PyPI pin (`rlm-harness==X.Y.Z` in `pyproject.toml`, lock
35
35
  - **This is a ROLLOUT source: trajectories, not reward.** `rl_export` passes `reward=None`; labels read the assembled verdict and metrics are objective effort counters. `deep_classify` tool_calls train the classifier; every other action is the planner's. A metric keeps ONE meaning across rlm-harness versions (the corpus mixes them; `run_start.payload.rlm_harness` names the writer): a quantity a newer kit makes observable gets a NEW key that is None where the trace cannot say (e.g. `analyst_failures`). The ATLAS rubric and the eval member stay reward-free too; see `.claude/rules/rubric-and-eval.md`.
36
36
  - **Attack knowledge lives in `diff_sentry/skills/`, not the prompt.** The skill catalog is injected (`load_skills_as_tools(discovery="inject")`) and `read_skill(name)` pulls a body on demand. Fix a wrong convention by editing or adding a skill; `detect.INSTRUCTIONS` holds only identity, the MISSION frame, the tool cost model, the triage loop, and output-gating rules. Skills ship via `packages = ["diff_sentry"]`; a force-include duplicates them and breaks the build.
37
37
  - **Keep the dspy-free modules dspy-free.** `config`, `schema`, `normalize`, `indicators`, `shelllex`, `linewide`, `assemble`, `response`, `emit`, `ingest`, `hosts`, `dbutil`, `actors`, `snapshot`, `watch`, `history`, `releases`, `npm`, `images`, `pycheck`, `rl_export`, and `rubric` must not import dspy at module top, and `import diff_sentry` must not import dspy (`ClassifyChange` / `setup` / `run` / `screen` / `detect_from_event` are lazy PEP 562 re-exports).
38
- - **The trace self-describes the run.** `run_start` meta carries the normalized event, instructions, source echo, `baseline_indicators`, `emit_on`, role→model names, budgets, and the rubric skeleton, so an offline re-render/export re-derives the same `signal` (reading `emit_on` from meta, never current config). Any new per-run config that affects read-time derivation must ride in meta.
38
+ - **The trace self-describes the run.** `run_start` meta carries the normalized event, instructions, source echo, a release's artifact echo (`releases.artifact_echo`), `baseline_indicators`, `emit_on`, role→model names, budgets, and the rubric skeleton, so an offline re-render/export re-derives the same `signal` (reading `emit_on` from meta, never current config). Any new per-run config that affects read-time derivation must ride in meta.
39
39
 
40
40
  ## Topic guides
41
41
 
@@ -54,5 +54,5 @@ Claude Code loads each rule automatically when you touch a matching file; other
54
54
 
55
55
  - rlm-harness owns the generic cores: `make_model_tool` (chat → retry → validate → circuit-break) under `deep_classify`, and the SSRF primitives (`is_safe_url`, `resolved_host_is_safe`, `parse_cidrs`) under `fetch_tool`, which adds the GitHub allowlist, the httpx provider, and tracing.
56
56
  - When this consumer needs a workaround, fix the reusable gap in rlm-harness generically; never special-case diff-sentry there. Consumer values (`DS_*` roles, the verdict schema, indicator rules, the SIEM payload shape) stay here.
57
- - The deterministic tier ships as `cli.screen`, `watch` and `release-watch` (host-side, in front of `cli.run`). Next increments: an optional small single-shot model call inside that tier.
57
+ - The deterministic tier ships as `cli.screen`, `watch` and `release-watch` (host-side, in front of `cli.run`), and it stays model-free: the second stage is the RLM run, so no single-shot model call filters in between.
58
58
  - Two workspace members, never in the `diff_sentry` wheel: `studio/` (`diff-sentry-studio`, the detection console, behind its `live` extra) and `eval/` (`diff-sentry-eval`, the reward-free scorecard). Both read the trace / `DetectionResponse` contract through the public surface only. Keep the root wheel at `packages = ["diff_sentry"]` so `uv build` never sweeps them in.
@@ -2,6 +2,38 @@
2
2
 
3
3
  All notable changes to diff-sentry, a BewAIre-style detector that classifies one GitHub change (PR, issue or push) for malicious intent on [`rlm-harness`](https://github.com/qazbnm456/rlm-harness).
4
4
 
5
+ ## 0.17.0
6
+
7
+ Upgrade from 0.16.0: the planner now reads every added and removed line for sinks before it decides, not only the lines the scanner flagged. The GitHub Action's scan is unchanged, nothing needs configuring, and `rlm-harness==1.25.0` is unchanged.
8
+
9
+ ### Changed
10
+ - **The planner runs a sink pass before any verdict.** One REPL step lists every added or removed line in the change's files that holds a network call, an exec or shell, a deserialiser, a secret read, a workflow expression, a permission or guard, or a hidden value, with trigger files first and lock, minified, vendored and documentation files skipped. Code moved from one place to another is marked as moved. With a 30B planner, malicious recall on the repository's test corpus rose from 0.974 to 1.000, with no new false positive.
11
+ - **What a change says about itself no longer clears a line.** The title, body, comments, commit messages, names and code comments are the author's account; when they disagree with what a line does, the line wins. Five pairings are named as the attack whatever the description says (a secret reaching an outbound channel, fetched bytes being deserialised or run, an attacker-controlled value reaching a privileged shell or prompt, a hidden value reaching exec or the network, and a grant by an author without write access), each with the facts that make it ordinary.
12
+ - **A `benign` rationale names the new sinks the pass found** and why each is ordinary, and any claim about a line quotes that line.
13
+
14
+ ### Fixed
15
+ - **A line break in a filename can no longer end its file section early.** The planner sees it as `\n`, so a crafted name cannot spell a comment or another file's header and hide its own patch.
16
+ - **The package-hook skill's examples are no longer copied from the test corpus.**
17
+
18
+ ## 0.16.0
19
+
20
+ Upgrade from 0.15.0: `release-watch --final` can hand the riskiest releases to the model through `watch`, and `rlm-harness` moves to `==1.25.0`, whose traces record every request the planner was sent. The GitHub Action's scan is unchanged and nothing needs configuring. If you watch a repository whose GitHub owner is named `pypi`, `npm` or `oci`, its new runs get new run ids (see Fixed).
21
+
22
+ ### Added
23
+ - **`release-watch --final` hands a screened release to the model.** With `--final` (or `DS_RELEASE_FINAL=1`), a release or image whose screen reaches `high` (`DS_RELEASE_FINAL_MIN_SEVERITY`) on content it read is queued for the `watch` on the same state directory, so releases share one queue, hourly cap, worker pool, retries and pause with pull requests and issues. The screen's alert is sent as before, and the model's follows as `stage=final` under the same run id. An image that two tags point at, compared with the same image, is run once. `watch --queue-only` runs the queue without polling. See [release-watch](docs/release-watch.md#the-models-judgement---final-opt-in).
24
+ - **A release or image is named in its response and SIEM payload.** `artifact` carries the ecosystem, registry, name, version or tag, digest, and what it was compared with. A publisher or an image's unsigned provenance rides as `publisher` and `claimed_source`, never as the source. A pull request's or issue's payload is unchanged.
25
+ - **`DS_WATCH_PAUSED_REPOS` pauses a watched repository without clearing its state.** Its polling, re-checks, undelivered early alerts and queued model runs wait, nothing stored is touched, and removing it from the list resumes where it stopped. It also pauses a release's model runs, named `pypi/<package>`, `npm/<package>`, `npm/@scope/<package>` or `oci/<registry>/<image>`. `watch --stats` counts the held runs as `queued_paused`.
26
+ - **`DS_CLASSIFIER_OMIT_PARAMS`** leaves `temperature` and/or `max_tokens` out of the classifier's request, for an endpoint that refuses them.
27
+ - **`DS_RUN_TAG`, or `classify --run-tag`, labels every planner call a trace records**, for example with a teacher run's budget or temperature.
28
+
29
+ ### Changed
30
+ - **`rlm-harness==1.25.0`.** Each trace now records what every planner call was sent (an `rlm_setup` event, the raw completion and reasoning of each call, and an `extract` event when the iteration budget runs out), so `rlm_harness.dataset.export_sft_turns(..., render="adapter")` rebuilds those requests exactly. Metrics and labels from `export` keep their meaning.
31
+
32
+ ### Fixed
33
+ - **A GitHub owner named `pypi`, `npm` or `oci` no longer shares run ids with a release.** Pull request 7 of `pypi/x` was `pypi__x-pr-7`, the run id of package `x-pr` version 7, so one could overwrite the other's response and trace. Those owners' runs are now `<owner>_gh__…`; every other repository's and release's ids are unchanged.
34
+ - **Setting `temperature` in `DS_CLASSIFIER_LM_KWARGS`'s `extra_body` while `DS_CLASSIFIER_OMIT_PARAMS` names it is refused at startup**, as a top-level one already was.
35
+ - **A crafted, deeply nested `__pycache__` path in a wheel or image no longer slows the release screen.**
36
+
5
37
  ## 0.15.0
6
38
 
7
39
  Upgrade from 0.14.0: `watch` weighs slash commands by the target repository's own workflows, and can look up an author's older public history if you turn that on. The GitHub Action's scan is unchanged, nothing needs configuring, and `rlm-harness==1.24.0` is unchanged.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: diff-sentry
3
- Version: 0.15.0
3
+ Version: 0.17.0
4
4
  Summary: Catch malicious pull requests before they merge: scan a diff for supply-chain attack patterns with deterministic evidence a model cannot suppress.
5
5
  Author: Boik Su
6
6
  License-Expression: MIT
@@ -10,7 +10,7 @@ Requires-Python: >=3.11
10
10
  Requires-Dist: httpx>=0.27
11
11
  Requires-Dist: packaging>=23
12
12
  Requires-Dist: pydantic>=2.11.0
13
- Requires-Dist: rlm-harness==1.24.0
13
+ Requires-Dist: rlm-harness==1.25.0
14
14
  Provides-Extra: classify
15
15
  Requires-Dist: openai>=1.0; extra == 'classify'
16
16
  Provides-Extra: observe
@@ -43,7 +43,7 @@ jobs:
43
43
  - uses: actions/checkout@v7
44
44
  with:
45
45
  fetch-depth: 0 # the scan diffs against the PR base
46
- - uses: qazbnm456/diff-sentry@v0.15.0
46
+ - uses: qazbnm456/diff-sentry@v0.17.0
47
47
  ```
48
48
 
49
49
  That is the whole setup. The job fails when an indicator at or above `high` fires. Add `push` to `on:` to also scan commits pushed straight to a branch. A push that bypasses branch protection can also delete this workflow, so `watch` and `release-watch` read the repository and its releases from outside.
@@ -96,7 +96,7 @@ If you operate the infrastructure, or maintain a project where a wrong call is e
96
96
  - **Deep classification**: a reasoning model reads a PR, issue or push in a sandbox and returns a verdict next to the evidence. See [How it works](docs/how-it-works.md).
97
97
  - **The studio**: a local console that streams a run as it happens. See [`studio/README.md`](studio/README.md).
98
98
  - **Watch**: monitors a list of repositories, alerts the moment the rules fire, and remembers the accounts and payload hosts it has seen. See [Watching a watchlist](docs/watch.md).
99
- - **Release watch**: compares each new release of the PyPI and npm packages you depend on with the release before it, and alerts when it carries a startup hook, a packed loader or a new install script, or was published without its usual provenance. See [Watching releases](docs/release-watch.md).
99
+ - **Release watch**: compares each new release of the PyPI and npm packages you depend on with the release before it, and alerts when it carries a startup hook, a packed loader or a new install script, or was published without its usual provenance. With `--final` it also hands the riskiest releases to the model through `watch`'s queue. See [Watching releases](docs/release-watch.md).
100
100
  - **Trajectories for training**: every run is recorded, and `export` turns the traces into a reward-free dataset for fine-tuning a smaller planner. See [The full pipeline](docs/how-it-works.md#the-full-pipeline).
101
101
 
102
102
  None of this is needed for the Action, and none of it sends your code anywhere you did not configure yourself.
@@ -21,7 +21,7 @@ jobs:
21
21
  - uses: actions/checkout@v7
22
22
  with:
23
23
  fetch-depth: 0 # the scan diffs against the PR base
24
- - uses: qazbnm456/diff-sentry@v0.15.0
24
+ - uses: qazbnm456/diff-sentry@v0.17.0
25
25
  ```
26
26
 
27
27
  That is the whole setup. The job fails when an indicator at or above `high` fires. Add `push` to `on:` to also scan commits pushed straight to a branch. A push that bypasses branch protection can also delete this workflow, so `watch` and `release-watch` read the repository and its releases from outside.
@@ -74,7 +74,7 @@ If you operate the infrastructure, or maintain a project where a wrong call is e
74
74
  - **Deep classification**: a reasoning model reads a PR, issue or push in a sandbox and returns a verdict next to the evidence. See [How it works](docs/how-it-works.md).
75
75
  - **The studio**: a local console that streams a run as it happens. See [`studio/README.md`](studio/README.md).
76
76
  - **Watch**: monitors a list of repositories, alerts the moment the rules fire, and remembers the accounts and payload hosts it has seen. See [Watching a watchlist](docs/watch.md).
77
- - **Release watch**: compares each new release of the PyPI and npm packages you depend on with the release before it, and alerts when it carries a startup hook, a packed loader or a new install script, or was published without its usual provenance. See [Watching releases](docs/release-watch.md).
77
+ - **Release watch**: compares each new release of the PyPI and npm packages you depend on with the release before it, and alerts when it carries a startup hook, a packed loader or a new install script, or was published without its usual provenance. With `--final` it also hands the riskiest releases to the model through `watch`'s queue. See [Watching releases](docs/release-watch.md).
78
78
  - **Trajectories for training**: every run is recorded, and `export` turns the traces into a reward-free dataset for fine-tuning a smaller planner. See [The full pipeline](docs/how-it-works.md#the-full-pipeline).
79
79
 
80
80
  None of this is needed for the Action, and none of it sends your code anywhere you did not configure yourself.
@@ -40,7 +40,7 @@ inputs:
40
40
  that PR rather than by the ones already on main.
41
41
  required: false
42
42
  # KEEP IN STEP WITH [project].version. release.yml fails the build if this drifts from the tag being released, because a stale default here would silently run an old scanner under a new action tag.
43
- default: '0.15.0'
43
+ default: '0.17.0'
44
44
 
45
45
  outputs:
46
46
  failed:
@@ -72,7 +72,7 @@ __all__ = [
72
72
  "screen",
73
73
  ]
74
74
 
75
- __version__ = "0.15.0"
75
+ __version__ = "0.17.0"
76
76
 
77
77
 
78
78
  def __getattr__(name: str): # PEP 562: defer the dspy import to first use
@@ -16,7 +16,8 @@ import os
16
16
  import sys
17
17
  import time
18
18
  from collections.abc import Callable
19
- from dataclasses import dataclass
19
+ from dataclasses import dataclass, replace
20
+ from datetime import UTC, datetime
20
21
 
21
22
  from . import __version__
22
23
  from .config import DetectConfig
@@ -55,6 +56,8 @@ async def detect_from_event(
55
56
  "instructions": task.instructions,
56
57
  # The change under review: echoed into the response envelope + the SIEM signal.
57
58
  "source": _source_echo(event),
59
+ # What a release or image is (`releases.artifact_echo`), echoed the same way; absent for a PR or issue.
60
+ **_artifact_meta(event),
58
61
  # The host-derived facts about the author and the event (account age as of the event, profile, timestamps, fork, commit offsets), so an offline reader sees what the ingest saw.
59
62
  **({"provenance": event["provenance"]} if event.get("provenance") else {}),
60
63
  # The deterministic baseline: assemble unions this with every scan_indicators tool call.
@@ -111,6 +114,13 @@ def _source_echo(event: dict) -> dict:
111
114
  return {k: meta_source.get(k) for k in _SOURCE_KEYS}
112
115
 
113
116
 
117
+ def _artifact_meta(event: dict) -> dict:
118
+ from .releases import artifact_echo
119
+
120
+ artifact = artifact_echo(event)
121
+ return {"artifact": artifact} if artifact else {}
122
+
123
+
114
124
  def _write(path_parts: tuple[str, str], content: str) -> str:
115
125
  d, name = path_parts
116
126
  os.makedirs(d, exist_ok=True)
@@ -203,6 +213,7 @@ def screen(
203
213
  meta = {
204
214
  "event": normalize_event(event),
205
215
  "source": _source_echo(event),
216
+ **_artifact_meta(event),
206
217
  "baseline_indicators": baseline if baseline is not None else _baseline_indicators(event),
207
218
  "emit_on": list(config.emit_on),
208
219
  **({"provenance": event["provenance"]} if event.get("provenance") else {}),
@@ -267,6 +278,8 @@ def _cmd_classify(args) -> int:
267
278
  from .ingest import event_from_payload
268
279
 
269
280
  config = DetectConfig.from_env()
281
+ if args.run_tag is not None:
282
+ config = replace(config, run_tag=args.run_tag.strip() or None)
270
283
  with open(args.payload, "r", encoding="utf-8") as fh:
271
284
  payload = json.load(fh)
272
285
  event = event_from_payload(payload)
@@ -333,18 +346,57 @@ def _cmd_scan(args) -> int:
333
346
  return 1 if failed else 0
334
347
 
335
348
 
349
+ def _final_hand_over(state_dir: str, min_severity: str):
350
+ """`release-watch --final`: a recorded comparison that `final_eligible` passes is handed to the `watch` on `state_dir` (`watch.spool_final`), which queues it for the model under its own hourly cap. An image another tag already handed over, compared with the same image, is not handed over again (`watch.image_handed_over`). The screen and its alert are unchanged."""
351
+ import logging
352
+
353
+ from .releases import final_eligible
354
+ from .watch import _priority, image_handed_over, mark_image_handed_over, spool_final
355
+
356
+ log = logging.getLogger("diff_sentry.releases")
357
+
358
+ def hand_over(event: dict, run_id: str, response) -> None:
359
+ hits = list(response.indicators)
360
+ if not final_eligible(event, hits, min_severity):
361
+ return
362
+ first = image_handed_over(state_dir, event)
363
+ if first is not None and first != run_id: # another tag of the same image, compared with the same image
364
+ log.info("image %s is the image %s already handed over: not handed over again", run_id, first)
365
+ return
366
+ spool_final(state_dir, run_id, _priority(hits, {}), event)
367
+ mark_image_handed_over(state_dir, event, run_id)
368
+ log.info("release %s handed to the model queue", run_id)
369
+
370
+ return hand_over
371
+
372
+
336
373
  def _cmd_release_watch(args) -> int:
337
374
  import logging
338
375
  import signal
339
376
 
377
+ from .config import _env_bool
340
378
  from .images import ImageWatcher
341
379
  from .npm import NpmWatcher, parse_npm_packages
342
380
  from .releases import ReleaseWatcher, parse_packages, parse_sources
381
+ from .watch import consumer_status
343
382
 
344
383
  logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
345
384
  if not math.isfinite(args.interval) or args.interval <= 0:
346
385
  print("release-watch: --interval must be a positive number of seconds", file=sys.stderr)
347
386
  return 2
387
+ on_screened = None
388
+ final = (args.final or _env_bool("DS_RELEASE_FINAL", False)) and not args.check
389
+ if final:
390
+ min_severity = os.getenv("DS_RELEASE_FINAL_MIN_SEVERITY", "high").strip().lower()
391
+ if min_severity not in ("high", "critical"):
392
+ print(f"release-watch: DS_RELEASE_FINAL_MIN_SEVERITY must be high or critical, not {min_severity!r}",
393
+ file=sys.stderr)
394
+ return 2
395
+ problem, _stale = consumer_status(args.state, datetime.now(UTC))
396
+ if problem:
397
+ print(f"release-watch --final: {problem}", file=sys.stderr)
398
+ return 2
399
+ on_screened = _final_hand_over(args.state, min_severity)
348
400
  texts = list(args.packages) + [os.getenv("DS_RELEASE_PACKAGES", "")]
349
401
  try:
350
402
  if args.packages_file:
@@ -359,16 +411,17 @@ def _cmd_release_watch(args) -> int:
359
411
  images = [i for text in [*args.images, os.getenv("DS_RELEASE_IMAGES", "")] for i in text.replace(",", " ").split()]
360
412
  floating = tuple(args.image_tags or os.getenv("DS_RELEASE_IMAGE_TAGS", "latest").replace(",", " ").split())
361
413
  image_watcher = ImageWatcher([] if args.check else images, state_dir=args.state, out_dir=args.out,
362
- floating=floating, emit=not args.no_emit)
414
+ floating=floating, emit=not args.no_emit, on_screened=on_screened)
363
415
  try:
364
416
  sources = parse_sources([*args.sources, os.getenv("DS_RELEASE_SOURCES", "")])
365
417
  watcher = ReleaseWatcher(packages, state_dir=args.state, out_dir=args.out, emit=not args.no_emit,
366
- sources=sources)
418
+ sources=sources, on_screened=on_screened)
367
419
  except BaseException:
368
420
  image_watcher.close()
369
421
  raise
370
422
  try:
371
- npm_watcher = NpmWatcher(npm, state_dir=args.state, out_dir=args.out, emit=not args.no_emit)
423
+ npm_watcher = NpmWatcher(npm, state_dir=args.state, out_dir=args.out, emit=not args.no_emit,
424
+ on_screened=on_screened)
372
425
  except BaseException:
373
426
  image_watcher.close()
374
427
  watcher.close()
@@ -394,6 +447,12 @@ def _cmd_release_watch(args) -> int:
394
447
  try:
395
448
  while not stopping:
396
449
  started = time.monotonic()
450
+ if final: # what it hands over waits in the spool; say so when nothing is taking it
451
+ problem, stale = consumer_status(args.state, datetime.now(UTC))
452
+ if problem or stale:
453
+ logging.getLogger("diff_sentry.releases").warning(
454
+ "release-watch --final: %s", problem or f"the `watch` on {args.state} has not looked "
455
+ "for handed-over releases for over an hour; they wait until it does")
397
456
  watcher.poll_once()
398
457
  npm_watcher.poll_once()
399
458
  image_watcher.poll_once()
@@ -458,7 +517,7 @@ def _cmd_watch(args) -> int:
458
517
  import logging
459
518
  import signal
460
519
 
461
- from .watch import WatchConfig, Watcher, WatchState, parse_repos, requeue_failed
520
+ from .watch import PollReport, WatchConfig, Watcher, WatchState, parse_paused, parse_repos, requeue_failed
462
521
 
463
522
  logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
464
523
  if args.stats:
@@ -467,12 +526,14 @@ def _cmd_watch(args) -> int:
467
526
  print(f"watch: no state at {db}", file=sys.stderr)
468
527
  return 2
469
528
  try:
529
+ env = os.getenv("DS_WATCH_PAUSED_REPOS", "")
530
+ paused = WatchConfig(paused=parse_paused([env])).paused if env else ()
470
531
  state = WatchState(db, read_only=True)
471
- except RuntimeError as exc:
532
+ except (RuntimeError, ValueError) as exc:
472
533
  print(f"watch: {exc}", file=sys.stderr)
473
534
  return 2
474
535
  try:
475
- print(json.dumps(state.stats(), indent=2))
536
+ print(json.dumps(state.stats(paused), indent=2))
476
537
  finally:
477
538
  state.close()
478
539
  return 0
@@ -499,13 +560,15 @@ def _cmd_watch(args) -> int:
499
560
  "recheck_s": int(args.recheck_hours * 3600) if args.recheck_hours is not None else None,
500
561
  "screen_only": args.screen_only or None, "deep_min_severity": args.deep_min_severity,
501
562
  "max_queue": args.max_queue, "max_deep_per_hour": args.max_deep_per_hour, "workers": args.workers,
563
+ "queue_only": args.queue_only or None,
502
564
  }
503
565
  config = WatchConfig.from_env(**overrides) # also parses DS_WATCH_REPOS and the other env knobs
504
566
  except (ValueError, OSError, OverflowError) as exc:
505
567
  print(f"watch: {exc}", file=sys.stderr)
506
568
  return 2
507
- if not config.repos:
508
- print("watch: no repositories — pass --repos / --repos-file or set DS_WATCH_REPOS", file=sys.stderr)
569
+ if not config.repos and not config.queue_only:
570
+ print("watch: no repositories — pass --repos / --repos-file, set DS_WATCH_REPOS, or run --queue-only",
571
+ file=sys.stderr)
509
572
  return 2
510
573
  try:
511
574
  detect = DetectConfig.screen_from_env() if config.screen_only else DetectConfig.from_env()
@@ -523,11 +586,15 @@ def _cmd_watch(args) -> int:
523
586
  try:
524
587
  if args.once:
525
588
  watcher.recover()
526
- report = watcher.poll_once()
589
+ if config.queue_only: # nothing to poll: the hand-overs, counted, then the queue
590
+ report = PollReport()
591
+ watcher.import_hand_overs(report)
592
+ else:
593
+ report = watcher.poll_once()
527
594
  ran = 0 if config.screen_only else watcher.drain()
528
595
  print(f"watch --once: listed={report.listed} new={report.new} revised={report.revised} "
529
596
  f"unchanged={report.unchanged} alerts={report.alerts} queued={report.queued} "
530
- f"shed={report.shed} ran={ran} errors={len(report.errors)}")
597
+ f"shed={report.shed} imported={report.imported} ran={ran} errors={len(report.errors)}")
531
598
  for e in report.errors:
532
599
  print(f" ! {e}", file=sys.stderr)
533
600
  for t in report.truncated:
@@ -637,6 +704,8 @@ def build_parser() -> argparse.ArgumentParser:
637
704
  cl.add_argument("--run-id", default=None)
638
705
  cl.add_argument("--out", default="./output")
639
706
  cl.add_argument("--no-emit", action="store_true", help="do not emit a SIEM signal")
707
+ cl.add_argument("--run-tag", default=None,
708
+ help="a label stamped on every planner call the trace records (overrides DS_RUN_TAG)")
640
709
  cl.set_defaults(func=_cmd_classify)
641
710
 
642
711
  sc = sub.add_parser("scan", help="deterministic indicator scan over text/diff (offline, no creds)")
@@ -654,7 +723,9 @@ def build_parser() -> argparse.ArgumentParser:
654
723
  sc.set_defaults(func=_cmd_scan)
655
724
 
656
725
  w = sub.add_parser("watch", help="monitor a watchlist of repositories (poll, screen, queue for the model)")
657
- w.add_argument("--repos", nargs="+", help="owner/name repositories (or set DS_WATCH_REPOS)")
726
+ w.add_argument("--repos", nargs="+", help="owner/name repositories (or set DS_WATCH_REPOS; DS_WATCH_PAUSED_REPOS "
727
+ "holds repositories, and releases as pypi/<package>, npm/<package> or oci/<image>, "
728
+ "without clearing their queue)")
658
729
  w.add_argument("--repos-file", help="a file of owner/name entries, one per line (# comments allowed)")
659
730
  w.add_argument("--out", default="./output")
660
731
  w.add_argument("--state", default=os.getenv("DS_WATCH_STATE_DIR", "./output/state"),
@@ -664,12 +735,17 @@ def build_parser() -> argparse.ArgumentParser:
664
735
  help="on first sight of a repo, also examine changes updated this recently (default 0)")
665
736
  w.add_argument("--recheck-hours", type=float, default=None,
666
737
  help="re-examine a change for edits / a deleted fork or account for this long (default 24)")
738
+ w.add_argument("--queue-only", action="store_true",
739
+ help="poll nothing: run the model queue and the releases `release-watch --final` hands over "
740
+ "(needs no --repos)")
667
741
  w.add_argument("--screen-only", action="store_true",
668
742
  help="deterministic tier only: archive, correlate, alert; never run the model (no creds)")
669
743
  w.add_argument("--deep-min-severity", default=None, choices=SEVERITIES,
670
744
  help="only queue for the model when the screen reached this severity (default: info = all)")
671
- w.add_argument("--max-queue", type=int, default=None, help="shed the lowest priority beyond this (0 = off)")
672
- w.add_argument("--max-deep-per-hour", type=int, default=None, help="cap model runs per hour (0 = off)")
745
+ w.add_argument("--max-queue", type=int, default=None,
746
+ help="shed the lowest priority beyond this (0 = off; a release from release-watch --final is never shed)")
747
+ w.add_argument("--max-deep-per-hour", type=int, default=None,
748
+ help="cap model runs per hour (0 = off); where there is no fcntl lock, a watch with a cap refuses to start unless --screen-only")
673
749
  w.add_argument("--workers", type=int, default=None,
674
750
  help="model runs at once, each in a process of its own (DS_WATCH_WORKERS, default 1)")
675
751
  w.add_argument("--no-emit", action="store_true", help="do not emit SIEM signals")
@@ -682,7 +758,7 @@ def build_parser() -> argparse.ArgumentParser:
682
758
  w.set_defaults(func=_cmd_watch)
683
759
 
684
760
  rw = sub.add_parser("release-watch",
685
- help="compare each new release of watched PyPI packages with the one before it (no model)")
761
+ help="compare each new release of watched PyPI packages with the one before it (no model; --final hands the riskiest to watch's queue)")
686
762
  rw.add_argument("--packages", nargs="+", default=[], help="PyPI project names (or set DS_RELEASE_PACKAGES)")
687
763
  rw.add_argument("--packages-file", help="a file of project names, one per line (# comments allowed)")
688
764
  rw.add_argument("--npm", nargs="+", default=[], help="npm package names, @scope/name included (or set DS_RELEASE_NPM)")
@@ -701,6 +777,10 @@ def build_parser() -> argparse.ArgumentParser:
701
777
  help="seconds between polls (DS_RELEASE_INTERVAL, default 300)")
702
778
  rw.add_argument("--no-emit", action="store_true", help="do not emit SIEM signals")
703
779
  rw.add_argument("--once", action="store_true", help="one poll, then exit")
780
+ rw.add_argument("--final", action="store_true",
781
+ help="hand a release whose screen reaches high (DS_RELEASE_FINAL_MIN_SEVERITY) on content it read to "
782
+ "the model, through the queue of the `watch` on the same --state and --out (or set "
783
+ "DS_RELEASE_FINAL=1; off by default; not yet validated by an eval)")
704
784
  rw.add_argument("--check", nargs=2, metavar=("PACKAGE", "VERSION"),
705
785
  help="judge one release against the one before it now, print the result, and exit "
706
786
  "(npm:NAME for an npm package)")
@@ -85,6 +85,26 @@ def _classifier_lm_kwargs() -> dict | None:
85
85
  return kw
86
86
 
87
87
 
88
+ # What an endpoint that refuses them may have left out of the classifier's request (`DS_CLASSIFIER_OMIT_PARAMS`).
89
+ _CLASSIFIER_OMITTABLE = ("temperature", "max_tokens")
90
+
91
+
92
+ def _classifier_omit_params(lm_kwargs: dict | None) -> tuple[str, ...]:
93
+ """`DS_CLASSIFIER_OMIT_PARAMS`: the default request parameters an endpoint does not take, left out of every classifier call. Only `temperature` and `max_tokens`; anything else, or a parameter another setting asks for, stops the process here."""
94
+ raw = os.getenv("DS_CLASSIFIER_OMIT_PARAMS", "")
95
+ names = tuple(dict.fromkeys(p.lower() for p in raw.replace(",", " ").split()))
96
+ unknown = [n for n in names if n not in _CLASSIFIER_OMITTABLE]
97
+ if unknown:
98
+ raise ValueError(f"DS_CLASSIFIER_OMIT_PARAMS may name only {', '.join(_CLASSIFIER_OMITTABLE)}, "
99
+ f"not {', '.join(unknown)}")
100
+ sent = set(lm_kwargs or {}) | set((lm_kwargs or {}).get("extra_body") or {}) # extra_body is merged into the request
101
+ if "temperature" in names and "temperature" in sent:
102
+ raise ValueError("DS_CLASSIFIER_OMIT_PARAMS leaves out temperature, which DS_CLASSIFIER_LM_KWARGS sets")
103
+ if "max_tokens" in names and os.getenv("DS_CLASSIFIER_MAX_TOKENS"):
104
+ raise ValueError("DS_CLASSIFIER_OMIT_PARAMS leaves out max_tokens, which DS_CLASSIFIER_MAX_TOKENS sets")
105
+ return names
106
+
107
+
88
108
  @dataclass(frozen=True)
89
109
  class DetectConfig:
90
110
  # Planner (main) + analyst (sub), sharing one OpenAI-compatible proxy. No model name is assumed: `from_env` requires them. Empty defaults are only for direct construction in tests.
@@ -104,6 +124,8 @@ class DetectConfig:
104
124
  classifier_transient_retries: int = 1
105
125
  # Extra request parameters of the classifier's call, over its `temperature=0.1` (`_classifier_lm_kwargs`).
106
126
  classifier_lm_kwargs: dict | None = None
127
+ # Default parameters left out of the classifier's request, for an endpoint that refuses them (`_classifier_omit_params`).
128
+ classifier_omit_params: tuple[str, ...] = ()
107
129
  # After this many CONSECUTIVE unusable replies or repeating error statuses the tool short-circuits (make_model_tool).
108
130
  classifier_circuit_break: int = 4
109
131
 
@@ -120,6 +142,8 @@ class DetectConfig:
120
142
  max_iterations: int = 25
121
143
  max_llm_calls: int = 8 # caps ONLY analyst (llm_query) escalations
122
144
  max_output_chars: int = 10_000 # head+tail char cap dspy.RLM applies to each REPL output
145
+ # A caller's label (e.g. a teacher run's budget/temperature), stamped by rlm-harness on the trace's `rlm_setup` and every recorded planner call. A label only: nothing reads it back.
146
+ run_tag: str | None = None
123
147
 
124
148
  # ── Enrichment fetch (opt-in, GitHub-allowlisted, MF2) ──────────────────────────────────────
125
149
  enable_fetch: bool = False # OFF by default: fetch on attacker input is an exfil surface
@@ -194,6 +218,7 @@ class DetectConfig:
194
218
  RLMConfig(main_model=planner, sub_model=analyst, **{field: kw})
195
219
  except ValueError as exc:
196
220
  raise ValueError(f"{name}: {exc}") from exc
221
+ classifier_kw = _classifier_lm_kwargs()
197
222
  return cls(
198
223
  main_model=planner,
199
224
  sub_model=analyst,
@@ -209,7 +234,8 @@ class DetectConfig:
209
234
  classifier_max_tokens=int(os.getenv("DS_CLASSIFIER_MAX_TOKENS", "2048")),
210
235
  classifier_transient_retries=int(os.getenv("DS_CLASSIFIER_TRANSIENT_RETRIES", "1")),
211
236
  classifier_circuit_break=int(os.getenv("DS_CLASSIFIER_CIRCUIT_BREAK", "4")),
212
- classifier_lm_kwargs=_classifier_lm_kwargs(),
237
+ classifier_lm_kwargs=classifier_kw,
238
+ classifier_omit_params=_classifier_omit_params(classifier_kw),
213
239
  interpreter=os.getenv("DS_INTERPRETER", "pyodide"),
214
240
  observe=_env_bool("DS_OBSERVE", False),
215
241
  adapter=os.getenv("DS_ADAPTER", "json"),
@@ -219,6 +245,7 @@ class DetectConfig:
219
245
  max_iterations=int(os.getenv("DS_MAX_ITERATIONS", "25")),
220
246
  max_llm_calls=int(os.getenv("DS_MAX_LLM_CALLS", "8")),
221
247
  max_output_chars=int(os.getenv("DS_MAX_OUTPUT_CHARS", "10000")),
248
+ run_tag=os.getenv("DS_RUN_TAG", "").strip() or None,
222
249
  enable_fetch=_env_bool("DS_ENABLE_FETCH", False),
223
250
  fetch_timeout=float(os.getenv("DS_FETCH_TIMEOUT", "20")),
224
251
  fetch_max_bytes=int(os.getenv("DS_FETCH_MAX_BYTES", "400000")),