diff-sentry 0.14.0__tar.gz → 0.16.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.
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/.claude/rules/detect-setup.md +1 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/.claude/rules/monitoring.md +9 -2
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/.env.example +9 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/AGENTS.md +6 -6
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/CHANGELOG.md +28 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/PKG-INFO +5 -5
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/README.md +3 -3
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/action.yml +1 -1
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/__init__.py +1 -1
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/cli.py +120 -21
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/config.py +28 -1
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/deep_classify.py +12 -4
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/detect.py +6 -2
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/emit.py +2 -0
- diff_sentry-0.16.0/diff_sentry/history.py +103 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/images.py +6 -1
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/indicators.py +50 -6
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/ingest.py +94 -5
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/normalize.py +37 -2
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/releases.py +62 -5
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/response.py +8 -3
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/schema.py +4 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/watch.py +396 -45
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/docs/how-it-works.md +1 -1
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/docs/limits.md +1 -1
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/docs/release-watch.md +22 -2
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/docs/watch.md +14 -1
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/pyproject.toml +2 -2
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/studio/DESIGN.md +1 -1
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/studio/static/app.js +1 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/studio/tests/test_app.py +2 -1
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_adversarial_input.py +1 -1
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_cli_watch.py +8 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_config.py +31 -1
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_deep_classify.py +15 -0
- diff_sentry-0.16.0/tests/test_history.py +111 -0
- diff_sentry-0.16.0/tests/test_release_final.py +709 -0
- diff_sentry-0.16.0/tests/test_sft_trace.py +99 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_watch.py +123 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_watch_pool.py +19 -4
- diff_sentry-0.16.0/tests/test_workflows.py +165 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/uv.lock +5 -5
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/.claude/rules/handoff.md +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/.claude/rules/indicators.md +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/.claude/rules/rubric-and-eval.md +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/.claude/skills/release/SKILL.md +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/.github/workflows/ci.yml +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/.github/workflows/release.yml +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/.gitignore +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/.python-version +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/LICENSE +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/VENDOR.md +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/__main__.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/actors.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/assemble.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/dbutil.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/fetch_tool.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/hosts.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/linewide.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/npm.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/pycheck.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/rl_export.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/rubric.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/shelllex.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/skills/ci-and-workflows.md +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/skills/concealment-and-provenance.md +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/skills/developer-autorun.md +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/skills/llm-directed-text.md +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/skills/package-and-build-hooks.md +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/skills/runtime-droppers-and-exfil.md +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/skills/triage-a-change.md +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/diff_sentry/snapshot.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/docs/development.md +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/eval/README.md +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/eval/diff_sentry_eval/__init__.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/eval/diff_sentry_eval/__main__.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/eval/diff_sentry_eval/cli.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/eval/diff_sentry_eval/judge.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/eval/diff_sentry_eval/schema.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/eval/diff_sentry_eval/score.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/eval/diff_sentry_eval/taskset.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/eval/pyproject.toml +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/eval/taskset.example.json +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/eval/tests/conftest.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/eval/tests/test_boundary.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/eval/tests/test_cli.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/eval/tests/test_judge.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/eval/tests/test_schema.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/eval/tests/test_score.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/eval/tests/test_taskset.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/studio/README.md +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/studio/diff_sentry_studio/__init__.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/studio/diff_sentry_studio/app.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/studio/diff_sentry_studio/iterations.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/studio/diff_sentry_studio/live.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/studio/diff_sentry_studio/mapper.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/studio/pyproject.toml +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/studio/static/index.html +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/studio/static/replay-core.js +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/studio/static/run-core.js +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/studio/static/style.css +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/studio/static/trajectory.js +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/studio/static/vendor/fonts/jetbrains-mono-400.woff2 +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/studio/static/vendor/fonts/jetbrains-mono-700.woff2 +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/studio/tests/replay-core.test.js +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/studio/tests/run-core.test.js +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/studio/tests/static-contract.test.js +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/studio/tests/test_iterations.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/studio/tests/test_live.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/studio/tests/test_mapper.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/studio/tests/trajectory.test.js +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/__init__.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/conftest.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/corpus/change_corpus.json +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/corpus/hackerbot_claw_campaign.json +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/corpus/hackerbot_claw_incident.json +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/fixtures/known-malicious.diff +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/oracle/__init__.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/oracle/grammar.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/oracle/harness.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/oracle/lexrunner.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/oracle/programs.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/oracle/runner.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_actors.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_assemble.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_campaign_replay.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_cli.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_detect.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_detection_quality.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_dogfood_gate.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_emit.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_enclosure.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_export.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_fetch_tool.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_file_scope.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_file_structure.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_forward_offline.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_gate_edges.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_grounding.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_hosts.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_images.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_incident_hackerbot_claw.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_indicators.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_ingest.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_ingest_metadata.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_injection_offline.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_inline_exec_and_bidi.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_linewide.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_lookalike_owner.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_metadata_rules.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_normalize.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_npm.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_oracle.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_oracle_harness.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_provenance.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_python_loader.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_releases.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_response.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_rubric.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_schema.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_shelllex.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_snapshot.py +0 -0
- {diff_sentry-0.14.0 → diff_sentry-0.16.0}/tests/test_subscription.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,23 +28,30 @@ 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
|
|
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
|
|
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.
|
|
39
40
|
- **Account age is measured as of the event.** `_age_days(created_at, as_of)` takes the event's own time; the wall clock is only the fallback for a payload with none. A replay of a historical incident must carry `created_at`, or every old attacker looks established (`test_campaign_replay` pins this).
|
|
40
41
|
- **Attacker-authored strings stay out of the MF1 sandwich.** Profile fields, branch names, and comments are bounded at ingest and rendered in the untrusted section only. Comments are text-scanned only when the change's author or an outsider wrote them and the commenter is not a `Bot`: maintainers quote install commands and release notes constantly.
|
|
41
42
|
- **Data minimization.** The `email` fields of a profile and of commits are reduced to a domain in the event and masked in the archive (`snapshot.scrub_emails`). Free text is archived as captured: it is evidence. Nothing prunes the archive, the store, or queued events.
|
|
43
|
+
- **The repository's workflows weigh the slash command** (`ingest.repo_workflows`, passed in as `workflows=` by `watch`, cached an hour per repository by `Watcher._repo_workflows`, and by `pr`/`issue`; ingest reads nothing without it). It lists the default branch's `.github/workflows` and reads each file as text, bounded (100 files, more is no facts; 512 KiB each): a file naming `issue_comment` or `pull_request_review_comment` starts on a comment, the quoted `/command` literals on its lines that read the comment are what it matches (`repo_comment_commands`; those of a file with no check on the commenter, `_COMMENTER_GATE_RE`, also in `repo_comment_commands_open`: `author_association`, `github.actor`, the sender or commenter login, a collaborator, member or membership lookup, or a call to a reusable workflow or a local action whose checks are not read), and one with none, or with a `/literal` on a line that does not read the comment (a dispatcher such as `case "$CMD" in "/deploy")`), counts as answering any comment (`repo_comment_workflows_unfiltered`), so no command steps down for it; a `pull_request_target` file that checks out the PR's own code (`ref:` to its head, its merge commit or a pull ref, `repository:` the head repo, `gh pr checkout`, `git checkout`/`switch` to it or to `FETCH_HEAD`; a `git fetch` that only reads the head is not) goes in `repo_prt_head_checkout`. A 404 listing is a fact (no workflows); any other failure, or one file unread or oversized, is no facts, so `scan_metadata` keeps its plain reading. With the facts, a command anyone can run is one step up (author within an hour: `high`, else `medium`), a matched command behind a commenter check keeps the plain reading, and with no comment workflow or no match and no open handler one step down (`low` / `info`). Only GitHub Actions is read: a command an app or outside CI answers is unseen, a sub-floor loss at worst. `scan_provenance` raises `prt-runs-fork-code` (medium) for an outsider's PR when `repo_prt_head_checkout` is non-empty.
|
|
44
|
+
- **Account history is opt-in** (`history.py`): `history.enabled(flag)` is None unless `--account-history` or `DS_ACCOUNT_HISTORY=clickhouse`, because it sends a login to a third party (ClickHouse's public playground, GH Archive's `github_events`). `ingest._provenance` asks it only for a `User` (not `ghost`) and only when a caller passed it in (`watch`, `pr`, `issue`; `actor` prints it), so tests and `scan` never reach the network. The query is parameterised (`{login:String}`, the login checked against GitHub's login shape first) and read as of the event (`param_as_of`, `param_cut` 30 days before it), so a replay sees what was true then. It records `author_history_events_before`, `_repos_before`, `_first_event` and `_last_before_days`; zero events is a fact, a failed query or an answer it cannot read no facts. GH Archive keys events by the login they were made under, so history whose first event is older than the account (`author_account_created_at`) belongs to an earlier holder of the login: it is dropped and `author_history_other_account` recorded instead; a renamed account's events under its old login are not found (a false sub-floor hit at worst). `scan_provenance` reads them: `dormant-account-reactivated` (medium, `_last_before_days` of a year or more, evidence in whole years so a re-ingest keeps the id) and `no-public-history` (low, no events before the window from an account 180 days old or more). The lookup caches each login per day.
|
|
42
45
|
- **Adding a fact:** capture it in `ingest.py` (best-effort: a failed call omits the key, unless the value feeds the digest, in which case mark the event incomplete instead of reporting "none"), put it in `provenance` (or a bounded event field), read it in `scan_provenance` / `scan_metadata` with a negative case, and keep it sub-floor unless it is standalone evidence. Replay the incident corpus.
|
|
43
46
|
- **Read-only means read-only.** `--stats` and `actor` open the state `mode=ro` (`open_versioned(read_only=True)`) and neither create, stamp, nor requeue anything. Only `serve` and `--once` call `recover()`, under the lock.
|
|
44
47
|
- **Terminal output is sanitized.** `format_dossier` replaces control characters; `_json_out` escapes the C1 range `json.dumps` leaves raw; URL and token parsing cut at the first control character. A string an attacker wrote must not be able to drive the operator's terminal.
|
|
45
48
|
|
|
46
49
|
## Release watch (`releases.py`, `release-watch`)
|
|
47
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
|
+
|
|
48
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.
|
|
49
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.
|
|
50
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,7 +71,10 @@ 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/
|
|
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)
|
|
71
78
|
# DS_WATCH_INTERVAL=60 # seconds between polls (raised if GitHub sends X-Poll-Interval)
|
|
72
79
|
# DS_WATCH_BACKFILL_HOURS=0 # on first sight of a repo, also examine changes this recent
|
|
73
80
|
# DS_WATCH_RECHECK_HOURS=24 # shorten the re-check schedule (15 min, 1 h, 6 h, 24 h); it cannot extend it
|
|
@@ -84,3 +91,5 @@ DS_API_KEY=sk-...
|
|
|
84
91
|
# DS_RELEASE_IMAGES=ghcr.io/owner/name # release-watch: container images compared by build provenance (or --images)
|
|
85
92
|
# DS_RELEASE_MAX_LAYER_MB=1024 # release-watch: a larger image layer is not read, which alerts
|
|
86
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
|
|
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`.
|
|
@@ -31,11 +31,11 @@ rlm-harness is an exact PyPI pin (`rlm-harness==X.Y.Z` in `pyproject.toml`, lock
|
|
|
31
31
|
- **The budget is hard: `max_retries=1`, no whole-RLM retry inside a run.** One change = one trajectory, so the trace stays valid training data. (`watch` may run a change again, but only when the previous attempt produced no result at all, an infrastructure failure; `cli.run` resets that run id's trace first, so exactly one trajectory per run id survives.) A failed run is infra before it is a schema bug; see `.claude/rules/detect-setup.md` for how the failure names itself.
|
|
32
32
|
- **A second model-judgement is a TOOL, never the sub-LM.** `deep_classify` (on rlm-harness's `make_model_tool`) is the swappable second-stage seam the planner chooses to call, so the decision is a `tool_call` in the trajectory. The analyst intercept (`intercept_sub_lm`) is tracing-only, zero transforms. Swapping the backend touches only `classify_backend` / `_selfclassify_chat`. The planner passes distilled findings, never the whole diff.
|
|
33
33
|
- **Sandboxed code builds no sub-agents.** In dspy 3.4.1 and later, sandboxed code can construct dspy programs that run on the host, call the analyst, can drive the task's tools, and record as one `sub_call` with no inner turns. The kit's default allows it, so `setup` passes `sandbox_sub_agents=False` explicitly, and production never injects an interpreter (which would bypass it); `test_program_offers_no_sub_agents` holds the behaviour.
|
|
34
|
-
- **GitHub ingest, monitoring, and SIEM emission are host-side plumbing, never planner tools.** `ingest.py` shells out to `gh` host-side (transport injectable); `emit.emit_signal` POSTs and never raises; `watch`, `actors` and `snapshot` poll, remember, and archive outside the trajectory, `releases` and `npm` read PyPI's and npm's own hosts, and the refs and trees of a package's GitHub repository, as data that is never installed, and `images` reads the GHCR and Docker Hub APIs only (manifests, provenance, and the layers two images do not share, as data in memory, never unpacked or run). `pycheck` compiles a release's Python source and unmarshals its bytecode in a separate interpreter to compare them, and runs neither. Only choices the policy makes are tools; delivering a finished result is plumbing. What the store learns reaches the signal only as provenance facts through `scan_provenance`, never as a second derivation (see `.claude/rules/monitoring.md`).
|
|
34
|
+
- **GitHub ingest, monitoring, and SIEM emission are host-side plumbing, never planner tools.** `ingest.py` shells out to `gh` host-side (transport injectable); `emit.emit_signal` POSTs and never raises; `watch`, `actors` and `snapshot` poll, remember, and archive outside the trajectory, `history` (opt-in, off by default: it sends a login to ClickHouse's public playground) reads an author's GH Archive history, `releases` and `npm` read PyPI's and npm's own hosts, and the refs and trees of a package's GitHub repository, as data that is never installed, and `images` reads the GHCR and Docker Hub APIs only (manifests, provenance, and the layers two images do not share, as data in memory, never unpacked or run). `pycheck` compiles a release's Python source and unmarshals its bytecode in a separate interpreter to compare them, and runs neither. Only choices the policy makes are tools; delivering a finished result is plumbing. What the store learns reaches the signal only as provenance facts through `scan_provenance`, never as a second derivation (see `.claude/rules/monitoring.md`).
|
|
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
|
-
- **Keep the dspy-free modules dspy-free.** `config`, `schema`, `normalize`, `indicators`, `shelllex`, `linewide`, `assemble`, `response`, `emit`, `ingest`, `hosts`, `dbutil`, `actors`, `snapshot`, `watch`, `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.
|
|
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, 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`)
|
|
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,34 @@
|
|
|
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.16.0
|
|
6
|
+
|
|
7
|
+
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).
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- **`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).
|
|
11
|
+
- **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.
|
|
12
|
+
- **`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`.
|
|
13
|
+
- **`DS_CLASSIFIER_OMIT_PARAMS`** leaves `temperature` and/or `max_tokens` out of the classifier's request, for an endpoint that refuses them.
|
|
14
|
+
- **`DS_RUN_TAG`, or `classify --run-tag`, labels every planner call a trace records**, for example with a teacher run's budget or temperature.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- **`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.
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
- **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.
|
|
21
|
+
- **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.
|
|
22
|
+
- **A crafted, deeply nested `__pycache__` path in a wheel or image no longer slows the release screen.**
|
|
23
|
+
|
|
24
|
+
## 0.15.0
|
|
25
|
+
|
|
26
|
+
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.
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
- **A slash command is weighed by what the repository's own workflows answer.** `watch`, `pr` and `issue` read the target repository's `.github/workflows` (its default branch, once an hour). A command that a workflow runs for anyone who comments goes one step up, to `high` when the change's author fires it within an hour of opening it, the hackerbot-claw shape. A command only some commenters can run keeps its usual weight, and one no workflow answers goes one step down. Only GitHub Actions workflows are read.
|
|
30
|
+
- **`prt-runs-fork-code`** (`medium`): an outsider's pull request into a repository whose `pull_request_target` workflow checks out the pull request's own code, which then runs with the repository's secrets.
|
|
31
|
+
- **An opt-in account history from GH Archive.** With `--account-history` (or `DS_ACCOUNT_HISTORY=clickhouse`), `watch`, `pr`, `issue` and `actor` look up an author's public events from before GitHub's 30-day window, as of the event, through ClickHouse's public playground. An account that wakes after a year without public activity is `dormant-account-reactivated` (`medium`), and an account older than 180 days with no earlier public activity is `no-public-history` (`low`); neither raises an alert on its own. The lookup is off by default because it sends the author's login to a third party, and `scan` and the GitHub Action never use it. See [Watching a watchlist](docs/watch.md).
|
|
32
|
+
|
|
5
33
|
## 0.14.0
|
|
6
34
|
|
|
7
35
|
Upgrade from 0.13.0: `release-watch --images` now reads what each image changes, and checks compiled bytecode against its source. The GitHub Action's scan is unchanged, and `rlm-harness==1.24.0` is unchanged. For the bytecode check, install the Python version an image or wheel uses (`python3.N` on `PATH`) beside the watcher; without it, changed bytecode alerts that it could not be checked.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: diff-sentry
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.16.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.
|
|
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.
|
|
46
|
+
- uses: qazbnm456/diff-sentry@v0.16.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.
|
|
@@ -58,7 +58,7 @@ That is the whole setup. The job fails when an indicator at or above `high` fire
|
|
|
58
58
|
| Exfiltration | secrets reaching a network sink, cross-process `/proc/<pid>/mem` reads, OAST callback services, IPFS and permaweb gateways |
|
|
59
59
|
| Diff-presentation evasion | payloads shoved past the viewport by a long whitespace run, bidi-override and zero-width characters |
|
|
60
60
|
| Provenance | forged `[bot]` identities, bot-mimicking new accounts, accounts created days before the event, profiles that describe an autonomous agent, unsigned or identity-mismatched commits, a fork deleted after the PR |
|
|
61
|
-
| Author-controlled channels | a PR branch name carrying shell syntax, slash-command comments that fire `issue_comment` workflows |
|
|
61
|
+
| Author-controlled channels | a PR branch name carrying shell syntax, slash-command comments that fire `issue_comment` workflows (weighed by what the repository's own workflows answer) |
|
|
62
62
|
| Campaign memory (`watch` only) | an account or payload host already flagged in another repository, an edit that removes a flagged payload, a burst of changes from a new account |
|
|
63
63
|
| Prompt injection | instructions aimed at an LLM reviewer or triage workflow |
|
|
64
64
|
|
|
@@ -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.
|
|
24
|
+
- uses: qazbnm456/diff-sentry@v0.16.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.
|
|
@@ -36,7 +36,7 @@ That is the whole setup. The job fails when an indicator at or above `high` fire
|
|
|
36
36
|
| Exfiltration | secrets reaching a network sink, cross-process `/proc/<pid>/mem` reads, OAST callback services, IPFS and permaweb gateways |
|
|
37
37
|
| Diff-presentation evasion | payloads shoved past the viewport by a long whitespace run, bidi-override and zero-width characters |
|
|
38
38
|
| Provenance | forged `[bot]` identities, bot-mimicking new accounts, accounts created days before the event, profiles that describe an autonomous agent, unsigned or identity-mismatched commits, a fork deleted after the PR |
|
|
39
|
-
| Author-controlled channels | a PR branch name carrying shell syntax, slash-command comments that fire `issue_comment` workflows |
|
|
39
|
+
| Author-controlled channels | a PR branch name carrying shell syntax, slash-command comments that fire `issue_comment` workflows (weighed by what the repository's own workflows answer) |
|
|
40
40
|
| Campaign memory (`watch` only) | an account or payload host already flagged in another repository, an edit that removes a flagged payload, a burst of changes from a new account |
|
|
41
41
|
| Prompt injection | instructions aimed at an LLM reviewer or triage workflow |
|
|
42
42
|
|
|
@@ -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.
|
|
43
|
+
default: '0.16.0'
|
|
44
44
|
|
|
45
45
|
outputs:
|
|
46
46
|
failed:
|