feat(task-board): the import reply says what happened to each item - #7555
Open
viktormarinho wants to merge 1 commit into
Open
viktormarinho wants to merge 1 commit into
viktormarinho wants to merge 1 commit into
Conversation
The reports engine needs to know which card each pushed finding became,
to link findings to tasks and to skip findings that already have a card.
The import reply only carried counts.
Add `items` to the reply: one `{ index, outcome, id, key_seq }` entry per
request item, in request order. `outcome` is `created`, `updated`,
`semantic_match`, `dismissed` or `quota_blocked`, and `id`/`key_seq` name
the card the item created, refreshed, matched or was blocked by. The
dismissed lookups become maps to the dismissed card, built from the rows
the transaction already reads. The counts are now derived from `items`
and keep their meaning. A replayed run_id still omits `items`.
4 tasks
This branch has not been deployed
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.
What is this contribution about?
The reports engine pushes Deco Score findings to
POST /api/:org/internal/task-board/import. The reply only had counts, so the engine could not tell which card each finding became. It needs that for two things. The owner widget will link each finding to its task, and the daily recompute will skip findings that already have a card.The reply now has
items, with one entry per request item in request order:Each branch of the import loop reports this:
outcomeid/key_seqcreatedexternalKeymatches an open cardupdatedupdatedupdatedsemantic_matchsemantic_matchdismissedquota_blockedChoices worth reviewing:
semantic_matchfor both owners. The engine only needs the card id for both of its uses. Whether the card's text was refreshed depends on who owns it, and the engine does nothing different either way. A flag can be added later without breaking callers.outcomeis the most specific label, and the counts keep their meaning. Everysemantic_matchis still counted inupdatedand everyquota_blockedincreated, as before. The counts are now derived fromitems, so the two cannot disagree.idandkey_seqare always present. Every current outcome names a card.run_idhas noitems. It still replies{ created: 0, updated: 0, delegated: 0, deduped: true }. That request wrote nothing and the route does not re-read what the original run did, so the per-item result is unknown.itemsarray is still a 400. The schema requires at least one item, so no reply carriesitems: [].{ id, key_seq }. They are built from the two queries the transaction already runs, which now also selectkey_seq. If several dismissed cards share a key or normalized title, the reply names one of them. Any of them blocks the item.Every existing field keeps its meaning, so the change is additive. The current engine casts the JSON and reads only the counts, so it keeps working. A follow-up PR in the reports repository will store these ids to link findings to tasks.
No shared type or schema describes this reply, and
apps/docsdoes not document the import contract. The module docstring intask-board-import.tsis where the contract lives, and it now describesitems.How did you verify your code works?
bun test apps/api/src/api/routes/task-board-import.integration.test.ts apps/api/src/api/routes/task-board-import.test.tsagainst a local Postgres: 33 pass.[created X, updated X], and one card holds the later description.dismissedwith the dismissed card's id, and the next item keeps index 1.duplicate_reportedactivity.setGlobalSettingsturns on quota enforcement with zero free executions. The delegated item reportsquota_blockedwith its card, and the card ends up unassigned.items.itemsas well. They cover created, delegated (reported ascreated), keyed refresh, keyed dismissal and its restore, the exact-title refresh, and a done card's regression (the reply names the new card, not the done one). They also cover a dismissal in another org (that org's reply names its own new card) and therun_idreplay (noitems).bun run --cwd=apps/api check(tsc) is clean.bun run verify: fmt, lint and knip pass. The unit stage failed on the first run while the machine was at a load average of about 40 on 10 cores. The errors wereCannot find modulefor modules that exist, plus 5 to 20 second timeouts. None of those files import the import route. Rerunning the 46 affected files passed (510 tests). A second fullbun run testgave 9630 pass and 1 fail,NDJSONLogExporter > should flush via timer interval, a 150 ms timer test that passes on its own.Screenshots/Demonstration
No UI change.
How to Test
bun run devwithVAULT_SERVICE_TOKENset.created: 1,updated: 1, anditemswith{ index: 0, outcome: "created" }and{ index: 1, outcome: "updated" }carrying the sameidandkey_seq.dismissed: 2, and both entries asdismissedwith the deleted card'sid.DATABASE_URLpointing at a disposable Postgres.Migration Notes
None.
Review Checklist
Summary by cubic
Makes the task-board import reply say what happened to each pushed item, so the reports engine can link findings to the cards they became.
items: one{ index, outcome, id, key_seq }entry per request item in request order, naming the card the item created, refreshed, matched, or was blocked by.outcomeis the most specific label —created,updated,semantic_match,dismissed, orquota_blocked— and the counts keep their old meaning, sosemantic_matchitems still count asupdatedandquota_blockedascreated.run_idstill omitsitems, and empty batches still return 400.Written for commit 041bfb8. Summary will update on new commits.