Skip to content

fix(templates,test): clarify swe_issue_readiness repro_steps vs env_or_logs and test JSX/Helm braces - #102

Merged
ghchinoy merged 1 commit into
GoogleCloudPlatform:mainfrom
ghchinoy:fix/swe-issue-readiness-and-braces-test
Dec 3, 2026
Merged

ghchinoy merged 1 commit into
GoogleCloudPlatform:mainfrom
ghchinoy:fix/swe-issue-readiness-and-braces-test

Conversation

@ghchinoy

Copy link
Copy Markdown
Collaborator

Summary

Follow-up polish for templates/swe/ from #101:

  1. Clarify repro_steps vs. env_or_logs on swe_issue_readiness:
    • Tightens option descriptions in templates/swe/swe_issue_readiness.json.tmpl so repro_steps explicitly covers bug reports that identify the symptom/component but lack concrete steps or triggering inputs (even when environment details are present or no error is logged), while env_or_logs targets missing diagnostic error output or runtime/OS/config details.
    • Replaces the typical example in templates/swe/swe_issue_readiness.examples.json (which previously included Error log: + a 1-line panic message, pulling model predictions toward env_or_logs) with a clean logic-bug ticket (Exported CSV in reports/export.go occasionally drops the last row, explicit component + Go/OS version + HTTP 200 / no crash) missing only triggering inputs and reproduction steps.
  2. JSX / Helm / Jinja {{ ... }} delimiter regression test:
    • Adds TestSWETemplatesRenderTemplateDelimitersInDiffs in pkg/template/examples_test.go, verifying all 8 templates/swe/*.json.tmpl safely escape and preserve React JSX (style={{ color: "red", padding: 8 }}), Helm/Go template ({{ .Values.image.tag | default "latest" }}), and Jinja ({% if env == "prod" %}{{ user_input }}{% endif %}) payloads without template errors or JSON corruption.

Surface & Documentation Checklist

  • CLI, HTTP gateway, MCP server, and Decision Studio stay in parity (no new options or surfaces).
  • docs/ and docs-site/ are synced (no documentation changes).
  • No real project IDs, endpoint URLs, keys, or build outputs (studio/dist/*) are included.

Verification

  • go vet ./...
  • go test -count=1 -race ./pkg/template/... ./cmd/... (including all 8 subtests of TestSWETemplatesRenderTemplateDelimitersInDiffs and TestAllShippedTemplatesRenderAndValidate/swe/swe_issue_readiness)

@jigyasujuneja jigyasujuneja left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good direction separating repro_steps from env_or_logs and checking template delimiters. A few small items to tighten before merge (happy to approve after):

  • Merge conflict with #103: git merge-tree hits a content conflict in pkg/template/examples_test.go because both PRs append a test at the same spot. Merge #103 first, rebase here, and keep both tests.
  • Option overlap in the new typical example: env_or_logs (templates/swe/swe_issue_readiness.json.tmpl:33-35) still reads "Bug report lacks diagnostic error output (stack trace, error message, exit code)...", and the new example (templates/swe/swe_issue_readiness.examples.json:8) says "returns HTTP 200 with no error or crash". Literally speaking it lacks error output, so only the parenthetical in repro_steps (:22) breaks the tie. Scoping env_or_logs to failures where error output or runtime details exist but were left out (or adding a short precedence rule in instructions) avoids relying on a parenthetical.
  • foundAll loop (pkg/template/examples_test.go:253-260) stops at the first string field containing all three snippets. Check every replaced string key instead so one unescaped or dropped field cannot slip past.
  • Test scope and mutant check (pkg/template/examples_test.go:190-210): Go text/template never re-parses data values, so this checks toJson escaping across every string variable (including non-diff fields). Adding a control character ("\x07"), "\u2028", and a non-BMP rune ("😀") to adversarialPayload also catches {{ printf "%q" ... }} mistakes, which currently pass even though %q produces invalid JSON escapes for control bytes.

…r_logs and test JSX/Helm/control-char escaping

Rebased cleanly onto merged GoogleCloudPlatform#103 (keeping both SWE template tests) and
addressed review feedback:
- Scope env_or_logs to failures that produce an error/crash or depend on
  environment state yet omit relevant diagnostics, and state precedence
  directly in missing_info_kind.instructions so HTTP 200 logic bugs map
  unambiguously to repro_steps.
- Replace typical example in swe_issue_readiness.examples.json with clean
  HTTP 200 CSV logic bug missing only repro steps/inputs.
- Add TestSWETemplatesRenderTemplateDelimitersInDiffs verifying every
  replaced string state field preserves JSX, Helm, Jinja, control byte
  (\x07), U+2028, and non-BMP emoji runes intact via toJson.
@ghchinoy

ghchinoy commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks @jigyasujuneja — rebased onto main (post-#103) and addressed all 4 items:

  • Rebased cleanly on fix(templates,test): add untrusted-DATA prompt-injection guard to swe_model_router and agent_loop_detector #103: Kept both TestSWETemplatesIncludeUntrustedDataGuard and TestSWETemplatesRenderTemplateDelimitersInDiffs in pkg/template/examples_test.go.
  • Tightened env_or_logs vs. repro_steps boundary: Scoped env_or_logs specifically to failures that produce an error/crash or depend on environment state yet omit diagnostics, and added an explicit tie-break in missing_info_kind.instructions instead of relying on a parenthetical.
  • Check every replaced string field: Replaced the short-circuiting foundAll loop with a per-key verification over every replaced string variable in state.
  • Added control-byte & Unicode checks: Added \x07, \u2028, and 😀 to adversarialPayload so toJson escaping is exercised against printf "%q" mistakes too.

Verified: go vet ./... and go test -count=1 -race ./pkg/template/... ./cmd/....

@ghchinoy
ghchinoy force-pushed the fix/swe-issue-readiness-and-braces-test branch from 53073ad to 4dbbdce Compare December 2, 2026 15:55

@jigyasujuneja jigyasujuneja left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All four items from the previous pass are addressed cleanly:

  • Rebased onto main after #103 with both TestSWETemplatesIncludeUntrustedDataGuard and TestSWETemplatesRenderTemplateDelimitersInDiffs intact.
  • Scoped env_or_logs to failures with errors, crashes, or environment dependencies and added an explicit tie-break in missing_info_kind.instructions.
  • Switched TestSWETemplatesRenderTemplateDelimitersInDiffs to verify every replaced string key in state instead of stopping on the first match.
  • Added \x07, \u2028, and 😀 to adversarialPayload to exercise toJson escaping beyond printf "%q".

CI checks are green (7 passed, 5 skipped). Approved.

@ghchinoy
ghchinoy merged commit 492df6c into GoogleCloudPlatform:main Dec 3, 2026
12 checks passed
@ghchinoy
ghchinoy deleted the fix/swe-issue-readiness-and-braces-test branch December 3, 2026 00:50
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