Skip to content

refactor(action-center): gather the engine's thresholds in one place - #821

Merged
gkhngyk merged 1 commit into
mainfrom
refactor/engine-thresholds
Sep 17, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
refactor/engine-thresholds

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Phase 2.5 of #818.

Summary

Nineteen numbers decided what the engine counts as worth reporting, and each lived in whichever file happened to read it:

Where What
pulse/metrics.js how far visibility must fall, how far a competitor must rise, what makes a citation "lost", what counts as a platform outage
signals/record.js the detection window, how many prompts make an uncited-mentions pattern more than an anecdote, when an audit stops being evidence
action-center/generate.js how long a kind rests after a cycle closes
action-center/validate.js the measurement windows and the noise floor
page-opportunities.js the session floor and percentile a page must clear

Survivable at eleven detectors. Phase 3 brings roughly forty, and retuning the engine by hunting through detectors does not scale to that — so this moves before that arrives, while it is still half a day's work.

The change

server/src/config/action-engine.js holds all nineteen, grouped by the question each answers — detection, noise, validation — rather than by the file that currently reads it, so moving a detector later does not move its threshold.

Consumers read through resolve() rather than importing constants. That is the seam the specification's resolution order arrives through:

System Default → Definition Default → Workspace Override

Only the first exists today. resolve(overrides) merges one group deep, so when per-definition or per-workspace tuning lands, no call site changes.

This moves thresholds, it does not retune them

Every value is carried over unchanged. A check compares all nineteen against their previous literals and confirms each still holds its old number; the existing 438-test suite passes untouched, including the detector tests that assert on these exact boundaries.

Deliberately left behind

  • Retry counts, page sizes, poll intervals, display limits. These have one right answer rather than a judgement worth tuning per workspace. Folding them in would bury the numbers that matter among the ones that do not.
  • The GSC suggestion thresholds. That subsystem produces prompt suggestions, not signals. Pulling it in would widen this past the Action Engine, and its thresholds answer to a different product question.

Tests

Seven, on the config itself:

  • the defaults are frozen, groups included — a threshold anything can reach in and change at runtime is a shared mutable global wearing a config file's name
  • every value is a finite number
  • every ratio sits between 0 and 1 — a ratio above 1 reads as a percentage someone forgot to divide, and would silently disable the guard it belongs to
  • resolve() with no overrides returns the defaults themselves
  • an override changes one threshold and leaves its neighbours and other groups whole
  • a resolved set cannot write back to the defaults

Related issue

Phase 2.5 of #818. Its exit condition — changing a detection threshold means editing configuration, not a detector — is what this implements.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

Database

None.

How to test

cd server && yarn test   # 445 passing, 7 of them new
yarn lint && yarn format:check

Behaviour is unchanged by construction, so the meaningful check is that nothing moved: the detector suites pass against the same boundaries they asserted before. To confirm the surface works, change detection.visibilityDropPoints in the config and watch the drop detector's threshold move with it — one file, no hunting.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/) — 0 errors
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

🤖 Generated with Claude Code

https://claude.ai/code/session_01SQ2H6mSd9JDpmqonk2VWBj

Phase 2.5 of #818.

Nineteen numbers decided what the engine counts as worth reporting, and they
lived in the five files that happened to read them: how far visibility must
fall before it is a drop, how many prompts make an uncited-mentions pattern
more than an anecdote, how long a kind rests after a cycle closes, how much a
metric must move before a measurement is a result. Survivable at eleven
detectors. Phase 3 brings roughly forty, and hunting through detectors to
retune the engine does not scale to that.

They now live in config/action-engine.js, grouped by the question each answers
rather than by the file that reads it — so moving a detector later does not
move its threshold. Consumers read through `resolve()` rather than importing
constants, which is the seam the specification's definition-level and
workspace-level overrides arrive through: when they do, no call site changes.

Every value is carried over unchanged; a check confirms all nineteen still
hold their previous numbers, and the existing suite passes untouched. This
moves thresholds, it does not retune them.

Deliberately left behind: retry counts, page sizes, poll intervals, display
limits. Those have one right answer rather than a judgement worth tuning, and
folding them in would bury the numbers that matter. The GSC suggestion
thresholds stay put too — that subsystem produces prompt suggestions, not
signals, and pulling it in would widen this past the engine.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01SQ2H6mSd9JDpmqonk2VWBj
@gkhngyk
gkhngyk merged commit 3e6a783 into main Sep 17, 2026
6 checks passed
@gkhngyk
gkhngyk deleted the refactor/engine-thresholds branch September 17, 2026 07:51
@gkhngyk gkhngyk mentioned this pull request Sep 18, 2026
33 of 37 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant