Skip to content

fix(process): accept a trace identifier the comparison result can represent - #2488

Merged
morluto merged 1 commit into
morluto:mainfrom
XiaoBinGan:fix/process-trace-identifier-bound
Oct 13, 2026
Merged

morluto merged 1 commit into
morluto:mainfrom
XiaoBinGan:fix/process-trace-identifier-bound

Conversation

@XiaoBinGan

Copy link
Copy Markdown
Contributor

The specification owns the declared trace, event and variant identifier vocabulary, and the comparison result echoes those identifiers verbatim into raw_trace[].event_id, matched_variant and diagnostic event_ids. Both modules must therefore accept the same values.

Summary

processTraceSpecification accepts a trace identifier with the shared IDENTIFIER_PATTERN, which has no length bound. processTraceEvaluation restated that pattern by hand as /^[A-Za-z][A-Za-z0-9._\x2d]{0,63}$/u, silently adding a 64-character cap. A specification whose identifier is longer than 64 characters therefore validates, and then the result of comparing it fails its own schema, so compareProcessTraces throws a raw ZodError at the caller instead of returning a comparison or a modeled failure.

IDENTIFIER_PATTERN is the repository's identifier owner and is used unbounded by every other consumer (evidenceCompletionLedger, completionLedgerGeneration, reconstructionVerificationSchemas, browserScenarioValues, conformancePackage, adbDeviceAnalysis). The capped copy in the evaluation module is the outlier, not the contract.

Problem and expected behavior

With compareProcessTraces from the built tree:

ZodError: [
  { "path": ["left", "raw_trace", 0, "event_id"],
    "message": "Invalid string: must match pattern /^[A-Za-z][A-Za-z0-9._\\x2d]{0,63}$/u" },
  { "path": ["right", "raw_trace", 0, "event_id"], "message": "…same…" }
]

Expected: a specification that the advertised trace_spec contract accepts produces a comparison result, never an escaping schema error.

Change and scope

  • processTraceSpecification exports its identifier schema as processTraceIdentifierSchema, documented as the owner of the declared identifier vocabulary. The module-local name is the exported one; no alias is kept.
  • processTraceEvaluation imports that schema and deletes the hand-written capped pattern. Its three uses (event_id, matched_variant, event_ids) now reference the single owner, so the specification and its result cannot drift apart again.

Direction of the fix: the specification is the input contract advertised to callers, and identifiers are caller vocabulary that the result merely echoes, so the bound is removed rather than added. Adding a 64-character limit to the specification instead would reject input the contract accepted today and would be a breaking change to an advertised tool input. No separate representation, alias or wrapper remains.

Contract and boundary impact

  • Semantic owner and earliest changed stage: the declared trace identifier in the process trace specification. Cancellation, capture parsing, matching, cardinality and the comparison verdict are untouched.
  • CLI and MCP/tool-catalog contract: no tool name, command, input field, output schema or error code changes. trace_spec gains no new accepted shape; the only difference is that an identifier longer than 64 characters now produces a result instead of an escaping ZodError. Inputs of 64 characters or fewer behave exactly as before, so no advertised schema narrows.
  • Provider, target-format or platform compatibility: none — platform-independent domain logic.
  • Evidence, artifact, provenance or reconstruction contract: no Evidence, artifact byte, digest or provenance value changes. The echoed identifier is the caller's declared value in both modules.
  • Process execution, authorization, cleanup or containment impact: none.
  • Generated metadata, package or installation impact: none.

Evidence and regression coverage

A new case in processTraceComparison.test.ts, "compares a declared identifier the comparison result can represent", declares a 65-character event id, asserts the specification schema accepts it, and asserts the comparison returns verdict: "equivalent" with matched_variant: "only" and raw_trace: [{ event_id: <the 65-character id> }].

Before the change the same test failed with the ZodError quoted above; the existing six cases in that file passed throughout, which is why the case was uncovered. Verification on macOS 26.5.1 arm64 with Node.js 24.18.0 and npm 11.16.0, based on bb54082:

  • npm run test:focused over the comparison, specification, adapters, capture-comparison, capture-validation and scenario suites: 48 passed, 0 failed.
  • npm run test:focused over the three boundary suites that drive traces through the CLI/MCP adapters (processTraceAdaptersParity, processComparisonDiagnosticsMcp, processTruncationAdapters): 24 passed, 0 failed.
  • npm run check:fast: passed.
  • npm run verify:test-discovery: all 1015 test files discovered exactly once.

Unavailable coverage: no Windows or Linux run. The change does not touch platform-conditional code.

…resent

The trace specification owns the declared identifier vocabulary and the
comparison result echoes those identifiers verbatim into raw_trace[].event_id,
matched_variant and diagnostic event_ids. The result module restated the shared
IDENTIFIER_PATTERN by hand with a 64-character cap, so a specification with a
longer identifier validated and then its own comparison result failed to parse:
compareProcessTraces threw a raw ZodError at the caller instead of returning a
comparison.

Export the identifier schema from the specification as the single owner and
reuse it in the evaluation module, removing the capped copy. IDENTIFIER_PATTERN
has no length bound and every other consumer uses it unbounded, so the
duplicate was the outlier. Removing the bound rather than adding one keeps the
advertised trace_spec input contract unchanged; identifiers of 64 characters or
fewer behave exactly as before.

Verified with 48 process tests, 24 boundary CLI/MCP trace tests, check:fast and
verify:test-discovery on macOS arm64. The regression test failed with the
ZodError before the change and passes after it.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

@greptileai review

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge and fixes the identifier mismatch without narrowing accepted inputs.

Summary

The PR removes the comparison result’s separate 64-character identifier limit.

  • Long trace identifiers now pass through comparison results.

No actionable issues found. Tests were not run during this review.

Reviews (1) · Last reviewed commit: "fix(process): accept a trace identifier ..." · Reviewed by Greptile

@morluto
morluto merged commit 2c6a4fa into morluto:main Oct 13, 2026
35 checks passed
@morluto morluto mentioned this pull request Oct 13, 2026
3 tasks done
@morluto morluto added bug Something isn't working area: runtime Process capture and runtime observation labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants