Skip to content

feat(templates): add retail catalog QA, 32-way taxonomy, and merchandising policies - #26

Merged
ghchinoy merged 1 commit into
mainfrom
feat/prior-fusion-and-shortlist-routing
Nov 11, 2026
Merged

ghchinoy merged 1 commit into
mainfrom
feat/prior-fusion-and-shortlist-routing

Conversation

@jigyasujuneja

@jigyasujuneja jigyasujuneja commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Rebased onto main after #45 merged pkg/decisionindex shortlist routing, cosine prior normalization, and label-set plumbing. This PR now cleanly delivers the three production retail policy packs under templates/retail/, companion Studio/regression fixtures, and gateway template discovery wiring:

  • templates/retail/retail_catalog_qa.json.tmpl (+ .examples.json): 4-slot SKU quality assurance policy (auto_publish_approved, title_spec_conflict, primary_defect_action, seo_readiness_score).
  • templates/retail/retail_deep_taxonomy.json.tmpl (+ .examples.json): 4-slot catalog classification policy using "labels": "az_aa" inside schema so the 32-option google_product_category slot resolves in a single /v1/structured pass alongside primary_material, price_tier, and gift_eligible.
  • templates/retail/retail_merchandising_compliance.json.tmpl (+ .examples.json): 4-slot storefront readiness policy (brand_safety_compliant, primary_department, target_season, catalog_completeness_score).
  • Gateway & Discovery Wiring (cmd/serve.go): Adds "retail/" + base to resolveTemplateFile and "product" sample input to defaultSampleVars.

Verification

  • env -u DGEM_VERTEX_URL go test -race ./cmd/... ./pkg/... (TestAllShippedTemplatesRenderAndValidate, TestRetailTemplatesRender, TestResolveTemplateFileValidNames, and TestDiscoverTemplatesCatalogAndSampleVars all pass).
  • Verified live dgem decide rendered wire payloads for all three retail templates against deploy/cloudrun/server/structured_server.py parse_schema.

@jigyasujuneja
jigyasujuneja force-pushed the feat/prior-fusion-and-shortlist-routing branch from 51bf787 to f0cf8ce Compare November 4, 2026 00:36
@jigyasujuneja jigyasujuneja changed the title feat(decisionindex): port hesitation-gated prior fusion, cosine normalization, and shortlist routing feat(deploy,decisionindex): add GKE G4 GPU deployment guide, 52-label choice sets, and retail catalog templates Nov 4, 2026
@jigyasujuneja
jigyasujuneja force-pushed the feat/prior-fusion-and-shortlist-routing branch from f0cf8ce to 2ed90ee Compare November 4, 2026 15:49
@jigyasujuneja jigyasujuneja changed the title feat(deploy,decisionindex): add GKE G4 GPU deployment guide, 52-label choice sets, and retail catalog templates feat(templates): add retail catalog QA, deep taxonomy, and merchandising policy templates Nov 4, 2026
@jigyasujuneja
jigyasujuneja force-pushed the feat/prior-fusion-and-shortlist-routing branch from 2ed90ee to 99d8b76 Compare November 4, 2026 16:16
@ghchinoy

ghchinoy commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

