Skip to content

fix: require Metadata.CorrelationID at Intent construction - #192

Merged
rustyeddy merged 1 commit into
mainfrom
fix/191-intent-requires-correlation-id
Aug 25, 2026
Merged

fix: require Metadata.CorrelationID at Intent construction#192
rustyeddy merged 1 commit into
mainfrom
fix/191-intent-requires-correlation-id

Conversation

@rustyeddy

Copy link
Copy Markdown
Owner

What changed

order.NewIntent now requires Metadata.CorrelationID to be
non-zero, in addition to the existing Metadata.EventID requirement.

Why

Rusty's post-merge review comment on #191 found a real gap: Intent
is documented — both in its own field comment and NewIntent's doc
comment — as the anchor for the intent -> proposal -> risk decision -> request/order -> fill correlation chain, but the constructor only
enforced a non-zero EventID, not CorrelationID. A caller could
therefore construct a valid Intent with no correlation identifier,
leaving every later stage with nothing to correlate back to. Since
Intent is the first/anchor stage of that chain, nothing downstream
can retroactively assign a CorrelationID an intent never had — the
fix is to require it now, matching what the docs already claimed.

Test plan

  • go build ./..., go vet ./..., gofmt -l . all clean
  • go test ./... -race passes across the whole repository
  • New regression test TestNewIntentRejectsZeroMetadataCorrelationID
  • order package coverage remains 100.0%

Addresses feedback on #191

🤖 Generated with Claude Code

https://claude.ai/code/session_014JmhCNQ3Nh3veVXzZifMa9

…ow-up)

Rusty's post-merge review on #191 found a real gap: Intent is
documented (both in its own field comment and NewIntent's doc comment)
as the anchor for the intent -> proposal -> risk decision ->
request/order -> fill correlation chain, but NewIntent only required
Metadata.EventID to be non-zero, not Metadata.CorrelationID. A caller
could construct a valid Intent with no correlation identifier, leaving
every later stage with nothing to correlate back to -- exactly the gap
the docs claimed didn't exist.

Since Intent is the first/anchor stage, nothing later can retroactively
assign a CorrelationID an intent never had. NewIntent now requires
Metadata.CorrelationID non-zero, matching the documented contract,
with a regression test (TestNewIntentRejectsZeroMetadataCorrelationID).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014JmhCNQ3Nh3veVXzZifMa9
Copilot AI lite review requested due to automatic review settings August 25, 2026 20:02

Copilot AI 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.

🟢 Approval recommended

The change is narrowly scoped, matches documented intent invariants, and is covered by an added targeted regression test.

Pull request overview

This PR tightens order.NewIntent validation to match existing documentation by requiring Metadata.CorrelationID (in addition to Metadata.EventID) so the intent → downstream order lifecycle correlation chain is guaranteed to be anchored at intent creation.

Changes:

  • Require non-zero Metadata.CorrelationID in order.NewIntent validation.
  • Update intent tests to supply a correlation ID in fixtures and add a regression test for rejecting zero correlation IDs.
  • Add a test helper to generate id.CorrelationID values.
File summaries
File Description
order/intent.go Enforces non-zero Metadata.CorrelationID and updates constructor documentation accordingly.
order/intent_test.go Updates fixtures for the new requirement and adds a regression test for missing correlation IDs.
order/helpers_test.go Adds mustCorrelationID helper for generating correlation IDs in tests.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@rustyeddy rustyeddy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Reviewed latest head. This is the right narrow fix for the #191 correlation-gap finding: NewIntent now requires both Metadata.EventID and Metadata.CorrelationID, the constructor docs match the invariant, the shared fixture supplies a real correlation ID, and there is a focused regression test proving a zero CorrelationID is rejected. I don't see a new blocker in these changes. Looks ready to merge.

@rustyeddy
rustyeddy merged commit 8dd7e0b into main Aug 25, 2026
2 checks passed
@rustyeddy
rustyeddy deleted the fix/191-intent-requires-correlation-id branch August 25, 2026 20:06
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