[GH-ISSUE #5456] [Bug] SQLite reply-budget refusals recommend recovering Evidence that was never produced #3314

Closed
opened 2026-10-31 00:39:04 +00:00 by bsakaguchi · 1 comment
Owner

Originally created by @coygeek on GitHub (Oct 20, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/5456

Before submitting

  • I searched the open and closed issues for a related report.
  • I removed credentials, tokens, private paths, and sensitive target data.

Area

CLI

Observed behavior

inspect-sqlite-database correctly refuses a selected row whose hex representation exceeds its 16 MiB worker reply budget, but recommends retrieving retained Evidence or using complete CLI JSON output. The failing command already requests complete CLI JSON, and this inspection fails before creating Evidence.

Reproduction

From the source checkout with dependencies and the built runtime prepared, run the script below. An independent verifier executed this exact script: both wide selections failed with the same recovery advice, and the intervening id-only control succeeded. The script isolates CLI configuration and creates a closed SQLite database with one 9 MiB blob.

python3 - <<'PYTHON'
import json, os, pathlib, subprocess, tempfile
work = pathlib.Path(tempfile.mkdtemp(prefix="sqlite-reply-check-"))
env = {k: v for k, v in os.environ.items() if not k.startswith("REA_")}
for key, name in [("HOME", "home"), ("XDG_CONFIG_HOME", "config"),
                  ("XDG_DATA_HOME", "data"), ("XDG_CACHE_HOME", "cache"),
                  ("XDG_STATE_HOME", "state"), ("TMPDIR", "temp")]:
    directory = work / name
    directory.mkdir()
    env[key] = str(directory)
path = work / "big.db"
fixture = """
const { DatabaseSync } = require('node:sqlite');
const db = new DatabaseSync(process.argv[1]);
db.exec('CREATE TABLE big (id INTEGER PRIMARY KEY, payload BLOB)');
db.prepare('INSERT INTO big (payload) VALUES (?)').run(Buffer.alloc(9 * 1024 * 1024, 7));
db.close();
"""
subprocess.run(["node", "-e", fixture, str(path)], env=env, check=True,
               capture_output=True, text=True)
for name, columns in [("wide", []), ("narrow", ["--column", "id"]),
                      ("wide-repeat", [])]:
    command = ["node", "scripts/rea.mjs", "inspect-sqlite-database", str(path),
               "--table", "big", "--row-limit", "1", "--format", "json"] + columns
    result = subprocess.run(command, env=env, capture_output=True, text=True, timeout=40)
    (work / (name + ".json")).write_text(result.stdout)
    (work / (name + ".stderr")).write_text(result.stderr)
    value = json.loads(result.stdout)
    print(json.dumps({"case": name, "exit": result.returncode,
                      "result": value if result.returncode else value["normalized_result"]["rows"]}))
PYTHON

Expected behavior

Preserve the documented reply limit and complete-output refusal, but explain recovery in terms of the selected SQLite output. Do not recommend retained-Evidence recovery for an observation that produced no Evidence, or complete CLI JSON when that mode already failed.

docs/sqlite-databases.md:103-109 documents the 16 MiB worker reply limit; lines 125-128 separately describe MCP delivery recovery. docs/mcp-contracts.md:102-115 associates actual MCP delivery-budget refusals with complete retained Evidence and an exact reference. Column selection is documented at docs/sqlite-databases.md:50-60.

Impact and scope

P3 recovery-wording defect, reproduced in both wide runs. The refusal, explicit reply-budget message, numeric limit, and non-retryable status remain correct. No incorrect successful analysis or data loss was observed. Selecting only id succeeded when that narrower observation suffices; it does not recover the excluded blob or make the original complete selection fit. Live MCP retention and other platforms were not tested.

REA version

6.7.0; source commit 074768901f3cdc8205b61773fb1faf6f6c7b3ca8 (prepared built CLI).

Runtime and platform

Node.js v26.12.0; Darwin arm64; SQLite 3.54.0. No external analysis provider was used.

Target and artifact context

Synthetic SQLite database with big(id INTEGER PRIMARY KEY, payload BLOB) and one 9,437,184-byte blob. The closed database was 9,453,568 bytes, below the 256 MiB snapshot allowance. The original database digest was unchanged after the inspections.

Interface

CLI

Earliest failure stage

Transport or result projection

Relevant output or evidence

Both wide commands exited 1 with empty stderr, resource_constraint, retryable: false, details.resource: "transport", and worker_reply_bytes: 16777216. Neither failing result contained an Evidence ID or reference. The observed message was:

Selected row byte lengths exceed the 16 MiB reply budget before hex projection.

The recovery action was:

Discover retained records with get_evidence_bundle and detail: summary, then inspect compatible records through inspect_analysis_view using an exact Evidence reference. Export complete retained session evidence through export_evidence_bundle to a caller-selected path, or use complete CLI JSON output. The connection remains usable.

The --column id control exited 0 with empty stderr, returned integer 1, and reported truncated: false.

Typed outcome or recovery expected

Keep the oversized-selection resource refusal and avoid partial successful Evidence. State that this observation has no completed Evidence to retrieve and that complete CLI JSON cannot bypass the worker reply limit. Fewer selected columns may permit a narrower observation. Genuine MCP delivery refusals after Evidence production should retain their applicable recovery guidance; that is a proposed regression check, not an executed MCP reproduction here.

Analysis or suspected cause

Source-derived reasoning at the tested commit: src/sqlite/SqliteDatabaseInspection.ts:95-107 counts selected cell byte lengths with hex expansion and refuses before projection. src/sqlite/SqliteDatabaseWorkerExecution.ts:91-101 maps that refusal to transport without a specific recovery action, so src/domain/analysisErrorPresentation.ts:67-74 supplies retained-Evidence/CLI advice. src/application/sqlite/SqliteDatabaseService.ts:97-116 returns the provider failure before constructing Evidence. The appropriate error taxonomy is left to implementation; the observed defect is the inapplicable recovery action.

Additional context

Prepared with AI assistance and independently reproduced through the supported CLI. The submission check fetched upstream main at 052956af3416fa01d93837e54fdec3ad2739f6d1: the cited SQLite producer, mapper, formatter, service, and SQLite documentation are unchanged from the tested baseline. The sole later change to docs/mcp-contracts.md adds an unrelated native-function-matching introduction. Current-main applicability is source-inspected, not a separate runtime reproduction.

Related but separate: #5405 concerns Rust/IL2CPP input admission and evidence-output advice. #4184 and PR #4216 concern unrelated catalog names exhausting selected-table output capacity. This fixture passes input admission and correctly reaches a genuinely oversized selected-row refusal; the defect is its recovery advice. No external provider or network access was needed for the reproduction itself.

Originally created by @coygeek on GitHub (Oct 20, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/5456 ### Before submitting - [x] I searched the open and closed issues for a related report. - [x] I removed credentials, tokens, private paths, and sensitive target data. ### Area CLI ### Observed behavior `inspect-sqlite-database` correctly refuses a selected row whose hex representation exceeds its 16 MiB worker reply budget, but recommends retrieving retained Evidence or using complete CLI JSON output. The failing command already requests complete CLI JSON, and this inspection fails before creating Evidence. ### Reproduction From the source checkout with dependencies and the built runtime prepared, run the script below. An independent verifier executed this exact script: both wide selections failed with the same recovery advice, and the intervening `id`-only control succeeded. The script isolates CLI configuration and creates a closed SQLite database with one 9 MiB blob. ```sh python3 - <<'PYTHON' import json, os, pathlib, subprocess, tempfile work = pathlib.Path(tempfile.mkdtemp(prefix="sqlite-reply-check-")) env = {k: v for k, v in os.environ.items() if not k.startswith("REA_")} for key, name in [("HOME", "home"), ("XDG_CONFIG_HOME", "config"), ("XDG_DATA_HOME", "data"), ("XDG_CACHE_HOME", "cache"), ("XDG_STATE_HOME", "state"), ("TMPDIR", "temp")]: directory = work / name directory.mkdir() env[key] = str(directory) path = work / "big.db" fixture = """ const { DatabaseSync } = require('node:sqlite'); const db = new DatabaseSync(process.argv[1]); db.exec('CREATE TABLE big (id INTEGER PRIMARY KEY, payload BLOB)'); db.prepare('INSERT INTO big (payload) VALUES (?)').run(Buffer.alloc(9 * 1024 * 1024, 7)); db.close(); """ subprocess.run(["node", "-e", fixture, str(path)], env=env, check=True, capture_output=True, text=True) for name, columns in [("wide", []), ("narrow", ["--column", "id"]), ("wide-repeat", [])]: command = ["node", "scripts/rea.mjs", "inspect-sqlite-database", str(path), "--table", "big", "--row-limit", "1", "--format", "json"] + columns result = subprocess.run(command, env=env, capture_output=True, text=True, timeout=40) (work / (name + ".json")).write_text(result.stdout) (work / (name + ".stderr")).write_text(result.stderr) value = json.loads(result.stdout) print(json.dumps({"case": name, "exit": result.returncode, "result": value if result.returncode else value["normalized_result"]["rows"]})) PYTHON ``` ### Expected behavior Preserve the documented reply limit and complete-output refusal, but explain recovery in terms of the selected SQLite output. Do not recommend retained-Evidence recovery for an observation that produced no Evidence, or complete CLI JSON when that mode already failed. `docs/sqlite-databases.md:103-109` documents the 16 MiB worker reply limit; lines 125-128 separately describe MCP delivery recovery. `docs/mcp-contracts.md:102-115` associates actual MCP delivery-budget refusals with complete retained Evidence and an exact reference. Column selection is documented at `docs/sqlite-databases.md:50-60`. ### Impact and scope P3 recovery-wording defect, reproduced in both wide runs. The refusal, explicit reply-budget message, numeric limit, and non-retryable status remain correct. No incorrect successful analysis or data loss was observed. Selecting only `id` succeeded when that narrower observation suffices; it does not recover the excluded blob or make the original complete selection fit. Live MCP retention and other platforms were not tested. ### REA version 6.7.0; source commit `074768901f3cdc8205b61773fb1faf6f6c7b3ca8` (prepared built CLI). ### Runtime and platform Node.js v26.12.0; Darwin arm64; SQLite 3.54.0. No external analysis provider was used. ### Target and artifact context Synthetic SQLite database with `big(id INTEGER PRIMARY KEY, payload BLOB)` and one 9,437,184-byte blob. The closed database was 9,453,568 bytes, below the 256 MiB snapshot allowance. The original database digest was unchanged after the inspections. ### Interface CLI ### Earliest failure stage Transport or result projection ### Relevant output or evidence Both wide commands exited 1 with empty stderr, `resource_constraint`, `retryable: false`, `details.resource: "transport"`, and `worker_reply_bytes: 16777216`. Neither failing result contained an Evidence ID or reference. The observed message was: ```text Selected row byte lengths exceed the 16 MiB reply budget before hex projection. ``` The recovery action was: ```text Discover retained records with get_evidence_bundle and detail: summary, then inspect compatible records through inspect_analysis_view using an exact Evidence reference. Export complete retained session evidence through export_evidence_bundle to a caller-selected path, or use complete CLI JSON output. The connection remains usable. ``` The `--column id` control exited 0 with empty stderr, returned integer `1`, and reported `truncated: false`. ### Typed outcome or recovery expected Keep the oversized-selection resource refusal and avoid partial successful Evidence. State that this observation has no completed Evidence to retrieve and that complete CLI JSON cannot bypass the worker reply limit. Fewer selected columns may permit a narrower observation. Genuine MCP delivery refusals after Evidence production should retain their applicable recovery guidance; that is a proposed regression check, not an executed MCP reproduction here. ### Analysis or suspected cause Source-derived reasoning at the tested commit: `src/sqlite/SqliteDatabaseInspection.ts:95-107` counts selected cell byte lengths with hex expansion and refuses before projection. `src/sqlite/SqliteDatabaseWorkerExecution.ts:91-101` maps that refusal to transport without a specific recovery action, so `src/domain/analysisErrorPresentation.ts:67-74` supplies retained-Evidence/CLI advice. `src/application/sqlite/SqliteDatabaseService.ts:97-116` returns the provider failure before constructing Evidence. The appropriate error taxonomy is left to implementation; the observed defect is the inapplicable recovery action. ### Additional context Prepared with AI assistance and independently reproduced through the supported CLI. The submission check fetched upstream main at `052956af3416fa01d93837e54fdec3ad2739f6d1`: the cited SQLite producer, mapper, formatter, service, and SQLite documentation are unchanged from the tested baseline. The sole later change to `docs/mcp-contracts.md` adds an unrelated native-function-matching introduction. Current-main applicability is source-inspected, not a separate runtime reproduction. Related but separate: #5405 concerns Rust/IL2CPP input admission and evidence-output advice. #4184 and PR #4216 concern unrelated catalog names exhausting selected-table output capacity. This fixture passes input admission and correctly reaches a genuinely oversized selected-row refusal; the defect is its recovery advice. No external provider or network access was needed for the reproduction itself.
Author
Owner

@morluto commented on GitHub (Oct 21, 2026):

Closing as fixed on main by github.com/morluto/rea@f801b2fbfd, retained at 67a6477f01.

SQLite output-limit replies now explicitly name both fixed 16 MiB allowances, say deadlines cannot raise them, offer exact-column/row-limit/schema selection when appropriate, and state that no completed Evidence exists to retrieve. The rejection remains non-retryable. This corrects the actual owning reply projection; no new SQLite-specific remediation runtime assertion was executed in this audit.

This audit inspected the current producer, regression source, issue discussion and main ancestry. Tests/runtime reproductions were not rerun, and no additional real-provider or platform coverage is implied.

<!-- gh-comment-id:6324331459 --> @morluto commented on GitHub (Oct 21, 2026): Closing as fixed on main by https://github.com/morluto/rea/commit/f801b2fbfd28f4e3713adefddc7bd73db44c284c, retained at 67a6477f011ae358fc333e5a6e26c86d932654ed. SQLite output-limit replies now explicitly name both fixed 16 MiB allowances, say deadlines cannot raise them, offer exact-column/row-limit/schema selection when appropriate, and state that no completed Evidence exists to retrieve. The rejection remains non-retryable. This corrects the actual owning reply projection; no new SQLite-specific remediation runtime assertion was executed in this audit. This audit inspected the current producer, regression source, issue discussion and main ancestry. Tests/runtime reproductions were not rerun, and no additional real-provider or platform coverage is implied.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#3314
No description provided.