ARTEX/agent
Николай Гусев 24cd7da9af agent: advisory duplicate check on report_finding via a decision model
Duplicates are the cheapest way to lose reviewer trust, and the only guard today is
a prompt instruction: the worker is told to check list_findings before registering.
It does not hold — in one run against a deliberately vulnerable app three defect
classes were registered twice each (two SQLi, two IDOR, two admin-endpoint
findings), and one of the pairs differed only in wording.

A decision model answers exactly this kind of closed-list question (same defect as
one of these N findings, or not?) with probabilities and no generated text, so the
judgement costs one small request instead of a main-model turn over a six-figure
context. Measured on our own findings before writing any of this (15 candidates,
hand labels): the correct partner 8/8 on a 27B decider and 7/8 on the flash one,
against 7/15 for the constant "always distinct", at 0.66 s and ~1.7k input tokens
per call with zero output tokens. Repeated calls were stable (30/30 identical).

Changes

- agent/triage.go: TriageClient interface, a /v1/systemone HTTP client, and the pure
  pieces (state builder, criteria builder, answer parser, threshold) so the logic is
  testable without a server.
- report_finding: consults the client before registering. On a duplicate above the
  confidence threshold the finding is not registered again; the caller is told which
  finding_id it matched and to extend it with update_finding_report.
- Wiring: agent.SetTriageClient on the worker/planner ToolSets, a triage_profile_id
  setting (any llm_profiles row whose base_url serves the decision contract; 0 = off),
  exposed through the settings API.

Fail-open, by construction

Triage changes an outcome only when it is confident; every other path behaves exactly
as today: no client, no existing findings, empty summary, transport error, non-200,
malformed body, an id the question never offered, or confidence below the threshold
all fall through to normal registration. A wrong suppression loses evidence, a wrong
registration only costs a row — hence the threshold, and hence "advisory".

Verification

- go test ./agent/ passes, including new tests: request shape (model/state/criteria
  carry every candidate), distinct answer, unknown id reads as distinct, probability
  fallback when confidence is absent, error on 500, no HTTP call without input, state
  cap, threshold boundaries.
- red/green on two independent breakages: forcing the threshold false and accepting
  an unoffered id both fail the suite; restored, it passes.
- go test ./server/ shows one failure,
  TestManagerSOCKS5UDPOptInAndAssetBlockRuleDropsDatagram (bind 127.0.0.2 —
  environment), reproduced on clean main in a separate worktree.
- gofmt -l agent/ server/ clean.

Notes

- The profile must serve /v1/systemone. A chat-only decider endpoint (one that refuses
  /v1/chat/completions) needs a thin adapter; a decision endpoint works directly.
- Off by default: with no triage_profile_id the platform behaves as before.

The cap on offered findings is a SELECTION, not "the newest N": with a wide graph
the true partner falls out of a newest-first list, so candidates are ranked by
relevance (same class, overlapping endpoint, another task on a shared asset) with
recency only breaking ties. Per-entry summary capping replaces the whole-state
truncation, which used to cut mid-line and leave criteria ids whose state line had
been dropped.

Threshold is a knob, not a constant (live acceptance): on a run with the wider
cross-task pool the model named the right partner in 8 of 9 questions, but its
confidence moved with the question's width — 0.73-0.79 on a small pool, 0.30-0.53
with twenty candidates. Six duplicates were suppressed, and exactly the two that
slipped were the 0.30 and 0.47 ones, both with the correct partner named. A fixed
0.5 cannot fit both ends, so the threshold is a setting (triage_min_confidence,
default 0.5); the low end is affordable because the suppression result tells the
agent to re-register explicitly when the finding is in fact distinct.

Cross-task pool (found by re-measuring the live miss): task_relations only links
spawned tasks, so two tasks created independently against the same target never see
each other's findings and a defect registered in both is invisible to the dedup
question. FindingsSharingAssets joins on the candidate's own asset ids (jsonb
containment, GIN-served) and adds those findings to the question, marked with their
task. On three real cross-task duplicates the wider question names the right partner
in all three (confidence 0.58-0.73, above the threshold), where the own-task pool
could only answer "none".

Regression note (found on a live run, not in CI): FindingID is filled from the findings table, so building the candidate list straight from the nodes dropped every entry and triage never fired ("nodes=6, no usable existing findings"). Covered by TestTriageCandidates_SkipsNodesWithoutFindingRow; findings inherited from a directly related task are kept and marked in the question.

---

Found while running the platform against a live target.

