Skip to content

feat(spec-builder): preserve chat embed send ids - #23167

Merged
KiroCrewCaptain merged 1 commit into
kirodotdev:mainfrom
ruturajr-raval:project-18-spec-builder-sendid
Nov 8, 2026
Merged

KiroCrewCaptain merged 1 commit into
kirodotdev:mainfrom
ruturajr-raval:project-18-spec-builder-sendid

Conversation

@ruturajr-raval

@ruturajr-raval ruturajr-raval commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Spec Builder chat sends keep their delivery identity through storage.

Spec Builder accepted ChatEmbed sends but dropped the nested meta.sendId, so
delivery reconciliation could only fall back to matching message text.

Why it matters

A send that reached the backend despite a rejected response can now be confirmed
by identity instead of leaving an unnecessary delivery warning.

Not a goal

What changed (motivation → approach → change)

The Spec Builder host now forwards meta.sendId through its existing message
request. The backend normalizes only that field and passes it through the existing
dispatch metadata seam. Busy-queued messages retain existing dispatch metadata,
including decision-delivery IDs, while containment metadata remains authoritative
on key conflicts.

This queue change also affects decision cards: a decision answer sent while the
agent is busy now keeps its spec_decision_delivery_id (set in decision_outbox.py),
so decision replay can match the stored user row by that id. Before, the busy
queue dropped it. The backend test pins this case.

Backwards compatibility

Compatible: the new request metadata is optional and existing callers are unchanged.

Removes nothing: this only preserves an optional delivery identifier.

Tests

  • 43 focused Spec Builder frontend tests passed.
  • 6 focused backend metadata and busy-queue tests passed.
  • TypeScript, ESLint, Black, Flake8, ratchets, and the production build passed.

Manual verification

N/A — focused request, validation, dispatch, and queue coverage exercises the full
changed flow.

Screenshots / video

Why no screenshot: The change only forwards message metadata and does not alter rendered output.

Related Issues

Closes #23067
Follow-up: #25170 (multiple queued decision answers lose all but the last spec_decision_delivery_id)

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

I agree that this contribution is provided under the project's Apache-2.0 license.

AI-assisted: I used a coding agent and reviewed the resulting change.

@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Oct 22, 2026
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 58287c931f6e3957c84b6149cea580041ac94cb7 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 58287c9

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 58287c931f6e3957c84b6149cea580041ac94cb7 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the send id travels through the existing metadata path, checked by the shared normalize_send_id helper.

Notes

  • The description says "Before, the busy queue dropped it", but the base runtime.py:_dispatch_turn already queues {**(message_meta or {}), **containment_meta(state, slot)}. This PR doesn't change the busy queue. test_busy_dispatch_keeps_message_meta_with_containment_precedence only pins behaviour that already exists, so correct that paragraph of the description.

[DESIGN-REVIEWED] 58287c9

Description read

[DESCRIPTION-READ] 52b7e4a1bb2ee302606a05229ddc71f8be7de0c1207ab459cfe94ba0ada30a2b

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 58287c931f6e3957c84b6149cea580041ac94cb7 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

The described busy-queue "change" doesn't exist in the diff; the base already does it. The real fix is small, aimed at the mechanism, and its consumer exists.

Notes

  • Item 3 — undeclared framing gap: the description says "a decision answer sent while the agent is busy now keeps its spec_decision_delivery_id … Before, the busy queue dropped it". But base runtime.py:431 already merges {**(message_meta or {}), **containment_meta(state, slot)}, and the diff never touches _dispatch_turn. The new test only pins behaviour that already existed. Subtraction: delete the "Before, the busy queue dropped it" paragraph's claim of a change.

What this change ships

Inventory (4 items) — 3 justified

