Skip to content

feat: flatten 7 discovery builders to kwargs; delete 10 *Input wrappers + convert 6 nested types to TypedDicts - #38

Merged
vvillait88 merged 1 commit into
mainfrom
feat/303f-discovery-flatten
May 14, 2026
Merged

feat: flatten 7 discovery builders to kwargs; delete 10 *Input wrappers + convert 6 nested types to TypedDicts#38
vvillait88 merged 1 commit into
mainfrom
feat/303f-discovery-flatten

Conversation

@vvillait88

Copy link
Copy Markdown
Contributor

Summary

Biggest single PR in the train. Flattens the 7 discovery builders and replaces their wrapper-constructor pattern with plain kwargs. Nested types (endpoint / link / identity / shipping rows) convert from @dataclass to TypedDict so callers stop wrapping rows that were really just dict-shaped data.

Before After
build_well_known_x402(BuildWellKnownX402Input(resources=...)) build_well_known_x402(*, resources)
build_well_known_mpp(WellKnownMppInput(...)) build_well_known_mpp(*, name, url, endpoints, purchase, ...)
build_bazaar_discovery_payload(BazaarDiscoveryConfig(...)) build_bazaar_discovery_payload(*, body_type, input, output, extra)
build_discovery_probe_response(DiscoveryProbeOptions(...)) build_discovery_probe_response(*, realm, sample_rail, ...)
llms_txt_identity_section(LlmsTxtIdentitySectionInput(...)) llms_txt_identity_section(*, agentscore=False, compliance=None)
llms_txt_payment_section(LlmsTxtPaymentSectionInput(...)) llms_txt_payment_section(*, rails, app_url, verbose=False, ...)
build_llms_txt(BuildLlmsTxtInput(...)) build_llms_txt(*, merchant_name, sections=None, ...)
x_payment_info_extension(XPaymentInfoInput(price=..., protocols=...)) x_payment_info_extension(*, price, protocols)
agentscore_openapi_snippets(BuildAgentScoreOpenApiSnippetsInput(...)) agentscore_openapi_snippets(*, security=True, denials=True, payment_required=True)
build_skill_md(BuildSkillMdInput(...)) build_skill_md(*, name, description, homepage, …) — 23 flat kwargs

Internal note: _SkillCtx

build_skill_md has 11 private _section(input) helpers. To keep their signatures unchanged without ballooning the diff, the public surface flattens to kwargs but the function internally constructs a frozen _SkillCtx dataclass that gets passed to each helper. Public API is fully flat; private helpers stay focused.

Deleted from exports

BuildWellKnownX402Input, WellKnownMppInput, BazaarDiscoveryConfig, DiscoveryProbeOptions, LlmsTxtIdentitySectionInput, LlmsTxtPaymentSectionInput, BuildLlmsTxtInput, XPaymentInfoInput, BuildAgentScoreOpenApiSnippetsInput, BuildSkillMdInput.

Nested types converted to TypedDicts

LlmsTxtSection, WellKnownX402Resource, SkillMdEndpoint, SkillMdLink, SkillMdIdentityRequirements, SkillMdShippingPolicy. Consumers continue calling them by name with kwargs (TypedDict supports the same call shape), but they no longer need an extra import + constructor.

Kept

PaymentMethodConfig (real nested compliance/x402 shape), X402SampleProbe, XPaymentInfoFixedPrice, XPaymentInfoDynamicPrice, XPaymentInfoMpp, DiscoveryProbeResponse.

Test plan

  • uv run pytest tests/ — 1033 passed / 3 skipped, 95.02% coverage
  • uv run ty check agentscore_commerce/ — clean
  • uv run ruff check . && uv run ruff format . — clean
  • uv run vulture agentscore_commerce/ --min-confidence 80 — only known false positives remain

Flattens the 7 discovery builders:

- build_well_known_x402(BuildWellKnownX402Input(resources=[WellKnownX402Resource(...)]))
    → build_well_known_x402(*, resources: list[WellKnownX402Resource])
    (WellKnownX402Resource is now a TypedDict)
- build_well_known_mpp(WellKnownMppInput(...))
    → build_well_known_mpp(*, name, url, endpoints, purchase, ...)
    (PaymentMethodConfig stays — carries nested compliance/x402 shape)
- build_bazaar_discovery_payload(BazaarDiscoveryConfig(...))
    → build_bazaar_discovery_payload(*, body_type=None, input=None, output=None, extra=None)
- build_discovery_probe_response(DiscoveryProbeOptions(...))
    → build_discovery_probe_response(*, realm, sample_rail, sample_amount_usd, sample_recipient, ...)
- llms_txt_identity_section(LlmsTxtIdentitySectionInput(...))
    → llms_txt_identity_section(*, agentscore=False, compliance=None)
- llms_txt_payment_section(LlmsTxtPaymentSectionInput(...))
    → llms_txt_payment_section(*, rails, app_url, verbose=False, ...)
- build_llms_txt(BuildLlmsTxtInput(...))
    → build_llms_txt(*, merchant_name, sections=None, tagline=None, agentscore_identity=None, payment=None)
    (LlmsTxtSection becomes a TypedDict; agentscore_identity/payment are dict forwards to the section helpers)
- x_payment_info_extension(XPaymentInfoInput(price=..., protocols=...))
    → x_payment_info_extension(*, price, protocols)
- agentscore_openapi_snippets(BuildAgentScoreOpenApiSnippetsInput(...))
    → agentscore_openapi_snippets(*, security=True, denials=True, payment_required=True)
- build_skill_md(BuildSkillMdInput(...))
    → build_skill_md(*, name, description, homepage, ...) — 23 flat kwargs
    (Internal _SkillCtx aggregates so 11 private section helpers stay typed; nested
    SkillMdEndpoint/SkillMdLink/SkillMdIdentityRequirements/SkillMdShippingPolicy
    become TypedDicts so callers stop double-wrapping.)

Deleted from exports: BuildWellKnownX402Input, WellKnownMppInput,
BazaarDiscoveryConfig, DiscoveryProbeOptions, LlmsTxtIdentitySectionInput,
LlmsTxtPaymentSectionInput, BuildLlmsTxtInput, XPaymentInfoInput,
BuildAgentScoreOpenApiSnippetsInput, BuildSkillMdInput.

Kept (data shapes consumers construct): PaymentMethodConfig, X402SampleProbe,
XPaymentInfoFixedPrice, XPaymentInfoDynamicPrice, XPaymentInfoMpp,
DiscoveryProbeResponse, LlmsTxtSection (TypedDict),
SkillMdEndpoint/SkillMdLink/SkillMdIdentityRequirements/SkillMdShippingPolicy
(TypedDicts), WellKnownX402Resource (TypedDict).

Tests: 1033 passed / 3 skipped, 95.02% coverage. ty + ruff + vulture
(modulo known false positives) clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vvillait88
vvillait88 merged commit 4dec77f into main May 14, 2026
7 checks passed
@vvillait88
vvillait88 deleted the feat/303f-discovery-flatten branch May 14, 2026 18:59
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.

1 participant