fix: padEditor author-attribute test off-by-one + run backend tests on PRs#36
Conversation
…on PRs Two linked problems surfaced when backend-tests finally ran on a main push: 1. Test off-by-one (the actual failure). The "inserts carry an author attribute even when authorId is empty" spec walked atext.attribs and required every op past the insert point to carry an author. But applyEdit splices the new text in *before* the pad's trailing '\n', so that original, AI-untouched newline is shifted to the document tail and correctly stays unattributed. The check skipped the seed prefix but had no upper bound, so it wrongly asserted on that trailing newline. Bound the check to [insertStart, insertEnd) — the span the AI actually wrote. The surgical-attribution code was right; only the assertion over-reached. 2. Why nobody noticed for ~2.5 weeks. backend-tests was skipped for same-repo PRs (it ran only on pushes or fork PRs), and the parent workflow only triggers push on main/master. So same-repo feature-branch PRs got no backend run, and this failure only ever showed up post-merge on main, where nothing blocks on it. Drop the guard so backend runs on every PR; it needs no secrets, so this is safe for forks too. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
Review Summary by QodoFix padEditor test off-by-one and enable backend tests on all PRs
WalkthroughsDescription• Fix off-by-one error in padEditor author-attribute test assertion - Test was checking trailing newline that AI never wrote - Bounded check to exactly inserted character span [insertStart, insertEnd) • Enable backend tests to run on all PRs, not just forks - Previous guard skipped same-repo PRs, hiding failures for 2.5 weeks - Failures only surfaced post-merge on main with no blocking mechanism Diagramflowchart LR
A["Test assertion<br/>over-reached"] -->|"Bound to inserted<br/>span only"| B["Correct bounds<br/>insertStart to insertEnd"]
C["Backend tests<br/>skipped on same-repo PRs"] -->|"Remove if guard"| D["Tests run on<br/>all PRs pre-merge"]
File Changes1. static/tests/backend/specs/padEditor.ts
|
Code Review by Qodo
1. Unscoped Actions token permissions
|
Pin backend-tests and frontend-tests jobs to permissions: contents:read now that backend runs PR-controlled code on every PR (incl. forks). Follow-up to #36; addresses Qodo finding. ci: commit — does not trigger a release.
|
🎉 This PR is included in version 1.2.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Context
After #35 merged, the post-merge
mainrun showedbackend-testsfailing — and it turns out it has been red on everymainpush since #29/#30 (2026-05-16). It was never visible on PRs because the job was skipped for same-repo PRs (see below). Two linked fixes:1. The actual failure — test off-by-one
The pad is seeded with
Base text→"Base text\n".applyEdit({appendText: '\nMore'})splices before the trailing\n, producing"Base text\nMore\n":Base text\n(inserted)More(inserted)\n(seed's original, shifted to tail)The test skipped ops in the seed prefix (
opEnd <= insertStart) but had no upper bound, so it also asserted on pos 14 — the seed's untouched trailing newline, which correctly has no author. The AI must not re-attribute text it never wrote, so the surgical-attribution code is correct; the assertion over-reached.Fix: bound the check to
[insertStart, insertEnd)— exactly the charactersapplyEditinserted.2. Why it hid for ~2.5 weeks — backend skipped on same-repo PRs
backend-testshad anif:guard that ran it only on pushes or fork PRs, and the parent workflow only triggerspushonmain/master. So same-repo feature-branch PRs got no backend run — failures only surfaced post-merge onmain, where nothing blocks on them. This is the same blind spot #35 addressed for the install contract, in another form.Fix: drop the guard so backend runs on every PR. Backend tests need no secrets, so it's safe for forks too. This PR's own backend run is the proof — it now executes pre-merge.
Verification
This PR exercises the fix on the PR itself (backend now runs on same-repo PRs). Merging only once it's green.
🤖 Generated with Claude Code