Repository navigation
feat(action-center): give a finding somewhere to wait - #831
Merged
Merged
Conversation
One active action per definition is the right rule — nobody should be handed the same piece of work twice — but it left a second finding nowhere to go. Phase 1 stopped such a finding corrupting the open action's scope; it did not stop it being lost. A condition detected while the slot was busy was linked as evidence and then forgotten, because the next cycle is built from whatever happens to be open on the night the slot frees up. Anything that resolved in between was never worked on at all. The generator now answers two questions instead of one. What did we find writes a candidate for every definition that matched, every night, whether or not anything can be done about it. What should we act on promotes from that queue, subject to the slot, the rest window, eligibility and the daily cap. None of those loses the finding any more; each one just leaves it waiting. A candidate covers exactly the matched signals no action has claimed, and is recomputed each night rather than accumulated: a signal that resolves leaves the queue by itself, and one the active action took as evidence is already accounted for. The queue therefore cannot drift out of step with what is true tonight. Its lifecycle mirrors a signal's — waiting while the evidence is live, stale when it is gone, back again if the condition returns. Priority is scored rather than sorted, because a queue needs one thing a sort does not: age. The weights are set so two rules hold, and the arithmetic is what enforces them: - nothing starves. A full two-week wait is worth 42 and the gap between low and medium is 35, so a low-impact finding that waited out the cap outranks a medium one detected tonight with comparable evidence. - a high-impact finding is never outranked. It sits at 200, out of reach of any wait and any evidence (122 at most). A queue that lets forty pages of low-impact opportunity outrank a visibility collapse is not a priority order, it is a vote. The scorer is defensive about its inputs on purpose: a missing signal count produced NaN, which sorts as "no opinion" and silently degraded the whole queue to alphabetical order. It was caught by a test written for exactly that shape, having already happened once while this was being built. No UI yet. The queue is visible in the nightly log line and in the table; showing a brand what is waiting is a separate change. Refs #818 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01SQ2H6mSd9JDpmqonk2VWBj
33 of 37 tasks
6 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 6 of #818. Findings the engine cannot act on yet stop disappearing.
One active action per definition is the right rule — nobody should be handed
the same piece of work twice — but it left a second finding nowhere to go.
Phase 1 stopped such a finding corrupting the open action's scope; it did not
stop it being lost. A condition detected while the slot was busy was linked
as evidence and then forgotten, because the next cycle is built from whatever
happens to be open on the night the slot frees up. Anything that resolved in
between was never worked on at all.
Two questions, answered separately
Three things still stop a candidate becoming an action —
ineligible,resting,capped— and none of them loses the finding any more. Each onejust leaves it waiting, and the waiting is what lifts it up the order.
The queue cannot drift
A candidate covers exactly the matched signals no action has claimed, and is
recomputed each night rather than accumulated. A signal that resolves leaves
the queue by itself; one the active action took as evidence is already
accounted for. Nothing has to be reconciled, because nothing is remembered
that could go stale — except
first_seen_at, which is the one thing thatcannot be recomputed and the only thing that matters for priority.
Its lifecycle mirrors a signal's: waiting while its evidence is live, stale
when it is gone, back again if the condition returns. Stale rather than
deleted — a condition that returns comes back with a fresh clock rather than
inheriting the patience of a finding that ended.
Priority is scored, not sorted
Because a queue needs one thing a sort does not: age. The weights are in
config/action-engine.jsand set so two rules hold, with the arithmetic asthe only thing enforcing them:
low and medium is 35, so a low-impact finding that waited out the cap
outranks a medium one detected tonight with comparable evidence.
of any wait and any amount of evidence (65 + 15 + 42 = 122 at most). A
queue that lets forty pages of low-impact opportunity outrank a visibility
collapse is not a priority order, it is a vote.
Both are asserted as tests rather than left as a comment, because the rules
live in four numbers that anyone may reasonably want to tune.
One bug worth naming
The scorer is defensive about its inputs on purpose. A missing signal count
produced
NaN, which sorts as "no opinion" — the comparator returnsNaN,the sort leaves the array alone, and the queue silently becomes alphabetical.
The engine still promotes something every night, just the wrong thing, so
nothing looks broken. It happened once while this was being built and is now
covered by a test written for that exact shape.
Not in this PR
A view of the queue. The waiting list is in
action_candidatesand inthe nightly
[actions] generatedline, which now reportsqueued,waitingand
stalealongsidecreated. Showing a brand what is waiting behind itsopen actions is a real feature and a separate change — and one worth doing,
given that an invisible queue repeats in miniature the failure #829 fixed.
Related issue
Refs #818
Type of change
feat— New featureHow to test
On the next nightly run,
action_candidatesgains a waiting row perdefinition that matched, and the log line reports what was queued, promoted
and staled. A brand with an active
recover_visibilityaction that detects anew visibility problem gets a waiting candidate rather than silence.
Migration
00089is applied to the hosted database.Checklist
feature/)yarn lintpassesyarn format:checkpasses🤖 Generated with Claude Code
https://claude.ai/code/session_01SQ2H6mSd9JDpmqonk2VWBj