Skip to content

[Core] Add awards to OpportunityDetails #1221

Closed

Description

@laurabelinfante

Summary

An award points at its opportunity through AwardBase.opportunity?: OppRef, but nothing points the other way. A consumer viewing an opportunity cannot see what it produced without searching awards by opportunityId. Billy's v0.5 candidate list adds an awards property to OpportunityDetails, the detail-only shape that already carries competitions?: CompetitionBase[].

Add optional awards?: <selected element>[] to OpportunityDetails in Core v0.5. The element shape is an explicit decision owned by this ticket: compare AwdRef[] with AwardBase[] before implementation and record the consumer rationale. The decision must address payload size, duplication, canonical-source expectations, and what a consumer may assume about dereferencing a reference when award routes are optional.

Moved from v0.6 to v0.5 in milestone planning on Sept 22, since it touches the same opportunity model as the other v0.5 opportunity changes.

Acceptance criteria

  • Before implementation, AwdRef[] and AwardBase[] are compared and the selected type plus consumer rationale is recorded, covering payload size, duplication, canonical source, the competitions precedent, and optional-route dereferencing expectations
  • Optional OpportunityDetails.awards?: <selected element>[] exists with @Versioning.added(v0_5), and opportunity model documentation describes its guarantees
  • Version tests prove the field is absent from earlier Core artifacts and present only in v0.5 artifacts
  • Website opportunity-detail fixtures include related awards; every entry resolves to a real award fixture whose opportunity.id points back, and copied reference/base fields match the canonical award fixture
  • Validation pass: before merging to the hold branch, draft the new models in Zod and Pydantic to catch design issues early (not merged, just a check)

Activity

  1. added
    coreIssues related to @common-grants/core library
    sdkIssue or PR related to our SDKs
    featureNew capability. Belongs on a hold branch.
    on Sep 23, 2026
  2. karinamzalez commented on Oct 7, 2026

    @karinamzalez
    Collaborator

    Element shape for OpportunityDetails.awards: AwdRef[] (#1221-T1)

    Recorded per the first acceptance criterion. The candidates were AwdRef[] (id, title, identifiers) and AwardBase[] (the full award record). The decision is AwdRef[].

    Payload size

    AwardBase requires description and status and carries funding, key dates, funders, recipient organizations, a parent reference, system metadata, and an opportunity: OppRef that would point back at the very record embedding it. An opportunity detail payload would grow with its award count, and every entry would repeat the opportunity's own reference. AwdRef is three fields, one of them optional.

    Duplication and canonical source

    The award routes own the award record. Embedding AwardBase creates a second copy of every award under its opportunity, which can drift from the canonical record and would need a rule for which copy wins. A reference has nothing to drift: it names the canonical record and leaves the data there.

    The competitions precedent

    OpportunityDetails.competitions embeds the full CompetitionBase only because no competition reference model exists. In practice the mock cannot populate nested competitions without violating the required forms field, and the conformance suite carries a pinned deviation admitting it (website/__tests__/lib/mock/conformance/fixtures-vs-schemas.spec.ts, "the nested-competitions deviation (pinned, not fixed)"). AwdRef entries validate cleanly, so awards does not repeat that outcome.

    Every other cross-record pointer in Core is a reference: AwardBase.opportunity is an OppRef, AwardBase.parent is an AwdRef, and funders and recipients are OrgRef collections. awards follows that pattern rather than the one exception.

    Dereferencing when award routes are optional

    A reference never promises that a route exists, and #1222 makes the award routes optional. The field's doc comment states the guarantee directly: GET /awards/{id} is the canonical record only where an implementation serves the award routes, and otherwise identifiers (for example the FAIN) is the key for joining the award in another system. A consumer must not assume a reference can be dereferenced through this API. This is the one real advantage AwardBase[] would have offered, and identifiers covers it without the cost above.

    The doc comment also fixes the field states: absent means the implementation does not publish this link for the record, and an empty array means the link is published and no awards are known. Entries carry no ordering guarantee. ADR 0024's null semantics are deliberately not claimed, because the field is AwdRef[] and the emitted schema rejects null; only application.tsp has migrated to nullable so far, and doing it here would be an unscoped partial migration.

    Reversibility

    If a later version wants summary fields inline (status, awarded amount), an AwdPreview extends AwdRef can replace the element type additively. Starting from AwardBase[] could not be narrowed later without a breaking change.

  3. karinamzalez commented on Oct 7, 2026

    @karinamzalez
    Collaborator

    Validation pass findings: Zod and Pydantic drafts (#1221-T4)

    Recorded per the fifth acceptance criterion. The pass ran on the scratch branch karina/1221-sdk-validation-pass (7444030), which is not merged and is not an ancestor of the #1255 branch. Nothing it adds is exported from a public index, so neither published package is affected.

    Conclusion: the Core field needs no change before merge. OpportunityDetails.awards fuzzes clean at 25 of 25 generated samples, and awards types cleanly while competitions stays loose, which answers the ticket's ordering question: typing competitions is not a prerequisite for shipping awards.

    The trap worth carrying into the v0.9 SDK work

    The intuitive hand-written identifier model requires registry and registry.code, but IdentifierT declares both optional (lib/core/lib/core/fields/identifier.tsp:28-34). An SDK written the intuitive way therefore rejects payloads the protocol accepts. It showed up as 14 of 25 generated samples for AwdIds. The draft was loosened to match the protocol, and the cases that reproduced it are kept as regression controls in lib/ts-sdk/__tests__/schemas/zod/awards.spec.ts.

    Other findings

    Coverage caveat

    The Zod half was executed. The Pydantic half is drafted but unexecuted: the machine has Python 3.9.6 and the package requires 3.11, the same wall #1220-T5 hit. Static review established the sealing finding above. The plan's T4 criterion allowed this explicitly, provided the half is flagged as unexecuted with the reason. The datamodel-codegen comparison is likewise not performed, under the same allowance.

    Files on the scratch branch

    • lib/ts-sdk/src/schemas/zod/awards.ts
    • lib/ts-sdk/__tests__/schemas/zod/awards.spec.ts
    • lib/python-sdk/common_grants_sdk/schemas/pydantic/models/awd_ref.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

coreIssues related to @common-grants/core libraryfeatureNew capability. Belongs on a hold branch.sdkIssue or PR related to our SDKs

Type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions