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.

fix(signals): stop advertising metric goals the emit-report writer rejects (#110594)

posthog[bot]a9e2aad61f38
diff --git a/products/signals/backend/serializers.py b/products/signals/backend/serializers.py
index 0f7259a03954..402f0affcc21 100644
--- a/products/signals/backend/serializers.py
+++ b/products/signals/backend/serializers.py
@@ -1114,16 +1114,24 @@ class ReportMetricWriteSerializer(ReportMetricSerializer):
default=None,
help_text="Legacy optional comparison. New report metrics must omit it.",
)
-
- def validate(self, attrs: dict[str, object]) -> dict[str, object]:
- if any(
- attrs.get(field) is not None
+ # Proposed goals live in impact_measurement_plan artefacts, so the authoring schema must not advertise them.
+ goal_value = None # type: ignore[assignment]
+ goal_direction = None # type: ignore[assignment]
+ goal_grain = None # type: ignore[assignment]
+ decision_window_days = None # type: ignore[assignment]
+ minimum_data_points = None # type: ignore[assignment]
+
+ def to_internal_value(self, data: object) -> dict[str, object]:
+ # DRF ignores undeclared keys, so check the raw payload to keep the rejection explicit.
+ # `goal_grain` stays out of this check: an older client fills its schema default on every metric.
+ if isinstance(data, Mapping) and any(
+ data.get(field) is not None
for field in ("goal_value", "goal_direction", "decision_window_days", "minimum_data_points")
):
raise serializers.ValidationError(
"Write proposed goals as impact_measurement_plan artefacts, not report metrics."
)
- return attrs
+ return super().to_internal_value(data)
class ReportMetricListSerializer(ReportMetricSerializer):
diff --git a/products/signals/backend/test/test_scout_report_api.py b/products/signals/backend/test/test_scout_report_api.py
index 244e6f8043e0..06803108ce02 100644
--- a/products/signals/backend/test/test_scout_report_api.py
+++ b/products/signals/backend/test/test_scout_report_api.py
@@ -37,7 +37,7 @@ from products.signals.backend.models import (
SignalSourceConfig,
)
from products.signals.backend.report_generation.resolve_reviewers import ReviewerIdentitySet
-from products.signals.backend.scout_harness.serializers import EditReportRequestSerializer
+from products.signals.backend.scout_harness.serializers import EditReportRequestSerializer, EmitReportRequestSerializer
from products.signals.backend.scout_harness.tools.emit import remediation_for_skip
from products.signals.backend.scout_harness.tools.report import (
MAX_EVIDENCE_DESCRIPTION_LENGTH,
@@ -2840,3 +2840,49 @@ class TestScoutReportCheckAPI(APIBaseTest):
assert response.status_code == status.HTTP_200_OK, response.content
assert response.json()["status"] == "cancelled"
+
+
+class TestEmitReportMetricGoalFields(SimpleTestCase):
+ def _payload(self, **metric_overrides: object) -> dict:
+ metric = {
+ "metric_id": "affected-users",
+ "title": "Affected users",
+ "kind": "affected_users",
+ "role": "primary",
+ "value_format": "count",
+ "query": trends_metric_query(series=[{"kind": "EventsNode", "event": "$exception", "math": "dau"}]),
+ **metric_overrides,
+ }
+ return {
+ "title": "Checkout p99 regressed after 4.2",
+ "summary": "The /checkout endpoint p99 doubled after the 4.2 deploy.",
+ "evidence": [{"description": "p99 doubled on /checkout", "source_id": "obs-1"}],
+ "actionability_explanation": "clear fix in the checkout handler",
+ "actionability": "immediately_actionable",
+ "priority": "P2",
+ "priority_explanation": "Checkout is a revenue path.",
+ "metrics": [metric],
+ }
+
+ @parameterized.expand(
+ [
+ ("goal_value", {"goal_value": 10}),
+ ("goal_direction", {"goal_direction": "at_most"}),
+ ("decision_window_days", {"decision_window_days": 7}),
+ ("minimum_data_points", {"minimum_data_points": 30}),
+ ]
+ )
+ def test_a_metric_goal_is_rejected_although_the_schema_omits_it(self, _name: str, goal: dict) -> None:
+ serializer = EmitReportRequestSerializer(data=self._payload(**goal))
+
+ assert not serializer.is_valid()
+ assert "impact_measurement_plan" in str(serializer.errors["metrics"])
+
+ @parameterized.expand(
+ [("no_goal_fields", {}), ("goal_grain_default_from_an_older_client", {"goal_grain": "whole_window"})]
+ )
+ def test_a_metric_without_a_goal_is_accepted(self, _name: str, extra: dict) -> None:
+ serializer = EmitReportRequestSerializer(data=self._payload(**extra))
+
+ assert serializer.is_valid(), serializer.errors
+ assert "goal_grain" not in serializer.validated_data["metrics"][0]
diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.ts
index 7fb3f641800a..289699893da5 100644
--- a/products/signals/frontend/generated/api.schemas.ts
+++ b/products/signals/frontend/generated/api.schemas.ts
@@ -5377,35 +5377,6 @@ export interface ReportMetricWriteApi {
* @nullable
*/
caption?: string | null
- /**
- * Proposed threshold after release. Informational only; does not schedule a check.
- * @nullable
- */
- goal_value?: number | null
- /** Whether success means at most or at least goal_value.
- *
- * * `at_most` - at_most
- * * `at_least` - at_least */
- goal_direction?: GoalDirectionEnumApi | null
- /** Whether the goal compares with the whole query window or each chart bucket.
- *
- * * `whole_window` - whole_window
- * * `per_interval` - per_interval */
- goal_grain?: GoalGrainEnumApi
- /**
- * Suggested days after release before assessing impact, not a monitoring schedule.
- * @minimum 1
- * @maximum 30
- * @nullable
- */
- decision_window_days?: number | null
- /**
- * Optional number of qualifying observations before assessing impact.
- * @minimum 1
- * @maximum 1000
- * @nullable
- */
- minimum_data_points?: number | null
/** Legacy optional comparison. New report metrics must omit it. */
comparison?: ReportMetricComparisonApi | null
}
diff --git a/products/signals/frontend/generated/api.zod.ts b/products/signals/frontend/generated/api.zod.ts
index 95ea45346c97..7bf8156bb27a 100644
--- a/products/signals/frontend/generated/api.zod.ts
+++ b/products/signals/frontend/generated/api.zod.ts
@@ -1557,11 +1557,6 @@ export const signalsScoutEditReportBodyMetricsItemUnitMax = 40
export const signalsScoutEditReportBodyMetricsItemCaptionMax = 500
-export const signalsScoutEditReportBodyMetricsItemGoalGrainDefault = `whole_window`
-export const signalsScoutEditReportBodyMetricsItemDecisionWindowDaysMax = 30
-
-export const signalsScoutEditReportBodyMetricsItemMinimumDataPointsMax = 1000
-
export const signalsScoutEditReportBodyMetricsItemComparisonOneLabelMax = 40
export const signalsScoutEditReportBodyMetricsMax = 6
@@ -1791,44 +1786,6 @@ export const SignalsScoutEditReportBody = /* @__PURE__ */ zod
.describe(
'Optional context the tile cannot show, such as a filter that narrows the count or a caveat on the data. Omit it rather than restate the title, unit, or window.'
),
- goal_value: zod
- .number()
- .nullish()
- .describe(
- 'Proposed threshold after release. Informational only; does not schedule a check.'
- ),
- goal_direction: zod
- .union([
- zod
- .enum(['at_most', 'at_least'])
- .describe('\* `at_most` - at_most\n\* `at_least` - at_least'),
- zod.null(),
- ])
- .optional()
- .describe(
- 'Whether success means at most or at least goal_value.\n\n\* `at_most` - at_most\n\* `at_least` - at_least'
- ),
- goal_grain: zod
- .enum(['whole_window', 'per_interval'])
- .describe('\* `whole_window` - whole_window\n\* `per_interval` - per_interval')
- .default(signalsScoutEditReportBodyMetricsItemGoalGrainDefault)
- .describe(
- 'Whether the goal compares with the whole query window or each chart bucket.\n\n\* `whole_window` - whole_window\n\* `per_interval` - per_interval'
- ),
- decision_window_days: zod
- .number()
- .min(1)
- .max(signalsScoutEditReportBodyMetricsItemDecisionWindowDaysMax)
- .nullish()
- .describe(
- 'Suggested days after release before assessing impact, not a monitoring schedule.'
- ),
- minimum_data_points: zod
- .number()
- .min(1)
- .max(signalsScoutEditReportBodyMetricsItemMinimumDataPointsMax)
- .nullish()
- .describe('Optional number of qualifying observations before assessing impact.'),
comparison: zod
.union([
zod.object({
@@ -1933,11 +1890,6 @@ export const signalsScoutEmitReportBodyMetricsItemUnitMax = 40
export const signalsScoutEmitReportBodyMetricsItemCaptionMax = 500
-export const signalsScoutEmitReportBodyMetricsItemGoalGrainDefault = `whole_window`
-export const signalsScoutEmitReportBodyMetricsItemDecisionWindowDaysMax = 30
-
-export const signalsScoutEmitReportBodyMetricsItemMinimumDataPointsMax = 1000
-
export const signalsScoutEmitReportBodyMetricsItemComparisonOneLabelMax = 40
export const signalsScoutEmitReportBodyMetricsMax = 6
@@ -2183,44 +2135,6 @@ export const SignalsScoutEmitReportBody = /* @__PURE__ */ zod
.describe(
'Optional context the tile cannot show, such as a filter that narrows the count or a caveat on the data. Omit it rather than restate the title, unit, or window.'
),
- goal_value: zod
- .number()
- .nullish()
- .describe(
- 'Proposed threshold after release. Informational only; does not schedule a check.'
- ),
- goal_direction: zod
- .union([
- zod
- .enum(['at_most', 'at_least'])
- .describe('\* `at_most` - at_most\n\* `at_least` - at_least'),
- zod.null(),
- ])
- .optional()
- .describe(
- 'Whether success means at most or at least goal_value.\n\n\* `at_most` - at_most\n\* `at_least` - at_least'
- ),
- goal_grain: zod
- .enum(['whole_window', 'per_interval'])
- .describe('\* `whole_window` - whole_window\n\* `per_interval` - per_interval')
- .default(signalsScoutEmitReportBodyMetricsItemGoalGrainDefault)
- .describe(
- 'Whether the goal compares with the whole query window or each chart bucket.\n\n\* `whole_window` - whole_window\n\* `per_interval` - per_interval'
- ),
- decision_window_days: zod
- .number()
- .min(1)
- .max(signalsScoutEmitReportBodyMetricsItemDecisionWindowDaysMax)
- .nullish()
- .describe(
- 'Suggested days after release before assessing impact, not a monitoring schedule.'
- ),
- minimum_data_points: zod
- .number()
- .min(1)
- .max(signalsScoutEmitReportBodyMetricsItemMinimumDataPointsMax)
- .nullish()
- .describe('Optional number of qualifying observations before assessing impact.'),
comparison: zod
.union([
zod.object({
diff --git a/products/signals/skills/authoring-scouts/references/report-contract.md b/products/signals/skills/authoring-scouts/references/report-contract.md
index 34a56fdd9131..30bf168a9991 100644
--- a/products/signals/skills/authoring-scouts/references/report-contract.md
+++ b/products/signals/skills/authoring-scouts/references/report-contract.md
@@ -51,18 +51,18 @@ A weak or partial observation belongs in the scratchpad, where a future run (wit
Judges the report for safety, then persists it at the judged status.
-| Field | Type | Notes |
-| --------------------------- | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `run_id` | string, required | The current run's id — the run you're executing in, same as every `scout-*` tool. |
-| `title` | string, ≤300, non-empty | The inbox headline. One specific, quantified line. |
-| `summary` | string | The report body prose — one tight passage a busy human can act on: a **quantified hook** (what's happening, with numbers), the **pattern** that makes it signal rather than noise, the suspected-cause **hypothesis**, and the **recommendation**. Cite entities inline as markdown links so the reader pivots straight to source (see below). |
-| `evidence` | list, 1–50 | Each `{description, source_id}`. Becomes a bound signal row backing the report. `source_id` is the citable entity id. Hard cap of **50** — summarize/trim before calling; a longer list fails validation before the report is judged or persisted. |
-| `actionability_explanation` | string | One sentence justifying the actionability call below. |
-| `actionability` | enum | `immediately_actionable` / `requires_human_input` / `not_actionable`. You make this call — the channel does not re-research it. See _Choosing actionability_ below. |
-| `already_addressed` | bool, default `false` | Set when the underlying issue is already handled and you're filing for the record. |
-| `metrics` | list, ≤6, optional | Typed impact measurements the inbox shows as tiles. The report's full set. Each `{metric_id, title, kind, query, role?, value?, value_at?, series?, value_format?, unit?, caption?}`. See _Measuring impact_ below. |
-| `charts` | list, ≤20, optional | Queries the inbox draws on the report — the report's full set, replacing any it already had. Each `{chart_id, title, query, caption?, size?}`. See _Attaching charts_ below. |
-| `suggested_prompts` | list, ≤3, optional | Follow-up prompts the inbox offers above the report's `Ask AI` box (questions to ask, or next-step actions to request), each ≤200 characters and all distinct. See _Suggesting follow-up prompts_ below. |
+| Field | Type | Notes |
+| --------------------------- | --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `run_id` | string, required | The current run's id — the run you're executing in, same as every `scout-*` tool. |
+| `title` | string, required, ≤300, non-empty | The inbox headline. One specific, quantified line. |
+| `summary` | string, required | The report body prose — one tight passage a busy human can act on: a **quantified hook** (what's happening, with numbers), the **pattern** that makes it signal rather than noise, the suspected-cause **hypothesis**, and the **recommendation**. Cite entities inline as markdown links so the reader pivots straight to source (see below). |
+| `evidence` | list, required, 1–50 | Each `{description, source_id}`. Becomes a bound signal row backing the report. `source_id` is the citable entity id. Hard cap of **50** — summarize/trim before calling; a longer list fails validation before the report is judged or persisted. |
+| `actionability_explanation` | string, required | One sentence justifying the actionability call below. |
+| `actionability` | enum, required | `immediately_actionable` / `requires_human_input` / `not_actionable`. You make this call — the channel does not re-research it. See _Choosing actionability_ below. |
+| `already_addressed` | bool, default `false` | Set when the underlying issue is already handled and you're filing for the record. |
+| `metrics` | list, ≤6, optional | Typed impact measurements the inbox shows as tiles. The report's full set. Each `{metric_id, title, kind, query, role?, value?, value_at?, series?, value_format?, unit?, caption?}`. See _Measuring impact_ below. |
+| `charts` | list, ≤20, optional | Queries the inbox draws on the report — the report's full set, replacing any it already had. Each `{chart_id, title, query, caption?, size?}`. See _Attaching charts_ below. |
+| `suggested_prompts` | list, ≤3, optional | Follow-up prompts the inbox offers above the report's `Ask AI` box (questions to ask, or next-step actions to request), each ≤200 characters and all distinct. See _Suggesting follow-up prompts_ below. |
**Cite each entity as a link, not a bare id.** In `summary` and in `evidence` descriptions, write
the entity you name as a markdown link: reuse the url the returning tool attached (`_posthogUrl`
diff --git a/products/signals/skills/signals-scout-anomaly-detection/references/report-contract.md b/products/signals/skills/signals-scout-anomaly-detection/references/report-contract.md
index 21452093157e..053a39a6340a 100644
--- a/products/signals/skills/signals-scout-anomaly-detection/references/report-contract.md
+++ b/products/signals/skills/signals-scout-anomaly-detection/references/report-contract.md
@@ -27,19 +27,19 @@ Below that bar, write a `baseline:` / `noise:` scratchpad entry instead — don'
## `emit_report` — author a full report
-| Field | Type | Notes |
-| --------------------------- | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `title` | string, ≤300, non-empty | The inbox headline. One specific, quantified line (see below). |
-| `summary` | string | The report body prose — hook → pattern → hypothesis → lineage → recommendation (see below). |
-| `evidence` | list, 1–50 | Each `{description, source_id}`. Becomes a bound signal row backing the report. |
-| `actionability_explanation` | string | One sentence justifying the actionability call. |
-| `actionability` | enum | `immediately_actionable` / `requires_human_input` / `not_actionable`. You make the call. |
-| `already_addressed` | bool, default `false` | Set when the move is already handled and you're filing for the record. |
-| `suggested_reviewers` | list of objects | Who owns the metric/dashboard — routes the report. Each entry is `{github_login}` and/or `{user_uuid}` (not a bare string). High-leverage — set it (see below). |
-| `priority` | `P0`–`P4` | Optional; pair with `priority_explanation`. Needed for an autostart draft PR. |
-| `priority_explanation` | string | Required when `priority` is set. |
-| `repository` | string | `owner/repo` for a code fix, the `NO_REPO` sentinel for a pure metric move, omitted for free-form. |
-| `charts` | list, optional | Queries the inbox draws on the report itself — see _Charts on the report_ below. |
+| Field | Type | Notes |
+| --------------------------- | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `title` | string, required, ≤300, non-empty | The inbox headline. One specific, quantified line (see below). |
+| `summary` | string, required | The report body prose — hook → pattern → hypothesis → lineage → recommendation (see below). |
+| `evidence` | list, required, 1–50 | Each `{description, source_id}`. Becomes a bound signal row backing the report. |
+| `actionability_explanation` | string, required | One sentence justifying the actionability call. |
+| `actionability` | enum, required | `immediately_actionable` / `requires_human_input` / `not_actionable`. You make the call. |
+| `already_addressed` | bool, default `false` | Set when the move is already handled and you're filing for the record. |
+| `suggested_reviewers` | list of objects | Who owns the metric/dashboard — routes the report. Each entry is `{github_login}` and/or `{user_uuid}` (not a bare string). High-leverage — set it (see below). |
+| `priority` | `P0`–`P4` | Optional; pair with `priority_explanation`. Needed for an autostart draft PR. |
+| `priority_explanation` | string | Required when `priority` is set. |
+| `repository` | string | `owner/repo` for a code fix, the `NO_REPO` sentinel for a pure metric move, omitted for free-form. |
+| `charts` | list, optional | Queries the inbox draws on the report itself — see _Charts on the report_ below. |
The result carries `report_id` (always set when a report was persisted — even when suppressed,
so you can edit / dedup against it), `report_status`, `emitted` (true only when it surfaced as
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 0e45c473cde8..5ce7fe119156 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -36891,30 +36891,6 @@ export namespace Schemas {
size?: SizeEnum | null;
}
- /**
- * * `at_most` - at_most
- * * `at_least` - at_least
- */
- export type GoalDirectionEnum = typeof GoalDirectionEnum[keyof typeof GoalDirectionEnum];
-
-
- export const GoalDirectionEnum = {
- AtMost: 'at_most',
- AtLeast: 'at_least',
- } as const;
-
- /**
- * * `whole_window` - whole_window
- * * `per_interval` - per_interval
- */
- export type GoalGrainEnum = typeof GoalGrainEnum[keyof typeof GoalGrainEnum];
-
-
- export const GoalGrainEnum = {
- WholeWindow: 'whole_window',
- PerInterval: 'per_interval',
- } as const;
-
export interface ReportMetricComparison {
/** Baseline or previous value, formatted like the current value. */
value: number;
@@ -36994,35 +36970,6 @@ export namespace Schemas {
* @nullable
*/
caption?: string | null;
- /**
- * Proposed threshold after release. Informational only; does not schedule a check.
- * @nullable
- */
- goal_value?: number | null;
- /** Whether success means at most or at least goal_value.
- *
- * * `at_most` - at_most
- * * `at_least` - at_least */
- goal_direction?: GoalDirectionEnum | null;
- /** Whether the goal compares with the whole query window or each chart bucket.
- *
- * * `whole_window` - whole_window
- * * `per_interval` - per_interval */
- goal_grain?: GoalGrainEnum;
- /**
- * Suggested days after release before assessing impact, not a monitoring schedule.
- * @minimum 1
- * @maximum 30
- * @nullable
- */
- decision_window_days?: number | null;
- /**
- * Optional number of qualifying observations before assessing impact.
- * @minimum 1
- * @maximum 1000
- * @nullable
- */
- minimum_data_points?: number | null;
/** Legacy optional comparison. New report metrics must omit it. */
comparison?: ReportMetricComparison | null;
}
@@ -51096,6 +51043,18 @@ export namespace Schemas {
change: WoWChange | null;
}
+ /**
+ * * `at_most` - at_most
+ * * `at_least` - at_least
+ */
+ export type GoalDirectionEnum = typeof GoalDirectionEnum[keyof typeof GoalDirectionEnum];
+
+
+ export const GoalDirectionEnum = {
+ AtMost: 'at_most',
+ AtLeast: 'at_least',
+ } as const;
+
export interface GoalEventSample {
/** UUID of the sampled conversion event */
event_uuid: string;
@@ -51192,6 +51151,18 @@ export namespace Schemas {
notes: string[];
}
+ /**
+ * * `whole_window` - whole_window
+ * * `per_interval` - per_interval
+ */
+ export type GoalGrainEnum = typeof GoalGrainEnum[keyof typeof GoalGrainEnum];
+
+
+ export const GoalGrainEnum = {
+ WholeWindow: 'whole_window',
+ PerInterval: 'per_interval',
+ } as const;
+
export interface GoogleSearchConsoleSearchOpportunitySignalExtra {
page: string;
query: string;
diff --git a/services/mcp/src/generated/signals/api.ts b/services/mcp/src/generated/signals/api.ts
index 479262d0f3fc..4dbd62c0f6d2 100644
--- a/services/mcp/src/generated/signals/api.ts
+++ b/services/mcp/src/generated/signals/api.ts
@@ -1845,11 +1845,6 @@ export const signalsScoutEditReportBodyMetricsItemUnitMax = 40
export const signalsScoutEditReportBodyMetricsItemCaptionMax = 500
-export const signalsScoutEditReportBodyMetricsItemGoalGrainDefault = `whole_window`
-export const signalsScoutEditReportBodyMetricsItemDecisionWindowDaysMax = 30
-
-export const signalsScoutEditReportBodyMetricsItemMinimumDataPointsMax = 1000
-
export const signalsScoutEditReportBodyMetricsItemComparisonOneLabelMax = 40
export const signalsScoutEditReportBodyMetricsMax = 6
@@ -2079,44 +2074,6 @@ export const SignalsScoutEditReportBody = () => zod
.describe(
'Optional context the tile cannot show, such as a filter that narrows the count or a caveat on the data. Omit it rather than restate the title, unit, or window.'
),
- goal_value: zod
- .number()
- .nullish()
- .describe(
- 'Proposed threshold after release. Informational only; does not schedule a check.'
- ),
- goal_direction: zod
- .union([
- zod
- .enum(['at_most', 'at_least'])
- .describe('\* `at_most` - at_most\n\* `at_least` - at_least'),
- zod.null(),
- ])
- .optional()
- .describe(
- 'Whether success means at most or at least goal_value.\n\n\* `at_most` - at_most\n\* `at_least` - at_least'
- ),
- goal_grain: zod
- .enum(['whole_window', 'per_interval'])
- .describe('\* `whole_window` - whole_window\n\* `per_interval` - per_interval')
- .default(signalsScoutEditReportBodyMetricsItemGoalGrainDefault)
- .describe(
- 'Whether the goal compares with the whole query window or each chart bucket.\n\n\* `whole_window` - whole_window\n\* `per_interval` - per_interval'
- ),
- decision_window_days: zod
- .number()
- .min(1)
- .max(signalsScoutEditReportBodyMetricsItemDecisionWindowDaysMax)
- .nullish()
- .describe(
- 'Suggested days after release before assessing impact, not a monitoring schedule.'
- ),
- minimum_data_points: zod
- .number()
- .min(1)
- .max(signalsScoutEditReportBodyMetricsItemMinimumDataPointsMax)
- .nullish()
- .describe('Optional number of qualifying observations before assessing impact.'),
comparison: zod
.union([
zod.object({
@@ -2256,11 +2213,6 @@ export const signalsScoutEmitReportBodyMetricsItemUnitMax = 40
export const signalsScoutEmitReportBodyMetricsItemCaptionMax = 500
-export const signalsScoutEmitReportBodyMetricsItemGoalGrainDefault = `whole_window`
-export const signalsScoutEmitReportBodyMetricsItemDecisionWindowDaysMax = 30
-
-export const signalsScoutEmitReportBodyMetricsItemMinimumDataPointsMax = 1000
-
export const signalsScoutEmitReportBodyMetricsItemComparisonOneLabelMax = 40
export const signalsScoutEmitReportBodyMetricsMax = 6
@@ -2506,44 +2458,6 @@ export const SignalsScoutEmitReportBody = () => zod
.describe(
'Optional context the tile cannot show, such as a filter that narrows the count or a caveat on the data. Omit it rather than restate the title, unit, or window.'
),
- goal_value: zod
- .number()
- .nullish()
- .describe(
- 'Proposed threshold after release. Informational only; does not schedule a check.'
- ),
- goal_direction: zod
- .union([
- zod
- .enum(['at_most', 'at_least'])
- .describe('\* `at_most` - at_most\n\* `at_least` - at_least'),
- zod.null(),
- ])
- .optional()
- .describe(
- 'Whether success means at most or at least goal_value.\n\n\* `at_most` - at_most\n\* `at_least` - at_least'
- ),
- goal_grain: zod
- .enum(['whole_window', 'per_interval'])
- .describe('\* `whole_window` - whole_window\n\* `per_interval` - per_interval')
- .default(signalsScoutEmitReportBodyMetricsItemGoalGrainDefault)
- .describe(
- 'Whether the goal compares with the whole query window or each chart bucket.\n\n\* `whole_window` - whole_window\n\* `per_interval` - per_interval'
- ),
- decision_window_days: zod
- .number()
- .min(1)
- .max(signalsScoutEmitReportBodyMetricsItemDecisionWindowDaysMax)
- .nullish()
- .describe(
- 'Suggested days after release before assessing impact, not a monitoring schedule.'
- ),
- minimum_data_points: zod
- .number()
- .min(1)
- .max(signalsScoutEmitReportBodyMetricsItemMinimumDataPointsMax)
- .nullish()
- .describe('Optional number of qualifying observations before assessing impact.'),
comparison: zod
.union([
zod.object({
diff --git a/services/mcp/tests/unit/signals-emit-report-schema.test.ts b/services/mcp/tests/unit/signals-emit-report-schema.test.ts
index 85875609111c..c42987361ab4 100644
--- a/services/mcp/tests/unit/signals-emit-report-schema.test.ts
+++ b/services/mcp/tests/unit/signals-emit-report-schema.test.ts
@@ -2,22 +2,38 @@ import { describe, expect, it } from 'vitest'
import { z } from 'zod'
import { GENERATED_TOOLS } from '@/tools/generated/signals'
-import { summarizeSchema } from '@/tools/schema-utils'
+import { resolveSchemaPath, summarizeSchema } from '@/tools/schema-utils'
+
+const METRIC_GOAL_FIELDS = ['goal_value', 'goal_direction', 'goal_grain', 'decision_window_days', 'minimum_data_points']
// The emit-report schema overflows the exec output budget, so callers read the compact summary.
// A long summary gets cut off, so the conditional rule must sit before the per-field properties.
describe('scout-emit-report schema summary', () => {
it.each(['scout-emit-report', 'signals-scout-emit-report'])(
- 'lists priority_explanation as required with priority before the properties in %s',
+ 'lists the required fields and priority_explanation with priority before the properties in %s',
(toolName) => {
const tool = GENERATED_TOOLS[toolName]!()
const jsonSchema = z.toJSONSchema(tool.schema, { io: 'input' }) as Record<string, unknown>
const summary = summarizeSchema(jsonSchema, toolName)
+ expect(summary.required).toEqual(
+ expect.arrayContaining(['title', 'summary', 'evidence', 'actionability_explanation', 'actionability'])
+ )
expect(summary.requiredWhenSet).toEqual({ priority: ['priority_explanation'] })
const keys = Object.keys(summary)
expect(keys.indexOf('requiredWhenSet')).toBeLessThan(keys.indexOf('properties'))
}
)
+
+ // The report writer rejects metric goals, so the published schema must not offer them.
+ it.each(['scout-emit-report', 'scout-edit-report'])('does not advertise metric goal fields in %s', (toolName) => {
+ const tool = GENERATED_TOOLS[toolName]!()
+ const jsonSchema = z.toJSONSchema(tool.schema, { io: 'input' }) as Record<string, unknown>
+
+ expect(resolveSchemaPath(jsonSchema, 'metrics.query')).not.toBeNull()
+ for (const field of METRIC_GOAL_FIELDS) {
+ expect(resolveSchemaPath(jsonSchema, `metrics.${field}`)).toBeNull()
+ }
+ })
})