Skip to content

fix(trial): preserve patch output bytes - #383

Open
mayankdhingra02 wants to merge 4 commits into
BenSheridanEdwards:mainfrom
mayankdhingra02:fix/preserve-trial-patch-bytes
Open

mayankdhingra02 wants to merge 4 commits into
BenSheridanEdwards:mainfrom
mayankdhingra02:fix/preserve-trial-patch-bytes

Conversation

@mayankdhingra02

@mayankdhingra02 mayankdhingra02 commented Nov 16, 2026 •

Copy link
Copy Markdown

Why does this feature exist?

A trial patch can become corrupt when Git output is trimmed, losing a final blank context line. Fixes #380.

What changed?

Keep patch stdout untrimmed while retaining trimming for ordinary Git queries. Preserve the three real patch-application regressions. Let the fake agent make its wip commit through the fixture's normal hooks, with every result-commit assertion retained.

Behavioural Proof (with video and screenshots)

  • Video: Not applicable: this change affects repository tooling without a rendered UI.
  • Screenshots: Not applicable: executable regression checks verify the tooling output.
  • Behaviour tests: The final full suite includes all 95 trial-harness cases, including committed, uncommitted and mixed real git-apply recovery checks. The focused fake-agent commit case fails with the old bypass flag under the normal guard and passes with normal hooks. These regressions are included in the final full suite.
  • Fixture repair: all seven earlier frozen snapshots reproduce the guard refusal. The repaired focused case passes with unchanged assertions and normal hooks. Earlier full-pass logs are historical. The PR383 full-run failure and focused red/green evidence are retained in the delivery report.
  • E2E mapping: browser behaviour is unchanged; the complete Playwright map passed in the normal pre-push hook.

Verification Summary

  • Head commit: 02e81ed
  • PRDs checked: None: repository tooling outside product coverage globs
  • PRD impact: None
  • North Star commit: b6b5631
  • Commands run: pnpm exec jest --selectProjects tooling --testPathPattern tooling/trial/run-trial.test.ts --runInBand --testNamePattern '^runTrial makes the one result commit with the hooks on, whatever the agent committed$'; pnpm install --frozen-lockfile; pnpm lint:anti-slop; pnpm verify; pnpm e2e. Full verification ran through the shared heavy-suite limiter in the normal pre-push hook.
  • Results: 85 unit/tooling suites and 3192 tests passed; 2 consumer and 1 provider contract tests, 7 HTTP integration tests and 19 Playwright tests passed at this committed head. Normal pre-commit and commit-message hooks passed. No new dependencies or architectural constraints.
  • Pre-commit wall-clock timing: measured from the normal fixture-repair commit's hook steps at this head.
Pre-commit step Seconds
typecheck 1.988
biome (format, import order, JSON and CSS lint, staged only) 1.035
oxlint (all lint: general, policy, naming, React, Tailwind and React Doctor rules) 2.342
style tokens (CSS and index.html on the @repo/ui design tokens) 0.897
anti-slop (vendored Oxlint rules) 1.319
suppression ban (no inline lint or coverage suppressions) 1.414
architecture gate (fallow zones, folder structure, role diagram) 2.929
fallow (code intelligence: dead code, cycles, complexity) 1.885
secret scan (gitleaks, staged content) 1.027
  • Security hold: GHSA-fc5q-39xc-vjpf affects installed picomatch 2.3.2 and 4.0.4. The same installed versions fail the hosted security audit on the six companion PRs. This fork's hosted security gate has not run; five workflows require maintainer approval. The official advisory has no patched release and npm 4.0.8 is unavailable. An isolated upstream backport probe revealed matching and capture regressions, so no unvalidated patch, version override or audit exception was adopted. Release-age policy and audit thresholds are unchanged.
  • Definition of Done: local checks passed at this head. Security remediation, latest hosted checks and any guarded-change sign-off must pass before readiness.
  • pnpm verify
  • pnpm e2e
  • Behaviour is covered by the E2E map when user-visible behaviour changed; this tooling change has regression coverage.
  • Logic is unit-tested where logic changed.
  • Accessibility considered; the browser accessibility map passed.
  • The diff follows .agents/project/ARCHITECTURE.md and CONVENTIONS.md.
  • No gates were bypassed or weakened.
  • Known risks or skipped checks: production runtime and a live model trial remain unverified. Hosted checks are recorded separately. Required human sign-off is reserved for the named maintainer. Revert this PR to restore the previous tooling behaviour.

PRD Behaviours to Review

  • None

PR Proof Law

  • I followed .agents/project/PR_QUALITY.md and .agents/skills/pr-quality-contract/SKILL.md; the PR quality check verifies the proof format.

@BenSheridanEdwards

Copy link
Copy Markdown
Owner

Paused for the day (17 Nov, 07:5x GMT). Stopped at head 9664c26 after updating the branch from main: all checks green, merge state clean. Next: an Opus review at this exact head, then merge if approved.

@BenSheridanEdwards BenSheridanEdwards left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Reviewed at 9664c26. The fix is correct and well scoped: only writePatch reads Git's output untrimmed, while the other git() callers keep trimmed output. The three new cases pass locally and they apply the patch for real, not just compare bytes. The compare/result-facts parser is unaffected (compare tests pass).

The branch is one commit behind main, so it needs updating before merge.

The shared exec helper can still corrupt multibyte characters at stdout chunk boundaries, which predates this PR. That's tracked in #388.

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.

Trial patch is corrupt when the uncommitted diff ends in a blank context line

2 participants