GPT 6 PROMPT
Investigate a boundary bug
Isolate an intermittent or edge-case defect before editing code.
Complete prompt
Task
Isolate an intermittent or edge-case defect before editing code.
Instructions
Investigate [BUG REPORT] in [RELEVANT FILES]. State the expected result and the exact observed result. List two or three plausible causes, then run the cheapest check that separates them. Preserve a minimal failing case. Once the cause is supported, make a focused repair and rerun that case plus adjacent boundaries. Include commands, exit status, and any checks you could not run.
Expected output
Reproduction, cause with evidence, minimal correction, and verification record.
Checks
- The failing case is shown before the fix.
- The chosen cause follows from a discriminating check.
- Post-fix verification includes a neighboring boundary.Expected output and checks
Expected output
Reproduction, cause with evidence, minimal correction, and verification record.
Checks
- The failing case is shown before the fix.
- The chosen cause follows from a discriminating check.
- Post-fix verification includes a neighboring boundary.
Worked example
Worked example: Investigate a boundary bug
Original input
Investigate page=0 is accepted, pageSize=0 yields an invalid page count, and status-filtered pages can be short with inflated totals in the attached original.js and pagination.test.js. State the expected result and the exact observed result. List two or three plausible causes, then run the cheapest check that separates them. Preserve a minimal failing case. Once the cause is supported, make a focused repair and rerun that case plus adjacent boundaries. Include commands, exit status, and any checks you could not run.
Contract:
# Frozen task input — synthetic pagination review
Date: 2026-09-24. Runner: Codex delegated task using GPT-6 Sol. This is a local sample, not a paid API request or a model benchmark.
Review `original.js` as a JavaScript helper for an item list. The public contract is `paginate(items, { page = 1, pageSize = 10, status })`, returning `{ items, page, pageSize, total, totalPages }`. `status`, when supplied, matches `item.status` exactly. `page` and `pageSize` must be positive integers; invalid values should throw `RangeError`. Filter the complete input before slicing. `total` counts matching items, `totalPages` is based on that count, and a page beyond the end returns an empty `items` array. Do not mutate the input.
Find concrete correctness defects with reproductions. Then write `corrected.js` and automated tests that cover `page = 0`, invalid sizes, filtering before pagination, matching total, and useful nearby boundaries. Run the test command and retain its raw output. Explain exactly which behavior was observed. Use only the synthetic fixture; do not change the live site helper or claim that an API benchmark was run.
Input source: `original.js` in this directory, saved before correction.
Attached original.js:
```js
// Synthetic review fixture. Intentionally defective; do not use in production.
function paginate(items, { page = 1, pageSize = 10, status } = {}) {
const start = (page - 1) * pageSize;
const pageItems = items.slice(start, start + pageSize);
const visibleItems = status
? pageItems.filter((item) => item.status === status)
: pageItems;
return {
items: visibleItems,
page,
pageSize,
total: items.length,
totalPages: Math.ceil(items.length / pageSize),
};
}
module.exports = { paginate };
```
The test file is available at pagination.test.js. Use the existing local test runner; retain actual exit codes.What the checks found
- Separated validation, operation order, and count-source causes using direct calls.
- Recorded failing baseline and passing correction with exit codes.
- Named nearby boundaries verified by the test file.
Original output
## Symptom and discriminating checks
Expected: positive integer `page` and `pageSize`, matching records selected before pagination, counts based on matches. Observed: `page: 0` returns a page; `pageSize: 0` produces raw `Infinity` for `totalPages`; first page of `open` records returns only ID 1 where IDs 1 and 3 are available, while counts report all five records.
Plausible causes were (a) missing argument validation, (b) `slice` before `filter`, and (c) counts computed from the source array. The direct call in `review-observations.txt` separates them: page 0 and size 0 reach arithmetic without an exception; the filtered page is short; the returned counts are 5 and 3. Source lines `original.js:3-13` confirm all three paths.
## Repair and verification
`corrected.js` validates both numeric arguments, filters before slicing, and computes counts from matching records. `PAGINATION_TARGET=./original.js node --test pagination.test.js` exited 1; `node --test pagination.test.js` exited 0 at 2026-09-24T07:24:38Z. The corrected run passed six cases, including empty status, no matches, page past the end, and input preservation. Raw outputs: `bug-baseline-test.txt`, `bug-corrected-test.txt`; exit record: `bug-run.txt`. No browser or service behavior was exercised.Files from this run