← all branches

fix/cfe-inputs

needs attention
d1ec070 · incrementalPR #287reviewed 2026-07-24 00:31 UTC1H · 3M · 4L
The branch
Purpose
BAT-272 — CFE collector was silently reporting a failed Mi Espacio registration as a successful job with zero bills. This branch fixes the silent-success path and adds comprehensive grading tests.
Goal
Ensure a transient Mi Espacio registration failure retries via SFN and grades 'failed', not 'completed'. A genuinely empty account still grades 'completed' (no false positives).
Sub-goals
  • SG-1: Repair the recoverable gate + make registration-failure distinguishable (decideMiEspacioFailureAction)
  • SG-2: Pin the finalize grading with regression tests (decideFinalizeJob 3-row truth table)
  • SG-3: Rework strategy label — gobierno_fallback distinct from gobierno_only
  • SG-4: Preview e2e on manually-deployed cfe-silent estate (ALL PASS)
  • SG-N: Framework improvements (MAX_BRANCH_NAME_LEN 16, doc fixes)
The changes (whole branch)
What
This incremental commit: simplifies latestTotal derivation (removes isBillTotalTrustworthy staleness check); removes 200-char service_name guard; wires latest_only into parseFilesListQuery; adds BAT-272 grading regression tests; adds .describe() to public schemas; updates API doc strings.
Why
The latestTotal staleness check was preventing registration attempts on RPUs with old stored bills — the new approach always tries the stored total and lets CFE return LATEST_TOTAL_REQUIRED if it rejects it, which is a cleaner user-facing error. The service_name update behavior is removed from the public API (existing-contract names immutable via this route).
Areas
domains/utility/src/cfe-job+8075apps/platform/src/api/utils+2520apps/platform/src/api/contracts/public-v1+128packages/api/src/schemas/public+1010
Blast
6 files in incremental diff; 9 branch-own files total. Touches public-v1 validator (API-facing), CFE job decisions (pure core), public schemas. No shell changes, no DB migrations, no CDK/infra.
public-api CFE
ci· CI checks not accessible via tokencoderabbit· no .coderabbit.yamlcorrectness· 1 mediumsecurity· 1 mediumconventions· 1 high, 1 medium, 1 lowtests· 1 medium, 2 lowimprovement· 3 suggestionsseo· no apps/web files

Findings · 9

correctness1

medium

service_name 200-char guard removed; new-RPU contracts accept unbounded names

apps/platform/src/api/utils/public-v1-validation.ts:427

MAX_SERVICE_NAME_LENGTH and its guard were the only length check on the public-v1 path. For new RPUs, an oversized service_name now stores in the DB without error (text column, no constraint).

security1

medium

Unbounded service_name may hit SFN/EventBridge 256KB payload caps

apps/platform/src/api/utils/public-v1-validation.ts:426

No length validation between the HTTP body and the DB insert. A megabyte-scale service_name could push SFN StartExecution or EventBridge events over the 256KB hard cap.

conventions3

high

MCP batu_collect_bills missing latest_total param

packages/mcp-server/src/index.ts:221

Per .claude/rules/mcp-server.md: every public-v1 route's MCP tool must match the endpoint's validator. parseJobCreateBody now accepts latest_total, but batu_collect_bills has no latest_total field and doesn't forward it. An agent cannot supply latest_total to break the CFE registration deadlock — the primary purpose of this commit.

medium

MCP README not updated for latest_total

packages/mcp-server/README.md

mcp-server.md rule: update the tools table for any new filter. batu_collect_bills entry omits latest_total.

low

latest_total fail() omits error code; period_count includes one

apps/platform/src/api/utils/public-v1-validation.ts:414

Inconsistent with the adjacent period_count pattern in the same function.

tests3

medium

latest_only in parseFilesListQuery has zero test coverage

apps/platform/src/api/utils/__tests__/public-v1-validation.test.ts

latest_only was added but no test covers it, including the mutual-exclusion guard with bill_id.

low

toCfeJobConfig: latest_total → latestTotal not tested for zero value

apps/platform/src/api/mappers/public-v1/__tests__/jobs.mapper.test.ts

latest_total: 0 is a valid bill total; the !== undefined guard is correct but untested.

low

Collect SFN: latestTotal only tested as null

apps/platform/src/api/utils/__tests__/cfe-job-dispatch.test.ts:173

No test asserts non-null latestTotal propagates into the SFN collect payload.

improvement1

low

No comment explaining absence of service_name length cap

apps/platform/src/api/utils/public-v1-validation.ts

Future maintainer may re-add the cap without understanding the deliberate removal.

History · 4 commits

  1. d1ec070needs attentionincremental1H · 3M · 4L2026-07-24 00:31current
  2. e367b60needs attentionincremental0H · 2M · 2L2026-07-09 18:25
  3. 6f7954aneeds attentionincremental1H · 5M · 5L2026-07-09 17:38
  4. 6e0ff6fneeds attentionfull1H · 5M · 5L2026-07-09 17:17