Thanks for putting together the retail catalog templates! Before we can merge this and run live gateway template validation on them, a few schema and calibration items need to be fixed:

  1. retail_deep_taxonomy.json.tmpl fails with HTTP 422 on dgem decide and POST /api/decide:
    • google_product_category defines 32 options (cat_01..cat_32) without "labels": "az_aa" in "schema". Because dgem decide -t and POST /api/decide send the rendered schema directly to structured_server.py (parse_schema enforces <= 26 options under default "az" rather than routing through /v1/systemone brackets), running retail_deep_taxonomy from the CLI or Decision Studio returns HTTP 422 (at most 26 alternatives).
    • Please either set "labels": "az_aa" inside "schema" (noting it requires a label-set-enabled serving image) or keep shipped single-pass templates/ policies within <= 26 options.
  2. Top-level "layout" and "isolate" are dropped by ParseStructuredPayload:
    • When a .json.tmpl wraps "schema" and "state", pkg/template.ParseStructuredPayload unmarshals only those two fields and silently drops top-level "layout", "isolate", "name", "description", and "category". Please move "layout": "document_first" and "isolate": "auto" inside "schema".
  3. Canonical schema.questions keys and option names (AGENTS.md):
    • Please use "id", "instructions", and list-form "options": [{"name": "...", "description": "..."}] on schema.questions entries (matching structured_server.py), and use descriptive option "name" values rather than reusing "A".."F" and "A".."D" across multiple questions in the same template.
    • Update TestRetailTemplatesRender to also validate via ParseStructuredPayload (non-empty id and instructions, valid question types, unique IDs), and add "retail/" + base / "product" to resolveTemplateFile and defaultSampleVars in cmd/serve.go.
  4. Unfitted "temperature" blocks and "(Calibrated)" labels (AGENTS.md):
    • Per AGENTS.md, probabilities should only be labeled "calibrated" (and ship non-default "temperature" values) when fitted per policy on held-out labeled data. Please omit hardcoded "temperature" blocks and "(Calibrated)" from template titles unless backed by a held-out policy evaluation.

…ising policies

- Add canonical templates/retail/{retail_catalog_qa,retail_deep_taxonomy,retail_merchandising_compliance}.json.tmpl with schema-scoped layout/isolate, list-form options, string score levels, and labels="az_aa" on the 32-option google_product_category policy.
- Add companion .examples.json sidecars (typical with unambiguous=true and expected_answers, edge, minimal) for Studio and template regression tests.
- Wire "retail/"+base into resolveTemplateFile and "product" into defaultSampleVars in cmd/serve.go, with unit tests in cmd/template_resolve_test.go and pkg/template/mm_render_test.go.
@jigyasujuneja
jigyasujuneja force-pushed the feat/prior-fusion-and-shortlist-routing branch from 99d8b76 to 5ad06b8 Compare November 9, 2026 23:58
@jigyasujuneja jigyasujuneja changed the title feat(templates): add retail catalog QA, deep taxonomy, and merchandising policy templates feat(templates): add retail catalog QA, 32-way taxonomy, and merchandising policies Nov 9, 2026
@jigyasujuneja

Copy link
Copy Markdown
Collaborator Author

Thanks for the detailed review @ghchinoy! Rebased onto main (post-#45) so this PR now contains only the three retail policy packs, their .examples.json fixtures, and gateway discovery wiring, with every review item addressed:

  1. Canonical Template Contract: Removed top-level name/description/layout/isolate/temperature keys, moved "layout": "document_first" and "isolate": "auto" inside schema, switched questions from name/prompt + map options to canonical id/instructions + list options ({"name", "description"}), converted score levels to string arrays, replaced A/B/C/D placeholders with descriptive snake_case option names, and removed unfitted temperature / (Calibrated) labels.
  2. 32-Option Single-Pass Taxonomy (retail_deep_taxonomy.json.tmpl): Declared "labels": "az_aa" inside schema so the 32-option google_product_category slot passes both ValidateRenderedPayload and structured_server.parse_schema in a single pass without HTTP 422.
  3. Companion Fixtures & Gateway Wiring: Added .examples.json sidecars (typical with unambiguous: true + expected_answers, edge, and minimal) for all three retail templates, registered "retail/" + base in resolveTemplateFile and "product" in defaultSampleVars (cmd/serve.go), and added regression coverage in cmd/template_resolve_test.go and pkg/template/mm_render_test.go.

@ghchinoy
ghchinoy merged commit f4ff7b4 into main Nov 11, 2026
16 checks passed
@ghchinoy
ghchinoy deleted the feat/prior-fusion-and-shortlist-routing branch November 11, 2026 14:55
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