limits: triageDupMinConfidence 0.5 - калибровка 538 пар одной цели (stage3_calibrate.py, 2026-11-22): recall 1.00 при FP 0.47 на 75 жёстких негативах; на истинных дублях в живом прогоне 0.30-0.79
limits: triageMaxExisting 10 - ширина вопроса на реальном дубле (stage3_width.py, 2026-11-22): уверенность 0.81-0.91 до 11 кандидатов, 0.64 на 19, 0.56 на 29; латентность 0.44->1.29 с
limits: triageMaxSummaryChars 400 - p90 длины сводки 334, максимум 564 по 53 находкам графа (2026-11-22)
limits: triageMaxStateChars 6000 - арифметика при потолке 10 записей: 10*(400+60)+480 ~= 5.1 КБ, запас 1.17x
limits: triageHTTPTimeout 20s - наблюдаемая латентность decider 0.26-1.29 с, 3.83-3.96 с на 27B; запас ~5x к худшему
limits: findings pool query limit 50 - самый широкий пул по ассету 31 находка (53 в графе, 2026-11-22), запас 1.6x
limits: ответ decider 1 MiB - наблюдаемый ответ 0.3-2 КБ, запас ~500x
2026-11-23 16:59:40 +03:00
..
adversarial_gate_seed_test.go feat: adversarial verification gate before confirmed findings 2026-10-12 06:26:51 +02:00
agentic_guards_test.go security(agent): wire the capture check into prove_goal and fail closed without it 2026-11-21 08:10:52 +01:00
assembly.go agent: list available skills in the system prompt 2026-11-21 22:00:22 +03:00
assembly_test.go agent: guard prompt and wrap-up override hooks against concurrent access 2026-11-14 14:19:13 +01:00
auto_scope_hygiene_test.go test: clean up residual findings, retest conversations, parent assets, and test rows 2026-11-20 22:18:53 +01:00
bbot_ingest.go fix(agent): strip URL userinfo in scan and bbot ingestion 2026-11-14 01:02:16 +01:00
bbot_ingest_confined_test.go security(agent): confine ingest_bbot; write tool scripts outside the run dir 2026-11-20 05:35:54 +01:00
bbot_ingest_test.go fix(agent): strip URL userinfo in scan and bbot ingestion 2026-11-14 01:02:16 +01:00
bbot_ingest_tool.go agent: run the file tools as the executor identity 2026-11-22 23:00:41 +01:00
bbot_ingest_tool_pg_test.go security(agent): confine ingest_bbot; write tool scripts outside the run dir 2026-11-20 05:35:54 +01:00
bbot_ingest_tool_test.go Add ingest_bbot tool (bbot JSONL, typed scope split) 2026-11-12 12:35:06 +01:00
bedrock_gateway.go fix: bind Bedrock headers to gateway and redact errors 2026-11-22 22:31:06 +08:00
bedrock_gateway_test.go fix: bind Bedrock headers to gateway and redact errors 2026-11-22 22:31:06 +08:00
blackboard_inheritance_test.go test: clean up residual findings, retest conversations, parent assets, and test rows 2026-11-20 22:18:53 +01:00
budget.go Say what a restored task budget still allows, and test the lanes that count. 2026-11-17 15:50:00 -05:00
budget_test.go Restore a task spend cap from the lanes the live ledger counts. 2026-11-17 13:04:36 -05:00
cancelcause.go feat(engine): intent claim heartbeat, TTL and fencing token (S3c) 2026-11-10 17:45:11 +01:00
capture.go fix: report provider refusals, do not rerun them as idle turns 2026-11-18 00:41:18 -06:00
capture_approval_test.go Refactor PostgreSQL test skipping logic 2026-11-19 14:23:29 -03:00
capture_usage_test.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
chat.go security(agent): command-output spills go to a root-owned per-task dir 2026-11-20 05:35:55 +01:00
chat_session_id_test.go fix(agent): reject unsafe ChatAgent session ids 2026-11-18 22:40:21 +01:00
clipbody_test.go fix(agent): keep LLM connection-test logs on one line 2026-11-21 19:54:18 +00:00
coldgraph.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
coldgraph_test.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
compaction.go agent: fact provenance (declared source plus server-set origin) 2026-11-12 00:37:44 +01:00
constraints.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
coverage.go Leave asset-coverage tools available when the flag read fails. 2026-11-17 13:04:36 -05:00
coverage_flag_test.go test: clean up residual findings, retest conversations, parent assets, and test rows 2026-11-20 22:18:53 +01:00
coverage_ledger.go Coverage ledger: review fixes (one-line capped fields, framed gap lines, per-run end_reason) 2026-11-12 20:48:34 +01:00
coverage_ledger_test.go Coverage ledger: review fixes (one-line capped fields, framed gap lines, per-run end_reason) 2026-11-12 20:48:34 +01:00
data_envelope.go security(agent): frame worker assets, stagnation, agent credentials, todos and refuse symlinks in openScanOutput 2026-11-21 08:10:52 +01:00
data_envelope_test.go fix(agent): frame intent summaries as data 2026-11-17 23:44:36 +01:00
deadline_contract_seed_test.go feat: deadline contract in the executor seeds 2026-10-12 07:30:27 +02:00
deferred.go agent: list available skills in the system prompt 2026-11-21 22:00:22 +03:00
deferred_test.go chore: ARTEX 初始化 2026-07-26 04:27:45 -04:00
fact_assets.go fix: repair record_fact input contracts and asset aliases 2026-11-17 06:14:31 +00:00
fact_assets_test.go fix(agent): publish record_fact as a facts-only contract 2026-11-20 10:03:52 +00:00
fact_input.go fix(agent): publish record_fact as a facts-only contract 2026-11-20 10:03:52 +00:00
fact_input_legacy.go fix(server): recognise the released record_fact descriptions as known defaults 2026-11-20 18:48:06 +01:00
fact_input_test.go Tie fact evidence to recorded activity and proxy captures 2026-11-21 09:50:45 +00:00
fact_provenance_test.go test(agent,db): document and lock risk_accepted goal-proof semantics (#269) 2026-11-21 16:29:53 +01:00
filetools.go agent: run the file tools as the executor identity 2026-11-22 23:00:41 +01:00
filetools_identity.go agent: run the file tools as the executor identity 2026-11-22 23:00:41 +01:00
filetools_identity_linux.go agent: test that the file tool identity stays on its own thread 2026-11-22 23:00:41 +01:00
filetools_identity_other.go agent: run the file tools as the executor identity 2026-11-22 23:00:41 +01:00
filetools_identity_root_linux_test.go agent: run the file tools as the executor identity 2026-11-22 23:00:41 +01:00
filetools_identity_scope_root_linux_test.go agent: test that the file tool identity stays on its own thread 2026-11-22 23:00:41 +01:00
filetools_identity_test.go agent: run the file tools as the executor identity 2026-11-22 23:00:41 +01:00
filetools_other.go security(agent): confine the file tools and close the executor review 2026-11-20 05:35:54 +01:00
filetools_test.go security(agent): refuse run dirs reached by symlink; scrub S3 archive keys 2026-11-20 05:35:54 +01:00
filetools_unix.go security(agent): confine the file tools and close the executor review 2026-11-20 05:35:54 +01:00
finding_dedup_seed_test.go feat: duplicate discipline before report_finding and in the reporter 2026-10-12 07:29:59 +02:00
finding_hint_degrade_test.go fix(finding): accept evidence_hint_id 0 and degrade to explicit traffic_refs 2026-11-21 14:29:23 +01:00
finding_quality_seed_test.go feat: measured impact and attacker-goal proof standard for findings 2026-10-12 06:25:35 +02:00
finding_reasoning_test.go test: clean up residual findings, retest conversations, parent assets, and test rows 2026-11-20 22:18:53 +01:00
finding_recorder.go refactor(agent): remove unused finding traffic guidance 2026-11-21 21:30:58 +03:00
finding_recorder_source_test.go refactor(agent): remove unused finding traffic guidance 2026-11-21 21:30:58 +03:00
finding_recorder_test.go test: clean up residual findings, retest conversations, parent assets, and test rows 2026-11-20 22:18:53 +01:00
finding_workflow.go agent: state on the tools that traffic binding is off when the switch is off 2026-11-21 20:58:25 +03:00
finding_workflow_test.go agent: state on the tools that traffic binding is off when the switch is off 2026-11-21 20:58:25 +03:00
goals.go fix(coverage): count auto-scope only under a declared root (F8) 2026-11-12 07:37:58 +01:00
hooks_reach_test.go feat(guard): planner and main-agent hooks, target-gate scope in every session (S3b 1.1) 2026-11-10 22:14:24 +01:00
insert_assets_test.go Refactor PostgreSQL test skipping logic 2026-11-19 14:23:29 -03:00
mainagent.go Tie fact evidence to recorded activity and proxy captures 2026-11-21 09:50:45 +00:00
noa.go feat(agent): size NOA to the configured window and refuse irreducible requests 2026-11-15 19:08:49 +01:00
noa_budget.go fix(server): do not rerun intents refused by the NOA budget 2026-11-15 22:26:21 +01:00
noa_budget_test.go fix(server): do not rerun intents refused by the NOA budget 2026-11-15 22:26:21 +01:00
noise_profile.go fix(agent): noise prompt states what the capture proxy paces 2026-11-15 01:23:56 +01:00
noise_profile_test.go fix(agent): noise prompt states what the capture proxy paces 2026-11-15 01:23:56 +01:00
operator_handoff_seed_test.go feat: ask_operator environmental handoff discipline 2026-10-12 06:45:21 +02:00
p43_adversarial_bench_test.go style(agent): gofmt the adversarial bench capture-case cleanup 2026-11-21 08:14:56 +01:00
p43_envelope_and_scan_test.go security(agent): frame worker assets, stagnation, agent credentials, todos and refuse symlinks in openScanOutput 2026-11-21 08:10:52 +01:00
p43_proof_gate_test.go security(agent): wire the capture check into prove_goal and fail closed without it 2026-11-21 08:10:52 +01:00
planner.go agent: advisory duplicate check on report_finding via a decision model 2026-11-23 16:59:40 +03:00
prompt.go agent: guard prompt and wrap-up override hooks against concurrent access 2026-11-14 14:19:13 +01:00
prompt_injection_seed_test.go agent: guard prompt and wrap-up override hooks against concurrent access 2026-11-14 14:19:13 +01:00
prompt_now_test.go agent: guard prompt and wrap-up override hooks against concurrent access 2026-11-14 14:19:13 +01:00
prompt_test.go agent: guard prompt and wrap-up override hooks against concurrent access 2026-11-14 14:19:13 +01:00
promptcatalog.go agent: fact provenance (declared source plus server-set origin) 2026-11-12 00:37:44 +01:00
provider.go Merge pull request #480 from jamesKhor/feat/bedrock-gateway 2026-11-23 14:52:58 +01:00
provider_capture_e2e_test.go feat(llmrec): 录制 LLM 请求/响应 HTTP 原文 2026-08-25 09:40:05 -04:00
provider_capture_test.go feat(llm): optional custom User-Agent for LLM requests 2026-11-08 17:11:43 +01:00
provider_env_test.go feat: add bearer-authenticated Bedrock gateway profiles 2026-11-22 18:27:43 +08:00
provider_quota_test.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
provider_responses_test.go feat(llm): 支持 OpenAI Responses API 格式的 LLM 配置 2026-08-25 11:39:24 -04:00
provider_window_test.go fix(server): use the real context window for llmpool and sidequestion 2026-11-17 12:56:13 +00:00
providerstop.go fix: report provider refusals, do not rerun them as idle turns 2026-11-18 00:41:18 -06:00
providerstop_test.go fix: report provider refusals, do not rerun them as idle turns 2026-11-18 00:41:18 -06:00
proxyenv_test.go feat(traffic): pace Bash requests at the capture proxy 2026-11-15 00:57:13 +01:00
record_fact_shapes_test.go fix(agent): publish record_fact as a facts-only contract 2026-11-20 10:03:52 +00:00
retester.go feat: adversarial verification gate before confirmed findings 2026-10-12 06:26:51 +02:00
review_context_test.go Refactor PostgreSQL test skipping logic 2026-11-19 14:23:29 -03:00
rundir_test.go security(agent): share only run-dir leaves; main agent gets its own leaf 2026-11-20 05:35:55 +01:00
runinfo.go feat(tasks): add runtime controls and inherited context 2026-08-24 19:29:00 +08:00
scan_ingest.go fix(agent): strip URL userinfo in scan and bbot ingestion 2026-11-14 01:02:16 +01:00
scan_ingest_test.go security(agent): frame worker assets, stagnation, agent credentials, todos and refuse symlinks in openScanOutput 2026-11-21 08:10:52 +01:00
scan_ingest_tool.go agent: run the file tools as the executor identity 2026-11-22 23:00:41 +01:00
scan_ingest_tool_pg_test.go test: clean remaining residual rows across db, agent, and server test suites 2026-11-20 22:54:57 +01:00
session.go fix(agent): stop on transcript restore failures and keep session identity without persistence 2026-11-15 15:32:07 +01:00
session_header_test.go feat(llm): 每个 LLM 配置支持自定义会话头 2026-09-07 11:21:50 -04:00
session_test.go fix(agent): stop on transcript restore failures and keep session identity without persistence 2026-11-15 15:32:07 +01:00
side_questions.go feat(agent): 支持持久化 /btw 旁路提问 2026-09-10 21:42:25 +08:00
side_questions_test.go security(agent): confine the file tools and close the executor review 2026-11-20 05:35:54 +01:00
skill_index_test.go agent: list available skills in the system prompt 2026-11-21 22:00:22 +03:00
spill.go security(agent): command-output spills go to a root-owned per-task dir 2026-11-20 05:35:55 +01:00
spill_test.go security(agent): command-output spills go to a root-owned per-task dir 2026-11-20 05:35:55 +01:00
stagnation_test.go feat(engine): ouroboros takes - goal ambiguity gate, failover escalation, stagnation surfacing 2026-10-21 14:46:56 +02:00
target_gate_tools_test.go feat(intercept): target extraction, resolver, exemptions and the gate in the hook (S3b 1.5-1.7) 2026-11-11 00:34:55 +01:00
taskclock.go chore: ARTEX 初始化 2026-07-26 04:27:45 -04:00
terminalreason.go fix: report provider refusals, do not rerun them as idle turns 2026-11-18 00:41:18 -06:00
terminalreason_test.go feat(engine): intent claim heartbeat, TTL and fencing token (S3c) 2026-11-10 17:45:11 +01:00
testmain_test.go test(agent,server): run the tests in a temp directory of their own 2026-11-20 06:38:10 +01:00
toolcatalog.go fix(agent): publish record_fact as a facts-only contract 2026-11-20 10:03:52 +00:00
toolcatalog_test.go fix(tools): harden obj against blank required names and heal seeded list_task_credentials rows 2026-11-10 09:46:49 +01:00
toolrag.go Tool RAG: lexical projection of the bound tool catalog (off by default) 2026-11-12 15:42:31 +01:00
toolrag_test.go agent: guard ToolAugment/ToolResolve hooks against concurrent access 2026-11-14 13:46:03 +01:00
tools.go agent: advisory duplicate check on report_finding via a decision model 2026-11-23 16:59:40 +03:00
tools_creds.go fix(tools): drop empty required entry from list_task_credentials schema 2026-11-02 09:05:03 +03:00
tools_digest.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
tools_insert.go security(agent,db): enforce server-side finding traffic proof in prove_goal and mark scope expansions 2026-11-21 08:10:52 +01:00
tools_nil_store_test.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
tools_overview_test.go fix(rsi): honor triage status in goals and lesson scope 2026-11-21 08:50:26 +01:00
triage.go agent: advisory duplicate check on report_finding via a decision model 2026-11-23 16:59:40 +03:00
triage_test.go agent: advisory duplicate check on report_finding via a decision model 2026-11-23 16:59:40 +03:00
untrusted_boundary.go Refactor PostgreSQL test skipping logic 2026-11-19 14:23:29 -03:00
untrusted_boundary_test.go Untrusted boundary ON by default (opt-out via ARTEX_UNTRUSTED_BOUNDARY=0) 2026-11-12 14:46:44 +01:00
untrusted_prompt.go agent: untrusted-content tail for every chat agent; evidence wording fits the reporter 2026-11-11 21:59:09 +01:00
user_agent_test.go fix(llm): validate custom User-Agent in the connection-test path 2026-11-08 18:15:33 +01:00
webfetch.go feat(egress): change the noise profile at runtime 2026-11-14 23:30:06 +01:00
webfetch_dialer_test.go feat(intercept): pinned dialer for WebFetch and the custom http tool (S3b 2.1) 2026-11-11 19:19:55 +01:00
webfetch_egress_test.go feat(egress): change the noise profile at runtime 2026-11-14 23:30:06 +01:00
webfetch_redirect_test.go WebFetch: coalesce only, never cache; pin the gate-off redirect test to the off profile 2026-11-12 16:33:14 +01:00
worker.go agent: advisory duplicate check on report_finding via a decision model 2026-11-23 16:59:40 +03:00
worker_cache_prefix_test.go security(agent): frame worker assets, stagnation, agent credentials, todos and refuse symlinks in openScanOutput 2026-11-21 08:10:52 +01:00
worker_intervention_test.go 新增worker直接对话 2026-08-29 21:55:27 +08:00
wrapup.go agent: guard prompt and wrap-up override hooks against concurrent access 2026-11-14 14:19:13 +01:00