Skip to content

driver-sql: presentReadValue has no boolean kind, so distinct and aggregates over a boolean column show raw 1/0 (or legacy 'true'/'false') on SQLite #34974

Closed

Description

@objectstack-fleet

triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

Filed by triage at the request of repo:objectstack#3: a follow-up of p1 #34916 (PR #34965), ruled out of that PR's scope (seat ruling 6957305509; L1-d 6959775843). It is pre-existing, and #34965 does not widen it.

What happens

presentReadValue in driver-sql maps read values by field kind, but has no boolean kind. distinct and aggregate results over a boolean column therefore come back as raw 1 / 0 (and legacy 'true' / 'false') on SQLite, where record reads show booleans.

A group-by or distinct over a yes/no field shows 1/0 buckets.

Done when

  • A boolean kind in presentReadValue covers distinct and aggregate outputs.
  • A pin on SQLite: distinct over a boolean column returns true / false.

Grade: p3 · domain:server (out of focus). It is a visible but cosmetic bucket label on one driver. Alone that would be p2, so one grade lower out of focus gives p3.

Activity

  1. added
    pm:queue
    finding
    domain:server
    on Nov 17, 2026
  2. objectstack-fleet commented on Nov 18, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Scope widened and regraded p3 → p2 (02:2xZ), from repo:objectstack#3 (6967058582, item 1, the delta L2 on PR #35076):

    Done when the boolean kind added here maps '0' / 'false' / 0 to false and '1' / 'true' / 1 to true, for both distinct and aggregates, with pins on an INTEGER column and a TEXT-affinity column. Reading first: confirm the TEXT-affinity case live on SQLite.

  3. added
    priority:p2
    and removed on Nov 18, 2026
  4. objectstack-fleet commented on Nov 19, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb

    Claim: PM loop round 1 · area data-1 (lease:data-1; the maintainer, verbatim, 2026-11-19T04:35Z project chat: 「再开 area:data」; standing 「暂时都只派 p1 p2 的卡」) · 2026-11-19T04:44Z
    Session: session_01Utp6Ca1jJvsA1dHsPwMiQb
    Account: os-bill
    Branch: claude/issue-34974-boolean-read-presenter
    Worktree: objectstack-issue-34974 (os-dev worktree in the data-1 container)
    Domain: domain:server
    Seat: repo:objectstack#5
    File surface: packages/drivers/driver-sql/src/sql-driver-filter-helpers.ts (presentReadValue boolean arm, and readPresentationKind only if the kind must widen), a new test file named for this card in packages/drivers/driver-sql/src/, root .changeset/. Stop on breach and report.
    Container & model: S, mode:subagent, model: default — no path-derived mandate, effort: high
    Clause-②: no (measure on the diff: a stored boolean presents as the boolean find() already shows)
    Metadata-protocol: none
    Responsibility: platform — driver-sql presentReadValue 'boolean' arm returns Boolean(value), so a stored '0' / 'false' on a TEXT-affinity boolean column groups as true in distinct / aggregate; every dashboard or MCP group-by over a yes/no field on SQLite (and MySQL / Oracle flag columns).
    Thread-read: 6967079048
    Premise: partly holds — on origin/main de8d5497: sql-driver-filter-helpers.ts:333-334 presents the 'boolean' kind as Boolean(value) (so '0' / 'false' → true); readPresentationKind already yields 'boolean' for SQLite / MySQL / Oracle declared booleans (the body's "no boolean kind" is stale; the triage widening 6967079048 is the live defect). The dev measures the TEXT-affinity case live on SQLite first, as the card asks.
    Serial constraints cleared: none — overlap-check.mjs on a probe branch touching sql-driver-filter-helpers.ts and sql-driver-distinct.ts: 0 open PR heads share the files, base merges cleanly.
    Pre-claim lane: domain:server (packages/drivers/driver-sql/**)
    Pre-claim deps: none named; #34916 / PR #34965 and PR #35076 merged.
    Prior rulings read: check-prior-rulings 173 hits — ADR-0061 D2, ADR-0014 §2, ADR-0098 §2, ADR-0113 D3, ADR-0119 D1, ADR-0120 D5 (term noise, none on point); triage widening 6967079048 sets Done-when; thread: none
    Lease: lease:data-1

  5. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 19, 2026
  6. objectstack-fleet commented on Nov 19, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb
    os-dev-report

    {
      "issue": 34974,
      "status": "done",
      "branch": "claude/issue-34974-boolean-read-presenter",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/35332",
      "head": "c057c311b4f8ed3b8ec8230b0fe6272fa003f756",
      "session": "session_01Utp6Ca1jJvsA1dHsPwMiQb",
      "premise_still_valid": true,
      "summary": "presentReadValue's 'boolean' arm now calls presentStoredBoolean, the function formatOutput applies to a find() row, instead of Boolean(value). distinct() and aggregate() group keys (plain and aliased) therefore present 0 / '0' / 'false' as false and 1 / '1' / 'true' as true; any other value keeps its Boolean(value) reading. The premise holds partly: readPresentationKind already returned 'boolean' (the card body's 'no boolean kind' is stale), and the live defect was the Boolean(value) arm, confirmed live on SQLite on a TEXT-affinity column before the fix.",
      "readings": {
        "A1": "HOLDS at de8d5497: readPresentationKind (sql-driver-filter-helpers.ts:283-302) returns 'boolean' when (isSqlite || isMysql || isOracle) and booleanFields[table] includes the field. Unchanged by this PR.",
        "A2": "HOLDS: the 'boolean' arm was `return Boolean(value);` (filter-helpers.ts:333-334). Live on SQLite before the fix, from the new test file: TEXT-affinity distinct() answered [true] for a column holding '0' x3 and '1' x1; group key answered [[true,3],[true,1]]; INTEGER-column distinct() with legacy text 'false' answered [true]. 6 of 10 pins red, find() pins green.",
        "A3": "The case SURVIVES boot. backfillCanonicalBooleans rewrites only typeof='text' 'true'/'false', with SQL literals 1/0; on a TEXT-affinity column those land as the text '1'/'0', and it leaves '1'/'0' text alone on purpose. Measured: raw `flag text` table with '0','false','false','true', then initObjects: every cell is text '0'/'0'/'0'/'1' (pinned in the new file's fixture test). Also measured: a field retyped text to boolean keeps declared type TEXT after initObjects (pragma_table_info TEXT before and after), so TEXT affinity is reachable by a metadata retype. On that column the driver's own create(flag:false) stores the text '0.0' (not '0') - see out_of_scope_findings.",
        "A4": "YES: aggregate() group keys go through readPresentationKind (sql-driver-aggregation.ts:234 for a string key, :290 for an aliased object key, :345 for a related-object key) into presentedOutput, then presentReadColumns (:590), which calls presentReadValue. Pinned for plain and aliased keys on both columns. min/max/sum/avg over a boolean skip the 'boolean' kind (:479-480, the #11635 numeric ruling) and are unchanged."
      },
      "files_changed": [
        "packages/drivers/driver-sql/src/sql-driver-filter-helpers.ts (+5 -1: import + the boolean arm)",
        "packages/drivers/driver-sql/src/sql-driver-sqlite-serialisation.ts (+4 -1: export keyword + one docblock sentence) - OUTSIDE the fence, see deviations",
        "packages/drivers/driver-sql/src/sql-driver-34916-boolean-text-read.test.ts (+3 -2: stale before-half of the #34973 groupBy pin) - OUTSIDE the fence, see deviations",
        "packages/drivers/driver-sql/src/sql-driver-34974-boolean-read-presenter.test.ts (new, 10 tests)",
        ".changeset/34974-boolean-read-presenter.md (new, @objectstack/driver-sql patch)"
      ],
      "line_budget": "changed lines 173 (+169 / -4, 5 files) per dispatch-gates vs the human-merge threshold 3000: under. No governed surface, no skills/** file, no ratchet ledger touched.",
      "tests": "At head c057c311: `pnpm --filter @objectstack/driver-sql test` Test Files 264 passed | 13 skipped (277), Tests 4397 passed | 257 skipped (4654), lock VERDICT command-exit 0. `pnpm --filter @objectstack/driver-sql typecheck` exit 0; tsc --listFiles includes the new test file (1 hit). New file alone: 10/10. Before the fix (reading): 6 failed | 4 passed. Ablation on committed fix via scripts/ablation-replace.mjs: anchor 'return presentStoredBoolean(value);' x1 to x0, blob 6ec738601bee to 77d0e0a57de7, run 6 failed | 4 passed (the same six), restore blob == HEAD 6ec738601bee, git diff HEAD empty. Subject imported from src (./sql-driver.js), so no dist leg. Sibling boolean suites (11782, 11635, 17586, 34916) green after the 34916 pin update; the 34916 groupBy pin went red on the fix first (expected: its before-half pinned this defect).",
      "gates": "Local, derived by `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` (65 families, tree c057c311): 62 exit 0; 3 exit 3 = NOT MEASURED (prerequisite): `node scripts/check-plugin-teardown-shape.mjs --self-test` (needs unshallow clone for a pinned fixture commit), `pnpm check:dual-build-cjs-loads` (needs every package's dist, 96 absent), `pnpm check:lean-entry-closure` (needs packages/objectql/dist). `--ran` reconciliation with exit-annotated record: '65 derived famil(ies) accounted for - 62 run, 3 NOT-MEASURED (3 DERIVED from a recorded exit 3)', exit 0. overlap-check --branch=HEAD: 'VERDICT clean exit 0' (origin/main merges cleanly, 0 PR heads share files). check-platform-checklist not owed (no export renamed or deleted; one module-internal export added). CI on PR head c057c311 at report time: Lint & Repo Gates success, TypeScript Type Check success, Build Core success, Governed Surface Queue Guard success, Live E2E UI success, Test UI success, Dogfood Regression Gate success, Check Changeset success, Check PR Size success, PR-body guards success, Test Core 7/10 shards success and shards 3, 9, 10 in_progress; Lint UI / Type Check UI / Build & E2E UI skipped by selector.",
      "dogfood_battery": "n/a - no `!` in the PR title and no (narrowing) arm",
      "deviations": [
        "Fence breach 1: sql-driver-sqlite-serialisation.ts. presentStoredBoolean was module-private there; the route ('use that same function if one exists') and presentReadValue's class docblock ('the function formatOutput itself calls, never a re-derivation') need presentReadValue to call it, so the file gains `export` and one docblock sentence. No body change. Inside-fence alternative was a second copy of the mapping, which the docblock forbids.",
        "Fence breach 2: sql-driver-34916-boolean-text-read.test.ts. Its [#34973] groupBy pin's before-convergence half asserted the defect this card fixes ('the text false group presents as true') and went red on the fix. A test the change makes false must be fixed in the same PR, so the expected before-value now reads that group as false; the after-half is untouched.",
        "Commit trailer: the harness attribution asked for a model-named Co-Authored-By; the pre-push hook check:commit-card-trailers refused it, and the unpublished commit was reworded to the model-free pair (Co-authored-by: Claude) before the first push. No published history rewritten.",
        "PR footer: the AGENTS.md session-URL footer form is used, not the harness's alternative line.",
        "test:repo (vitest repo project) not run locally; declared to CI per os-dev (diff touches none of its tests).",
        "AGENTS.md section 10 'run the full suite once before opening a PR': scoped to the affected package (driver-sql test + typecheck) per os-dev's local-verification scope; the full farm is CI's."
      ],
      "mcp_calls": "0",
      "api_writes": "2 relay strokes. (1) pr_create via scripts/pm/fleet-write/dispatch.mjs: POST /repos/objectstack-ai/objectstack/dispatches, executed as POST /repos/objectstack-ai/objectstack/pulls (draft) + POST /repos/objectstack-ai/objectstack/issues/35332/assignees (os-bill); read-back 6549 bytes sent = stored. (2) this os-dev-report comment via scripts/pm/post-stamped.mjs: POST /repos/objectstack-ai/objectstack/issues/34974/comments. git push x3 (not REST).",
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": [
        "class: a · reach: named producer - the driver's own SqlDriver.create() on SQLite, after initObjects boots a field retyped from text to boolean (the column keeps declared type TEXT, measured with pragma_table_info before and after) · evidence: create(p, {flag:false}) and create(p, {flag:true}) store the text '0.0' and '1.0' (better-sqlite3 binds the JS number as REAL, TEXT affinity keeps it as text); find() then presents BOTH as true (presentStoredBoolean('0.0') falls to Boolean('0.0')), distinct() answers [true]. On the same column `flag = false` misses the text '0' rows the boot convergence writes. Not measured at the HTTP door. Fix routes are a design choice (read '0.0'/'1.0' in the shared presenter, which changes find(); or converge or rebuild the column's storage), so not touched here · dedupe words: TEXT affinity boolean, retyped column, '0.0', presentStoredBoolean, boolean storage convergence"
      ]
    }
  7. objectstack-fleet commented on Nov 19, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb

    Claim: amended by the area after the dev's measurement (os-dev-report 7000733773, deviations 1 and 2) · 2026-11-19T05:34Z
    Session: session_01Utp6Ca1jJvsA1dHsPwMiQb
    Account: os-bill
    Branch: claude/issue-34974-boolean-read-presenter
    File surface: as claimed, plus packages/drivers/driver-sql/src/sql-driver-sqlite-serialisation.ts (presentStoredBoolean gains export and one docblock sentence, no body change, so presentReadValue calls the one function formatOutput already uses instead of a second copy) and packages/drivers/driver-sql/src/sql-driver-34916-boolean-text-read.test.ts (the before-convergence half of its #34973 groupBy pin asserted this card's defect). No other path. PR: #35332.
    Clause-②: no
    Metadata-protocol: none

  8. objectstack-fleet commented on Nov 19, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6Ca1jJvsA1dHsPwMiQb

    Close-out 2026-11-19T06:20Z: PR #35332 MERGED as 24cc61fab; Fixes closed this card. Delivered: driver-sql's presentReadValue 'boolean' arm now calls presentStoredBoolean, the function find() already uses, so distinct() and aggregate() group keys present 0 / '0' / 'false' as false and 1 / '1' / 'true' as true on SQLite (INTEGER column holding legacy text, and a TEXT-affinity column), pinned and ablated. Known residue (L1-a ACCEPT 7000891060): on a column the boot has not converged, SQL still groups raw text and integer cells apart, so two buckets can carry the same label until convergence. Follow-up filed from the dev's report: #35341 (a boolean retyped from text keeps a TEXT column and create() stores '0.0' / '1.0'). pm:dispatched off.

  9. removed
    pm:dispatched
    on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:datadomain:serverfindingpriority:p2

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions