Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(signals): forward reviewer corrections to every scout that touched the report (#95365)

posthog[bot]63861aad48ea
diff --git a/products/signals/ARCHITECTURE.md b/products/signals/ARCHITECTURE.md
index a0144a0938de..94a32c87ed11 100644
--- a/products/signals/ARCHITECTURE.md
+++ b/products/signals/ARCHITECTURE.md
@@ -914,8 +914,8 @@ And on the read side, `scout-notes-list` withholds `report_dismissal` notes from
**Reviewer corrections.** A human adding or removing a suggested reviewer is also forwarded to a `SignalScoutNote` (`reviewer_correction_notes.forward_reviewer_correction_note`), under the same guard as the `suggested_reviewers_changed` activity row: a user-attributed edit that changed the set, so agent writes and order-only rewrites forward nothing.
Scouts treat a correction as authoritative routing precedent and cache it in `reviewer:` scratchpad keys, and until this channel existed nothing told them one had happened — the project profile's `recent_reviewer_corrections` covers about two days of edits on a busy project, so a login removed by hand kept being suggested by every scout holding it.
The note is the trigger, not the record: it asks the scout to condense its own memory, and nothing here writes to the scratchpad, because a mechanical entry would overwrite ownership evidence a scout verified for itself.
-It is the only derived origin addressed to more than the authoring scout. A removed login also goes to every scout whose `reviewer:` memory names it, resolved by one exact-term search under the `reviewer:` key prefix and keeping the live scout skills behind those entries, capped at `MAX_NOTE_TARGETS` per correction.
-A report with no live authoring scout falls back to the fleet-wide target only when no holder resolved, because a run reads the fleet-wide notes alongside its own and would otherwise hear the same edit twice.
+It is the only derived origin addressed to more than one scout. Every live scout that emitted or edited the report is a target, because a scout that set the reviewers through an edit did the routing the human just corrected. A removed login also goes to every scout whose `reviewer:` memory names it, resolved by one exact-term search under the `reviewer:` key prefix and keeping the live scout skills behind those entries. The targets are ordered emitting scout, editing scouts, then holders, and capped at `MAX_NOTE_TARGETS` per correction.
+A report no live scout touched falls back to the fleet-wide target only when no holder resolved, because a run reads the fleet-wide notes alongside its own and would otherwise hear the same edit twice.
An impersonated edit forwards nothing: the reviewer-corrections project profile already excludes impersonated activity rows, since a support-staff edit is not the team's ownership evidence.
Logins are shape-checked against GitHub's login rule before rendering, and an edit contributes at most `MAX_CORRECTION_LOGINS` of them: both write paths into the reviewers artefact accept any string of any length, and the value lands inside a backtick span in a prompt every scout reads.
Repeated edits are coalesced rather than queued: a login already named in a note to a target, in the same direction, inside `SUPPRESSION_WINDOW` is left out of the next one, so one person trimming the same login off ten reports in a morning tells each scout once.
diff --git a/products/signals/backend/auto_start.py b/products/signals/backend/auto_start.py
index 1a4929bb06b5..d9635cec3afe 100644
--- a/products/signals/backend/auto_start.py
+++ b/products/signals/backend/auto_start.py
@@ -482,7 +482,7 @@ def _live_skill_owner_logins(team: Team, report_id: str, reviewers_content: list
writes that swallow failures, so an identity guard cannot rest on them alone — the entry stamp
commits atomically with the pick it guards, and covers the entries that actually stand for
selection even when a tally write was lost."""
- skill_names = resolve_touching_scout_skills(team.id, report_id)
+ skill_names = set(resolve_touching_scout_skills(team.id, report_id))
skill_names |= {str(r["source_skill"]) for r in reviewers_content if r.get("source_skill")}
owner_uuids: set[str] = set()
for skill_name in skill_names:
diff --git a/products/signals/backend/reviewer_correction_notes.py b/products/signals/backend/reviewer_correction_notes.py
index 23487cf40b54..86a77324ac70 100644
--- a/products/signals/backend/reviewer_correction_notes.py
+++ b/products/signals/backend/reviewer_correction_notes.py
@@ -15,13 +15,14 @@ cold start (`scout-notes-list`). The note is the trigger, never the record: it a
revisit its own memory, and the scout decides what to keep. Nothing here writes to the scratchpad,
because a mechanical entry would overwrite ownership evidence a scout verified for itself.
-Targets are whoever holds the memory, which is why this is the only derived kind addressed to more
-than one scout. The authoring scout hears about its own report. On top of that, every scout whose
-`reviewer:` memory names a removed login hears about the removal, because those are the scouts still
-routing on it — a fleet-wide note would reach them only if it survived the newest-first window a run
-reads. A report with no live authoring scout falls back to the fleet-wide target, but only when no
-holder resolved: a run reads the fleet-wide notes alongside its own, so pairing the two would tell a
-holder the same thing twice.
+Targets are whoever was involved in the routing, which is why this is the only derived kind
+addressed to more than one scout. Every live scout that emitted or edited the report hears about it:
+an edit is how a scout puts reviewers on a report it did not file, so an editor is as much a router
+as the author. On top of that, every scout whose `reviewer:` memory names a removed login hears about
+the removal, because those are the scouts still routing on it — a fleet-wide note would reach them
+only if it survived the newest-first window a run reads. A report no live scout touched falls back to
+the fleet-wide target, but only when no holder resolved: a run reads the fleet-wide notes alongside
+its own, so pairing the two would tell a holder the same thing twice.
Authorization is the editor's, and mirrors `dismissal_notes` rather than `feedback_notes`: the logins
already reach scouts through the report's reviewers artefact and the project profile, so the note
@@ -49,7 +50,7 @@ from posthog.models import Team, User
from products.signals.backend.dismissal_notes import DERIVED_NOTE_TTL, principal_may_steer_scouts
from products.signals.backend.models import SignalReport, SignalScoutNote
from products.signals.backend.report_generation.resolve_reviewers import get_org_member_github_logins_by_user_uuid
-from products.signals.backend.scout_authorship import resolve_report_scout_skill
+from products.signals.backend.scout_authorship import resolve_touching_scout_skills
from products.signals.backend.scout_harness.tools.notes import leave_note
from products.signals.backend.scout_harness.tools.scratchpad import search_scratchpad_naming
from products.skills.backend.models.skills import LLMSkill
@@ -247,17 +248,21 @@ def _renderable(logins: Sequence[str]) -> tuple[str, ...]:
def _resolve_targets(team_id: int, report_id: str, removed_logins: Sequence[str]) -> list[str]:
- """Who to tell: the scout that filed the report, plus every holder of the removed logins.
+ """Who to tell: every scout that touched the report, plus every holder of the removed logins.
- A report with no live authoring scout (a pipeline report, or one whose scout is gone) falls back
- to the fleet-wide target ("") that dismissals use — but only when no holder resolved, because a
- run reads the fleet-wide notes alongside its own and a holder would hear the same edit twice.
+ Touching means emitted or edited, because a scout that set the reviewers through an edit did the
+ routing a human has just corrected, and it is better to tell it once too often than to leave it
+ routing on a login somebody removed. The touching union keeps deleted skills, so it is filtered
+ to live ones the way the holders are.
+
+ A report no live scout touched (a pipeline report, or one whose scouts are gone) falls back to
+ the fleet-wide target ("") that dismissals use — but only when no holder resolved, because a run
+ reads the fleet-wide notes alongside its own and a holder would hear the same edit twice.
"""
+ touching = _live_skills(team_id, resolve_touching_scout_skills(team_id, report_id))
holders = _memory_holders(team_id, removed_logins)
- authoring = resolve_report_scout_skill(team_id, report_id)
- if not authoring:
- return holders[:MAX_NOTE_TARGETS] if holders else [""]
- return [authoring, *(name for name in holders if name != authoring)][:MAX_NOTE_TARGETS]
+ targets = [*touching, *(name for name in holders if name not in touching)]
+ return targets[:MAX_NOTE_TARGETS] if targets else [""]
def _memory_holders(team_id: int, removed_logins: Sequence[str]) -> list[str]:
@@ -284,11 +289,18 @@ def _memory_holders(team_id: int, removed_logins: Sequence[str]) -> list[str]:
)
if entry.created_by_skill
}
- if not named:
+ return _live_skills(team_id, sorted(named))
+
+
+def _live_skills(team_id: int, names: Sequence[str]) -> list[str]:
+ """The given skill names that still exist, in the order they were given.
+
+ One query. A note addressed to a deleted skill steers no one, and `leave_note` rejects it.
+ """
+ if not names:
return []
- return sorted(
- LLMSkill.objects.filter(team_id=team_id, name__in=named, deleted=False).values_list("name", flat=True)
- )
+ live = set(LLMSkill.objects.filter(team_id=team_id, name__in=names, deleted=False).values_list("name", flat=True))
+ return [name for name in names if name in live]
def _actor_login(team_id: int, actor: User) -> str | None:
diff --git a/products/signals/backend/scout_authorship.py b/products/signals/backend/scout_authorship.py
index 550f94d556e3..2ed055c5ebd7 100644
--- a/products/signals/backend/scout_authorship.py
+++ b/products/signals/backend/scout_authorship.py
@@ -22,21 +22,35 @@ def resolve_report_scout_skill(team_id: int, report_id: str) -> str:
return resolve_authoring_skill_names(team_id, [report_id]).get(report_id, "")
-def resolve_touching_scout_skills(team_id: int, report_id: str) -> set[str]:
- """Every scout whose runs emitted or edited one report.
+def resolve_touching_scout_skills(team_id: int, report_id: str) -> list[str]:
+ """Every scout whose runs emitted or edited one report, emitting scouts first.
The single-owner resolution below prefers the author, but a report's stored reviewers follow
whichever scout last wrote them — possibly a later editor. Callers that exclude skill owners
- from autostart identity need the owners of every scout that could have produced the stored
- reviewers, so this returns the union of touching skills. Deleted skills are kept: their owner
- rows and stored picks can outlive the skill row, and over-exclusion is the safe direction.
+ from autostart identity, or that address each router of the report, need every touching skill,
+ so this returns their union. Deleted skills are kept: their owner rows and stored picks can
+ outlive the skill row, and over-exclusion is the safe direction for autostart. A caller that
+ writes to the skills filters them itself.
+
+ A caller that addresses each scout separately has to cap the list, so the order decides who is
+ dropped: the scouts that filed the report come first, and each group is sorted, so the same
+ report always resolves the same way.
"""
# `for_team`, not an ambient-scope filter: the autostart caller runs in a Temporal activity,
# which sets no team scope, and the fail-closed manager raises there.
runs = SignalScoutRun.objects.for_team(team_id).filter(
Q(emitted_report_ids__contains=[report_id]) | Q(edited_report_ids__contains=[report_id])
)
- return {skill_name for skill_name in runs.values_list("skill_name", flat=True) if skill_name}
+ emitting: set[str] = set()
+ editing: set[str] = set()
+ for skill_name, emitted_ids in runs.values_list("skill_name", "emitted_report_ids"):
+ if not skill_name:
+ continue
+ if report_id in (emitted_ids or []):
+ emitting.add(skill_name)
+ else:
+ editing.add(skill_name)
+ return [*sorted(emitting), *sorted(editing - emitting)]
def resolve_authoring_skill_names(team_id: int, report_ids: list[str]) -> dict[str, str]:
diff --git a/products/signals/backend/scout_harness/AGENTS.md b/products/signals/backend/scout_harness/AGENTS.md
index f99f85362b7c..45706c818fd9 100644
--- a/products/signals/backend/scout_harness/AGENTS.md
+++ b/products/signals/backend/scout_harness/AGENTS.md
@@ -46,7 +46,7 @@ In production it is driven by `SignalsScoutCoordinatorWorkflow` (periodic tick e
`run_id` on a `remember` write is best-effort lineage, never a gate: the serializer coerces one it can't parse to `None` (`_BestEffortUUIDField`, the same stance `expires_at` takes) and the view drops one that names no run on this project, because a scout retypes the id out of its run prompt and a truncated copy must not cost the memory. When nothing usable comes off the body the view falls back to `tools/runs.run_id_for_sandbox_task`, which resolves the writing run from the task the caller's sandbox token is bound to — provenance the sandbox cannot choose, so lineage survives the typo. Non-sandbox callers and the pipeline stages resolve to no run and are unaffected.
The scratchpad is shared with the report pipeline, not scout-only. `remember` / `forget` are gated on their own `signal_scratchpad_internal:write` scope rather than the wider `signal_scout_internal:write`, so the pipeline's research and implementation runs can persist what they judged without also getting `emit_signal` and `record_output`. Scouts keep both tools, because `SCOUT_INTERNAL_SCOPES` carries the scratchpad scope too; the pipeline's own postures are the `signals_research` / `signals_implementation` presets in `posthog/temporal/oauth.py`. `signals_research` withholds `task:write`: it turns the MCP read-only header off so its scratchpad tools survive, and that header was the only thing keeping the task-write toolset (report state included) away from a stage meant to read.
Those stages have no `SignalScoutRun`, so `created_by_run` cannot name them. They stamp `SignalScratchpad.created_by_identity` instead — a `pipeline:*` string from `../pipeline_identity.py`, resolved server-side from the token's bound task (its `ai_stage`, written once at run creation) rather than passed in, since a writer that could name itself could name a scout's skill. `_to_entry` reads it as `created_by_skill` when there is no run, so `scout-scratchpad-search` attributes every entry the same way. Like `created_by_run` it is written on create only, so an upsert keeps the original author.
- - `notes.py` — `list_notes` / `leave_note` / `delete_note` backed by the `SignalScoutNote` model: steering notes humans (or other agents) leave for the fleet over the public MCP surface (`scout-notes-*` tools), the inbound counterpart to the scratchpad. A note targets one scout by `skill_name` or the whole fleet (blank), optionally expiring via `expires_at`; the run prompt's _Notes left for you_ section directs every scout to `scout-notes-list` its own notes in step 1 and treat them as advisory steering. A third audience is a stage of the report pipeline, addressed through the reserved `pipeline:*` family (`PIPELINE_AUDIENCES`, holding `pipeline:report-research` today): a pseudo-target riding the same `skill_name` column, allowlisted at write time so an unrecognized one is rejected instead of silently steering no one, and skipping the scout-skill lookup because a stage has no `LLMSkill` row. `list_notes` matches `skill_name` exactly, so no scout ever sees a pipeline note; the research loader in `../report_steering.py` reads `pipeline:report-research` alongside the report's scout target and the fleet-wide blanks. `validate_note_target`, the shared write-time rule, and the audience constants live in `../note_targets.py`, an import-light module, because the Django admin form calls the rule at registry load and importing anything under `tools/` runs that package's `__init__`, which pulls in every harness tool. Unlike the scratchpad there is no sandbox-only write gate, but writes still demand skill-authoring-level authorization (keys need `llm_skill:write` on top of `signal_scout:write`, and every writer must clear the `llm_skill` RBAC editor bar) — so a note-writer could already steer the fleet by editing its skills, and notes add no new steering power. Four more writers derive rows from inbox activity. `../dismissal_notes.py`: judging an inbox report with a note (dismiss, snooze, or restore) also leaves it here as an `origin=report_dismissal` note, targeted at the scout that authored the report, so a reviewer's verdict reaches the scout without it having to re-find the report. Resolving does not, since that says the report did its job rather than that filing it was wrong. `../discussion_notes.py`: opening a discussion on a report (the inbox "Discuss" action, which kicks off a Q&A task) also leaves the user's question here as an `origin=report_discussion` note, targeted at the authoring scout — framed as context to weigh or ignore, not a verdict, so the scout can fold a durable preference/correction into its scratchpad or dismiss it as noise. `../feedback_notes.py`: the thumbs rating at the end of a report body ("Was this report useful?") carries its optional note here as an `origin=report_feedback` note, targeted at the authoring scout. Unlike a dismissal it never falls back to a fleet-wide note — feedback is a verdict on one scout's own report, so with no resolvable authoring scout nothing is forwarded and the call is a no-op — and it never changes the report's state; the analytics event the client fires stays the durable record of the rating. `../reviewer_correction_notes.py`: a user-attributed reviewer edit that changes the set (adding or removing a suggested reviewer) also leaves an `origin=report_reviewer_correction` note, and it is the only derived origin addressed to more than the authoring scout — the authoring scout plus every scout whose `reviewer:` memory names a removed login (`_memory_holders`, one exact-term search under the `reviewer:` key prefix, capped at `MAX_NOTE_TARGETS`), so a scout still routing on a stale login hears about the correction. A report with no live authoring scout falls back to the fleet-wide blank dismissals use, but only when no holder resolved, since a run reads the fleet-wide notes alongside its own and a holder would hear the same edit twice. An impersonated edit forwards nothing, matching the reviewer-corrections project profile, which excludes impersonated activity rows for the same reason. Logins are shape-checked against GitHub's login rule before rendering and capped per edit (`MAX_CORRECTION_LOGINS`), because both write paths into the reviewers artefact accept any string of any length and the value lands in a backtick span every scout reads. Repeated edits coalesce: a login already sent to a target in the same direction inside `SUPPRESSION_WINDOW` is left out of the next note, keyed on direction so a removal still corrects an addition made hours earlier. Like a dismissal it may fall back fleet-wide, and unlike discuss/feedback it does not demand the `signal_scout:write` / `llm_skill:write` key scopes, because the logins already reach scouts through the report's reviewers artefact and the project profile. All four paths re-check the same steering gate (token `scoped_teams`, canonical-project access, and the `llm_skill` editor bar) since the dismiss, discuss, feedback, and reviewer-edit actions need only `task:write`, and all forward only on the canonical team. The discuss and feedback paths additionally demand the `signal_scout:write` / `llm_skill:write` key scopes: a dismissal's text reaches runs anyway through the reports API, whereas the note is the only path a discussion question or feedback note takes to a scout, so a `task:write` credential must not open it alone. The discuss path is triggered from the tasks viewset (which holds the request the gate reads) through `facade/api.py:forward_report_discussion_note`, never from the tasks facade. On the read side, every derived origin quotes report content (report id, title, the note text), so `SignalScoutNoteViewSet.list` withholds them from any caller failing the reports read gate (`_may_read_reports`); both that gate and `../report_steering.py` read the list off `SignalScoutNote.derived_origins()` rather than naming the kinds, so a newly added origin is withheld from the moment it exists. The derived rows are context with a TTL; the `dismissal` artefact / discussion task / feedback analytics event / reviewer `suggested_reviewers` artefact + `suggested_reviewers_changed` activity-log row stays the record of truth. Notes reach two surfaces outside the fleet, both through `../report_steering.py`. `load_report_steering` renders the `HUMAN`-origin ones into the description of the self-driving implementation task, so steering that used to stop at the scout also reaches the run that writes the code; the derived origins are withheld there for the reason the read gate withholds them — they quote report content, which is built from raw product data, and that run can open a PR. `load_research_steering` renders every origin into the pipeline's report-research prompt, because the derived ones are feedback on exactly the judgment that stage is about to make; that run is read-only, already holds the report's raw signals, and writes back only to the report on the same team.
+ - `notes.py` — `list_notes` / `leave_note` / `delete_note` backed by the `SignalScoutNote` model: steering notes humans (or other agents) leave for the fleet over the public MCP surface (`scout-notes-*` tools), the inbound counterpart to the scratchpad. A note targets one scout by `skill_name` or the whole fleet (blank), optionally expiring via `expires_at`; the run prompt's _Notes left for you_ section directs every scout to `scout-notes-list` its own notes in step 1 and treat them as advisory steering. A third audience is a stage of the report pipeline, addressed through the reserved `pipeline:*` family (`PIPELINE_AUDIENCES`, holding `pipeline:report-research` today): a pseudo-target riding the same `skill_name` column, allowlisted at write time so an unrecognized one is rejected instead of silently steering no one, and skipping the scout-skill lookup because a stage has no `LLMSkill` row. `list_notes` matches `skill_name` exactly, so no scout ever sees a pipeline note; the research loader in `../report_steering.py` reads `pipeline:report-research` alongside the report's scout target and the fleet-wide blanks. `validate_note_target`, the shared write-time rule, and the audience constants live in `../note_targets.py`, an import-light module, because the Django admin form calls the rule at registry load and importing anything under `tools/` runs that package's `__init__`, which pulls in every harness tool. Unlike the scratchpad there is no sandbox-only write gate, but writes still demand skill-authoring-level authorization (keys need `llm_skill:write` on top of `signal_scout:write`, and every writer must clear the `llm_skill` RBAC editor bar) — so a note-writer could already steer the fleet by editing its skills, and notes add no new steering power. Four more writers derive rows from inbox activity. `../dismissal_notes.py`: judging an inbox report with a note (dismiss, snooze, or restore) also leaves it here as an `origin=report_dismissal` note, targeted at the scout that authored the report, so a reviewer's verdict reaches the scout without it having to re-find the report. Resolving does not, since that says the report did its job rather than that filing it was wrong. `../discussion_notes.py`: opening a discussion on a report (the inbox "Discuss" action, which kicks off a Q&A task) also leaves the user's question here as an `origin=report_discussion` note, targeted at the authoring scout — framed as context to weigh or ignore, not a verdict, so the scout can fold a durable preference/correction into its scratchpad or dismiss it as noise. `../feedback_notes.py`: the thumbs rating at the end of a report body ("Was this report useful?") carries its optional note here as an `origin=report_feedback` note, targeted at the authoring scout. Unlike a dismissal it never falls back to a fleet-wide note — feedback is a verdict on one scout's own report, so with no resolvable authoring scout nothing is forwarded and the call is a no-op — and it never changes the report's state; the analytics event the client fires stays the durable record of the rating. `../reviewer_correction_notes.py`: a user-attributed reviewer edit that changes the set (adding or removing a suggested reviewer) also leaves an `origin=report_reviewer_correction` note, and it is the only derived origin addressed to more than one scout — every live scout that emitted or edited the report (`resolve_touching_scout_skills`, since an editing scout may be the one that put the reviewers there) plus every scout whose `reviewer:` memory names a removed login (`_memory_holders`, one exact-term search under the `reviewer:` key prefix), ordered emitting scout first and capped at `MAX_NOTE_TARGETS`, so a scout still routing on a stale login hears about the correction. A report no live scout touched falls back to the fleet-wide blank dismissals use, but only when no holder resolved, since a run reads the fleet-wide notes alongside its own and a holder would hear the same edit twice. An impersonated edit forwards nothing, matching the reviewer-corrections project profile, which excludes impersonated activity rows for the same reason. Logins are shape-checked against GitHub's login rule before rendering and capped per edit (`MAX_CORRECTION_LOGINS`), because both write paths into the reviewers artefact accept any string of any length and the value lands in a backtick span every scout reads. Repeated edits coalesce: a login already sent to a target in the same direction inside `SUPPRESSION_WINDOW` is left out of the next note, keyed on direction so a removal still corrects an addition made hours earlier. Like a dismissal it may fall back fleet-wide, and unlike discuss/feedback it does not demand the `signal_scout:write` / `llm_skill:write` key scopes, because the logins already reach scouts through the report's reviewers artefact and the project profile. All four paths re-check the same steering gate (token `scoped_teams`, canonical-project access, and the `llm_skill` editor bar) since the dismiss, discuss, feedback, and reviewer-edit actions need only `task:write`, and all forward only on the canonical team. The discuss and feedback paths additionally demand the `signal_scout:write` / `llm_skill:write` key scopes: a dismissal's text reaches runs anyway through the reports API, whereas the note is the only path a discussion question or feedback note takes to a scout, so a `task:write` credential must not open it alone. The discuss path is triggered from the tasks viewset (which holds the request the gate reads) through `facade/api.py:forward_report_discussion_note`, never from the tasks facade. On the read side, every derived origin quotes report content (report id, title, the note text), so `SignalScoutNoteViewSet.list` withholds them from any caller failing the reports read gate (`_may_read_reports`); both that gate and `../report_steering.py` read the list off `SignalScoutNote.derived_origins()` rather than naming the kinds, so a newly added origin is withheld from the moment it exists. The derived rows are context with a TTL; the `dismissal` artefact / discussion task / feedback analytics event / reviewer `suggested_reviewers` artefact + `suggested_reviewers_changed` activity-log row stays the record of truth. Notes reach two surfaces outside the fleet, both through `../report_steering.py`. `load_report_steering` renders the `HUMAN`-origin ones into the description of the self-driving implementation task, so steering that used to stop at the scout also reaches the run that writes the code; the derived origins are withheld there for the reason the read gate withholds them — they quote report content, which is built from raw product data, and that run can open a PR. `load_research_steering` renders every origin into the pipeline's report-research prompt, because the derived ones are feedback on exactly the judgment that stage is about to make; that run is read-only, already holds the report's raw signals, and writes back only to the report on the same team.
- `structured_output.py` — `record_structured_output` (+ `_sync`): the structured-output channel, next to signals and reports. Opt-in via `SignalScoutConfig.structured_output_schema` (a JSON Schema describing ONE record, validated at config-write time by `validate_structured_output_schema` — which also rejects non-local `$ref`/`$dynamicRef`, and every validator here uses a no-retrieval registry, so a user-controlled schema can never make the worker fetch a URL; null = channel off, and the record endpoint fails closed). Setting the schema is skill-authoring-level steering (schema `description` fields are free prose rendered verbatim into a privileged prompt), so the config viewset gates it behind `llm_skill:write` + the `llm_skill` editor bar, like scout notes; clearing it stays on the base config scope. Records validate against the dispatch-time schema snapshot the runner stamps on the run row (`metadata["structured_output_schema"]`), so a mid-run schema edit can't reject records matching what the run was shown — while clearing the config schema mid-run still fails the channel closed (re-checked inside the capacity-reservation transaction with the config row locked, so a clear racing a submit serializes cleanly). Each submitted record is validated against the schema (all-or-nothing per call — an invalid record fails the batch with nothing written) and written into the team's own project as a `$scout_structured_output` event via one `capture_batch_internal` call (person processing off, deterministic uuid over `(run, batch index, subject, payload)` so a resubmitted batch collapses at ingestion while in-batch duplicates stay distinct). The events ARE the record — there is no Postgres row store, so past records are read like any events (insights, HogQL) and retention follows event retention — which is also why a delivery failure fails the call (`StructuredOutputDeliveryError` → 503) with an instruction to retry — the events carry a stable timestamp (the run's `created_at`) alongside the deterministic uuid, so the dedupe sorting key (`toDate(timestamp)` is part of it) stays identical across retries even past UTC midnight — and why the channel fails loudly for a dry-run `emit=False` scout, an org without AI-processing consent (mirroring `emit._preflight_emit_gates`), or a disabled `signals_scout` source instead of suppressing quietly (the runner also withholds the prompt section and schema snapshot when `emit` is off). Cardinality is the scout's call — the schema describes one record; a run may submit one, one per judged entity, or a batch (caps: `MAX_RECORDS_PER_CALL` per call, `MAX_RECORDS_PER_RUN` per run via the `structured_output_count` counter on `run.metadata`, reserved under the run-row lock before the forward — it counts accepted batches, so failed or retried forwards still spend cap). The prompt renders the exact configured schema in a per-run `# Structured output` section only when the channel is live, so the prompt and the validator can never describe two different contracts.
- `profile.py` — `project_profile_*` tools that read the deterministic `SignalProjectProfile` snapshot.
- `runs.py` — `runs_*` tools that read past `SignalScoutRun` rows for dedupe and cross-skill awareness.
diff --git a/products/signals/backend/scout_harness/prompt.py b/products/signals/backend/scout_harness/prompt.py
index e509aa1d3cec..438854c742b6 100644
--- a/products/signals/backend/scout_harness/prompt.py
+++ b/products/signals/backend/scout_harness/prompt.py
@@ -238,7 +238,7 @@ Each note's `origin` says how to read it, and each names the report ids it conce
- `human`: steering someone wrote for you directly.
- `report_dismissal`: a reviewer's verdict on one or more of your reports, forwarded so it reaches you without you re-finding them. One note covers one verdict, so when a reviewer acted on several reports at once read it as their view of that batch, never as a fleet-wide rule. **Dismissed** is the only kind that should make you stop filing something, and the reason code decides whether it even means that: `analysis_wrong`, `report_unclear`, and `wontfix_*` speak to your precision, so fold a reason that generalizes into a `noise:`/`pattern:` entry; `wrong_repo` says the report targeted the wrong repository, not that the finding was wrong — keep watching the topic, record the repository the note says was wrong so you do not pick it again for that kind of work, and record the corrected repository when the note names one; `already_fixed` means the issue was real and someone fixed it, so record that a fix shipped and keep watching for a recurrence. **Snoozed or restored** is about timing, not correctness: the report is still live, so keep watching what it describes.
- `report_discussion`: a question a user asked when they opened a discussion on one of your reports. Not a verdict and not a directive, but often carrying a preference, a correction, or context you couldn't have known ("this is expected, it's the approval flow"): fold the durable part into a `noise:`/`pattern:`/`watch:` entry, and leave one-off asks and unrelated chatter be.
-- `report_reviewer_correction`: someone added or removed a suggested reviewer on a report. This is the strongest ownership evidence there is, and the note reaches you because you either filed the report or hold a `reviewer:` memory naming the login. An added login is a positive ownership fact, so record it with the report id and the date. A removal is weaker on its own (someone away, a duplicate reviewer, noise the editor trimmed), and weaker still when the editor removed their own login, but repeated removals of the same login on the same surface say the memory you route on is stale. Search your `reviewer:` keys for the login and condense rather than delete: fold in that a teammate removed it, on how many reports and when, and keep the ownership evidence that still stands. Do not put a removed login back on a report about the same topic without new evidence.
+- `report_reviewer_correction`: someone added or removed a suggested reviewer on a report. This is the strongest ownership evidence there is, and the note reaches you because you either filed the report, edited it, or hold a `reviewer:` memory naming the login. An added login is a positive ownership fact, so record it with the report id and the date. A removal is weaker on its own (someone away, a duplicate reviewer, noise the editor trimmed), and weaker still when the editor removed their own login, but repeated removals of the same login on the same surface say the memory you route on is stale. Search your `reviewer:` keys for the login and condense rather than delete: fold in that a teammate removed it, on how many reports and when, and keep the ownership evidence that still stands. Do not put a removed login back on a report about the same topic without new evidence.
A resolved report never reaches you this way, because resolving means the report did its job rather than that filing it was wrong. Its note stays on the report, so read `dismissal_note` there when your inbox search turns it up, and record that a fix shipped and when, so you can tell a later recurrence from the original.
diff --git a/products/signals/backend/test/test_reviewer_correction_scout_notes.py b/products/signals/backend/test/test_reviewer_correction_scout_notes.py
index 7c57584b16c5..576799e47fd5 100644
--- a/products/signals/backend/test/test_reviewer_correction_scout_notes.py
+++ b/products/signals/backend/test/test_reviewer_correction_scout_notes.py
@@ -193,6 +193,59 @@ class TestReviewerCorrectionScoutNotes(APIBaseTest):
# routing on the login somebody just took off.
assert sorted(note.skill_name for note in self._correction_notes()) == [SCOUT_SKILL, OTHER_SCOUT_SKILL]
+ @parameterized.expand([("added", {"added": ("octocat",)}), ("removed", {"removed": ("octocat",)})])
+ def test_a_scout_that_edited_the_report_is_told(self, _name: str, edit: dict[str, tuple[str, ...]]) -> None:
+ self._create_skill()
+ self._create_skill(OTHER_SCOUT_SKILL)
+ report = self._create_report()
+ self._create_run(emitted_report_ids=[str(report.id)])
+ self._create_run(skill_name=OTHER_SCOUT_SKILL, edited_report_ids=[str(report.id)])
+
+ self._forward(report, **edit)
+
+ # An edit is how a scout puts reviewers on a report it did not file, so the editor did the
+ # routing this human corrected — for an addition too, which no memory search would find.
+ assert [note.skill_name for note in self._correction_notes()] == [SCOUT_SKILL, OTHER_SCOUT_SKILL]
+
+ def test_a_deleted_editing_scout_is_not_told(self) -> None:
+ self._create_skill()
+ LLMSkill.objects.create(team=self.team, name=OTHER_SCOUT_SKILL, description="gone", body="# gone", deleted=True)
+ report = self._create_report()
+ self._create_run(emitted_report_ids=[str(report.id)])
+ self._create_run(skill_name=OTHER_SCOUT_SKILL, edited_report_ids=[str(report.id)])
+
+ self._forward(report, removed=("octocat",))
+
+ # The touching union keeps deleted skills on purpose for autostart exclusion, so it has to be
+ # filtered here: a note addressed to a name no run answers to steers no one.
+ assert [note.skill_name for note in self._correction_notes()] == [SCOUT_SKILL]
+
+ def test_a_touching_scout_that_also_holds_the_memory_is_told_once(self) -> None:
+ self._create_skill()
+ self._create_skill(OTHER_SCOUT_SKILL)
+ report = self._create_report()
+ self._create_run(emitted_report_ids=[str(report.id)])
+ self._create_run(skill_name=OTHER_SCOUT_SKILL, edited_report_ids=[str(report.id)])
+ for index, skill_name in enumerate((SCOUT_SKILL, OTHER_SCOUT_SKILL)):
+ self._remember(
+ key=f"reviewer:products/logs{index}", content="octocat owns the logs path", skill_name=skill_name
+ )
+
+ self._forward(report, removed=("octocat",))
+
+ assert [note.skill_name for note in self._correction_notes()] == [SCOUT_SKILL, OTHER_SCOUT_SKILL]
+
+ def test_an_editing_scout_replaces_the_fleet_wide_fallback(self) -> None:
+ self._create_skill(OTHER_SCOUT_SKILL)
+ report = self._create_report()
+ self._create_run(skill_name=OTHER_SCOUT_SKILL, edited_report_ids=[str(report.id)])
+
+ self._forward(report, removed=("octocat",))
+
+ # Nobody emitted this report, but a scout edited it, so the correction has an audience and
+ # must not go to the whole fleet.
+ assert [note.skill_name for note in self._correction_notes()] == [OTHER_SCOUT_SKILL]
+
def test_a_login_that_is_only_a_substring_of_a_memory_is_not_a_holder(self) -> None:
self._create_skill()
self._create_skill(OTHER_SCOUT_SKILL)