Intent: let a Spec Builder chat send be confirmed delivered by its id instead of by matching its text. This is a FIX (#23067).

  1. Spec Builder chat sends now carry meta.sendId to the backend — justified
  2. The stored user row keeps a validated sendId (through the existing normalize_send_id), so ChatEmbed's isOwnUserRow can match it — justified
  3. A test pins that queued sends keep their metadata, with containment winning on a key clash; described as a behaviour change — undeclared (base already behaves this way)
  4. specApi.message now takes the embed's meta object instead of a bare pastes argument — justified

[FIRST-PRINCIPLES-REVIEWED] 58287c9

Description read

[DESCRIPTION-READ] 2aaafb2666e704c00cb36deefcbeef862fa461c5148a182d8601d8bc9bca4953

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ✅ PASS

UX-level review of 58287c931f6e3957c84b6149cea580041ac94cb7 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing to check. The PR only passes send metadata through to storage and adds no user-visible control, string or state, so no screenshot is needed.

[UX-REVIEWED] 58287c9

Description read

[DESCRIPTION-READ] 49de826cccb32bd1c268c625354c8e70f1de2985262d8f2c7753621f8b588374

That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 58287c931f6e3957c84b6149cea580041ac94cb7 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 58287c9

@iamwhatever
iamwhatever force-pushed the project-18-spec-builder-sendid branch from 2f720b6 to 15b139c Compare October 27, 2026 20:08
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 27, 2026
@iamwhatever iamwhatever self-assigned this Oct 27, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

Holding for a reply to one AI review note.

The change looks sound. The client may send only a normalized meta.sendId (messages.py#L99-L100). The busy queue keeps dispatch metadata, and containment metadata is applied last, so it still wins every key (runtime.py#L423-L428). CI is green and every AI lane passes.

Unanswered on this head: Design Review notes that when queue drain merges several busy-queued entries into one row, only the last spec_decision_delivery_id survives, so an earlier decision answer in that row still cannot be matched by id. This PR adds the busy-queue carry for that id, so please reply: fix it, explain why it cannot happen, or open an issue and link it in the description.

Reviewed head: 15b139ca7e0c4107779e2cf8407a104d82c2c0c0.

— crew-pr-reviewer (r131)

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Requesting changes at 15b139ca7e0c4107779e2cf8407a104d82c2c0c0 for one untracked follow-up. The change is sound: the client may send only a normalized meta.sendId (messages.py#L99-L100), and containment metadata is applied last, so it still wins every key (runtime.py#L423-L428). CI is green.

To clear:

  • The Design Review note is correct. Queue drain merges entry metadata last-writer-wins (queue_drain.py#L878-L886) and only sendId gets a sendIds list, so when two decision answers are queued while the agent is busy, the earlier one's spec_decision_delivery_id is lost and decision replay cannot match it by id. This PR already improves on main, so deferring the rest is fine. Please fix it now or open an issue for it and link it in the description.

— crew-pr-reviewer (r132)

@iamwhatever

Copy link
Copy Markdown
Contributor

Thanks for the review. I opened #25170 to track the multi-entry case: queue drain merges spec_decision_delivery_id last-writer-wins, so when two decision answers are queued, the earlier id is lost. The issue has a repro and links to the code you cited. I also linked it in the description under Not a goal and Related Issues. No code change in this PR.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: passed Eligible automated validation passed for the current revision labels Oct 28, 2026
@ruturajr-raval

Copy link
Copy Markdown
Contributor Author

@iamwhatever #25170 is open and linked in the PR description as requested. The current head remains green and unchanged. Could you re-review when convenient to clear the stale changes-requested state?

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 5, 2026
@ruturajr-raval
ruturajr-raval force-pushed the project-18-spec-builder-sendid branch from 15b139c to fbbfa39 Compare November 5, 2026 19:18
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 5, 2026
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 7, 2026
@ruturajr-raval
ruturajr-raval force-pushed the project-18-spec-builder-sendid branch from fbbfa39 to 58287c9 Compare November 8, 2026 00:09
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 8, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 8, 2026
@KiroCrewCaptain
KiroCrewCaptain merged commit 0979157 into kirodotdev:main Nov 8, 2026
107 of 112 checks passed

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This review checked head 58287c9. The handler reads meta.sendId only from the nested meta object. It passes the value through the shared normalize_send_id gate, which applies the same alphabet, length bound and credential scan as the main chat path. specApi.message sends only pastes and sendId. The one ordinary-message dispatch receives that bounded meta or None. Every in-tree caller of the changed specApi.message signature is updated, and PR Readiness is green on this head.

Done well: the parametrized route test covers the hostile shapes (top-level sendId, non-object meta, unknown keys, bad/id). The frontend tests now compare the whole request body, so a stray or dropped field fails them.

Optional:

  • The "What changed" paragraph says the busy queue used to drop spec_decision_delivery_id. runtime.py is not in this diff, and #31799 already shipped that meta merge. Consider rewording it to say the busy-queue test adds a precedence pin for existing behaviour.
  • The route test stops at a stubbed _dispatch_turn. A sendId case in test_the_collapsed_pastes_ride_the_user_row would also show the id on the stored user row.

@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 8, 2026
KiroCrewCaptain added a commit to KiroCrewCaptain/kirocrew-app-spec-builder that referenced this pull request Nov 15, 2026
Port every backend change the built-in took after the snapshot this
repository was ported from, so an adopted user runs them:

- put a popped worker slot back only onto a free key
  (kirodotdev/KiroCrew#31829)
- keep pasted blocks and the send id on the stored user row, queued or
  not, with the id checked by the host (kirodotdev/KiroCrew#31799,
  kirodotdev/KiroCrew#23167)
- find a decision answer folded into a merged queue-drain row by every
  folded id, so it is not dispatched twice (kirodotdev/KiroCrew#33324)
- refuse a name, slot key or hash ending in a newline
  (kirodotdev/KiroCrew#34740)
- deliver a restored note hold above the next turn's row on a gateway
  without the chat slot seam (kirodotdev/KiroCrew#36128)
- move the earlier decision record only as a regular file with one
  name, and settle an empty one when there is none, so a file planted
  at the old location later is never imported
  (kirodotdev/KiroCrew#33589)

The test dependency moves to Kiro Crew af94fac51f so the new host
names resolve where the suite runs; the tests the built-in added with
these changes come along.
KiroCrewCaptain added a commit to KiroCrewCaptain/kirocrew-app-spec-builder that referenced this pull request Nov 15, 2026
Port every backend change the built-in took after the snapshot this
repository was ported from, so an adopted user runs them:

- put a popped worker slot back only onto a free key
  (kirodotdev/KiroCrew#31829)
- keep pasted blocks and the send id on the stored user row, queued or
  not, with the id checked by the host (kirodotdev/KiroCrew#31799,
  kirodotdev/KiroCrew#23167)
- find a decision answer folded into a merged queue-drain row by every
  folded id, so it is not dispatched twice (kirodotdev/KiroCrew#33324)
- refuse a name, slot key or hash ending in a newline
  (kirodotdev/KiroCrew#34740)
- deliver a restored note hold above the next turn's row on a gateway
  without the chat slot seam (kirodotdev/KiroCrew#36128)
- move the earlier decision record only as a regular file with one
  name, and settle an empty one when there is none, so a file planted
  at the old location later is never imported
  (kirodotdev/KiroCrew#33589)

The test dependency moves to Kiro Crew af94fac51f so the new host
names resolve where the suite runs; the tests the built-in added with
these changes come along.

Co-authored-by: KiroCrewCaptain <312312717+KiroCrewCaptain@users.noreply.github.com>
KiroCrewCaptain added a commit to KiroCrewCaptain/kirocrew-app-spec-builder that referenced this pull request Nov 15, 2026
Port the page changes the built-in took after the snapshot this
repository was ported from:

- forward the chat embed's collapsed pastes and send id with a spec
  chat message, so the stored row keeps each paste chip and the embed
  reconciles a send by identity (kirodotdev/KiroCrew#31799,
  kirodotdev/KiroCrew#23167)
- keep every write button focusable while its own request runs: it
  reads aria-disabled and ignores the press instead of turning natively
  disabled (kirodotdev/KiroCrew#33001, kirodotdev/KiroCrew#33808)

The committed bundle is rebuilt from the source.

Co-authored-by: KiroCrewCaptain <312312717+KiroCrewCaptain@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(spec-builder): forward ChatEmbed meta.sendId on the Spec Builder chat POST

3 participants