Fix compose-publish x-sam-routes overrides#1403
Fix compose-publish x-sam-routes overrides#1403simple-agent-manager[bot] wants to merge 4 commits into
Conversation
|
Merge is deferred for staging verification. What passed:
What is still missing:
Why it is blocked:
Do not merge until the exact staging callback/build path can be verified with workspace credentials or D1 write access. |
Merging this PR will improve performance by 11.37%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | getModelGroupsForAgent - all agents |
20.4 µs | 18.3 µs | +11.37% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing sam/x-sam-routes-explain-01kvx9 (fabb294) with main (8c6f3ba)
…ain-01kvx9 # Conflicts: # apps/api/src/routes/mcp/deployment-guide-tools.ts
|
|
Current rescue status after rebasing/merging main into this PR:\n\n- Branch conflict is resolved and pushed at |



Summary
x-sam-routesis an optional override layer on top of the existingports:default.ports:happy path while allowing explicit public routes withoutports:, allowingmode: privateto suppress a matchingports:route, deduplicating explicit+ports public routes, and rejecting invalid route entries before apply.ports:is the default route mechanism andx-sam-routesis only needed for explicit overrides.Validation
pnpm lintpnpm typecheckpnpm testpnpm build; focused API tests; shared compose-parser test/typecheck/lint; documentation sync grep.Staging Verification (REQUIRED for all code changes — merge-blocking)
All checkboxes below are mandatory for any PR that changes runtime code (
.ts,.tsx,.go, etc.). WriteN/A: docs-onlyONLY if the PR contains zero runtime code changes. See.claude/rules/13-staging-verification.md.Deploy Stagingworkflow triggered manually and passed for this branchapp.sammy.party(staging) using test credentials and tested the applicationStaging Verification Evidence
https://api.sammy.party/healthreturned 200 with{"status":"healthy"}./api/projects,/api/projects/:id/environments, and/api/projects/:id/environments/:environmentId/public-routesreturned 200.https://app.sammy.party/returned 200.ports:fallback behavior was verified through the deployed public-routes endpoint.x-sam-routescompose-publish verification is blocked:x-sam-routes.[code: 7500]; the temporary environment was cleaned up.UI Compliance Checklist (Required for UI changes)
End-to-End Verification (Required for multi-component changes)
.claude/rules/10-e2e-verification.md)Data Flow Trace
buildComposePublishApplyPayload()and service container ports are read withcollectServiceContainerPorts()inapps/api/src/services/compose-publish-apply.ts.collectComposePublishPublicRoutes()inapps/api/src/services/deployment-routing.tsparses explicitx-sam-routes, validates service/port/mode, rejects provider services, and applies precedence so explicit service+port entries win overports:hints.buildComposePublishApplyPayload()deletes raw serviceports, assigns route targets withassignRouteTargets(), then injects only routed services as127.0.0.1:<hostPort>:<containerPort>bindings.buildComposePublishRouteTargets()uses the samecollectComposePublishPublicRoutes()+assignRouteTargets()path when reconstructing routes from stored compose-publish releases.ports:, private overrides suppressingports:, duplicate suppression, invalid route errors, and stored-release route reconstruction.Untested Gaps
x-sam-routesis blocked by missing workspace callback JWT/build_and_publish access and Cloudflare D1 write permission. Do not merge until that path is verified.Post-Mortem (Required for bug fix PRs)
What broke
Compose-publish deployment guidance described
x-sam-routessupport, but the compose-publish apply/reconstruction path only derived public routes from serviceports:.Root cause
The compose-publish raw-compose path had separate route derivation from the normalized manifest parser and never consumed top-level
x-sam-routes.Class of bug
Documentation/implementation contract drift in deployment route derivation.
Why it wasn't caught
Existing tests covered the
ports:route path and normalized parser behavior, but not raw compose-publishx-sam-routesprecedence or stored-release reconstruction.Process fix included in this PR
Focused regression tests now cover compose-publish
x-sam-routesbehavior in apply-time route assignment and stored-release reconstruction.Post-mortem file
tasks/archive/2026-06-24-compose-publish-x-sam-routes.mdSpecialist Review Evidence (Required for agent-authored PRs)
If local subagents were used during Phase 5, list every reviewer below. Do NOT merge until every row shows PASS or ADDRESSED. If any reviewer could not complete (timeout, workspace killed, error), you MUST add the
needs-human-reviewlabel and stop — do not self-merge. See.claude/rules/25-review-merge-gate.md.needs-human-reviewlabel added and merge deferred to human — N/A for reviewer completion; label is added for the staging feature-verification blocker.ports:as default andx-sam-routesas explicit override.x-sam-routes; no credential/auth/session changes.Exceptions (If any)
x-sam-routescompose-publish release is incomplete.[code: 7500].Agent Preflight (Required)
Classification
External References
N/A: implementation was based on repository code, tests, and SAM deployment docs/tool guidance.
Codebase Impact Analysis
apps/api/src/services/deployment-routing.ts: shared compose-publish route collection and stored-release target reconstruction.apps/api/src/services/compose-publish-apply.ts: apply-time route extraction, loopback binding rewrite, and private override behavior.apps/api/tests/unit/services/*: regression coverage for apply-time and reconstruction behavior.apps/api/src/routes/mcp/deployment-guide-tools.ts,apps/www/src/content/docs/docs/guides/app-deployments.md,apps/www/src/content/docs/docs/reference/api.md: docs/tool wording.packages/shared/src/compose-parser/parse.ts: diagnostic wording aligned with current route hints.Documentation & Specs
Updated deployment guide, API reference, and MCP deployment guide tool text to document
ports:as the default andx-sam-routesas the override.Constitution & Risk Check
Checked Principle XI/no hardcoded values and deployment exposure risk. The change avoids new hardcoded deployment constants, keeps hostnames/host ports assigned through existing configurable route options, and validates private/public exposure semantics with tests.