Skip to content

fix(journeys): assign-bot effect re-read parses wrong CRM envelope key → false negative (EVO-1930)#104

Merged
dpaes merged 1 commit into
developfrom
danilocarneiro/evo-1930-jornadas-assign-bot-falha-na-re-leitura-do-efeito-valida
Jun 25, 2026
Merged

fix(journeys): assign-bot effect re-read parses wrong CRM envelope key → false negative (EVO-1930)#104
dpaes merged 1 commit into
developfrom
danilocarneiro/evo-1930-jornadas-assign-bot-falha-na-re-leitura-do-efeito-valida

Conversation

@daniloleonecarneiro

Copy link
Copy Markdown

Summary

Follow-up to the EVO-1919 effect-verification hardening. After EVO-1900/D11 made the assign-bot binding actually persist (agent_bot_inboxes gets a row), the EVO-1919 re-read started reporting a false negative on the assign-bot node: ... bot binding does not reflect ... after re-read, failing the node even though the binding was created.

Root cause: the re-read already targeted the correct inbox resource (getInboxBotGET /inboxes/:id/agent_bot), but the confirm predicate parsed the wrong level of the CRM envelope. The CRM (AgentBotSerializer) returns, when a binding exists:

{ "success": true, "data": { "agent_bot": { "id": ... }, "configuration": { ... } } }

and data: null when there is no binding. The predicate read .id off the { agent_bot, configuration } wrapper (which has no id), so even a present binding yielded boundBotId === null → reported as "not persisted".

The EVO-1919 unit test masked this because it mocked a divergent shape ({ data: { data: bot } }) that does not match production.

Fix

  • assign-bot.node.ts: unwrap the bot under data.agent_bot (tolerating a flattened shape) before reading id; compare string-coerced ids. Re-read still hits the inbox binding, never the conversation.
  • assign-bot.node.spec.ts: mocks now mirror the real CRM envelope ({ success, data: { agent_bot, configuration } | null }). Added EVO-1930 regressions: bound bot confirms success (no false negative), numeric-id coercion, and a different-bound-bot legitimately fails.

(This branch also carries the EVO-1919 verifyEffect helper / journeyVerifyEffect config because those are not yet on develop; they are byte-identical to EVO-1919 and reconcile cleanly on the integration line.)

Test plan

  • npx tsc -b — clean.
  • npx jest assign-bot — 8/8 pass (incl. new EVO-1930 cases).
  • npx jest crm-client src/modules/temporal/activities/nodes — 135 pass; 3 failures are the pre-existing EVOAI_CRM_API_TOKEN ctor failures (reproduce on develop), none new.

Notas

  • AC met: binding present → node SUCCESS; binding absent / different bot → legitimate failure; re-read confirms agent_bot_inboxes of the correct inbox.

…lope key so assign-bot stops false-failing (EVO-1930)

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @daniloleonecarneiro, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@daniloleonecarneiro daniloleonecarneiro self-assigned this Jun 25, 2026

@dpaes dpaes left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved — deep adversarial review (card + authoritative diff + real code): acceptance criteria met, no blocking findings. Merge intentionally held to land in the coordinated dependency-order pass. Branch is clean vs develop.

@dpaes dpaes merged commit d60c720 into develop Jun 25, 2026
3 checks passed
@dpaes dpaes deleted the danilocarneiro/evo-1930-jornadas-assign-bot-falha-na-re-leitura-do-efeito-valida branch June 25, 2026 21:21
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.

2 participants