Skip to content

fix(objectql): a preserveAudit by-id update no longer hands the primary key to the driver - #8319

Merged
os-zhuang merged 1 commit into
mainfrom
claude/issue-8215-preserveaudit-primary-key
Aug 13, 2026
Merged

fix(objectql): a preserveAudit by-id update no longer hands the primary key to the driver#8319
os-zhuang merged 1 commit into
mainfrom
claude/issue-8215-preserveaudit-primary-key

Conversation

@os-zhuang

@os-zhuangos-zhuang commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Fixes#8215

What

isPreservableUnderAudit (packages/objectql/src/validation/rule-validator.ts) now excludes the row's own primary key before consulting the preserveAudit whitelist:

Keyed on SystemFieldName.ID (@objectstack/spec/system) — the registry's sanctioned "canonical spelling of the column that plays role X" use — because there is no per-field primaryKey marker in the spec for a def-based test to read: the driver provisions id as the primary key on every physical table, unconditionally (resolveInjectedSystemColumns reports it even under systemFields: false), and the engine's whole by-id addressing (idAddressesThisRow, addressKey: 'id') reads that name. The primaryKey: true spellings in test fixtures are inert runtime decoration (register-object-authored-shape.pin.ts pins that the key is not a spec Field key).

Both directions pinned

The pin this card exists to turn red

The #8216 pin ("composes with preserveAudit rather than overriding it") captured pre-fix behaviour as observed, deliberately. Rewritten as "composes with preserveAudit — and the primary key is stripped even under the flag (#8215)", pointed at #8215 rather than #6435, and its load-bearing facts are asserted as literals (toHaveLength, toContain on field-name substrings, a literal out object) rather than derived from the composer, so a reworded message cannot keep both sides green.

Doc clause (cross-seat: content/docs/**, domain:devx#6023 — declared on the card by the PM)

content/docs/protocol/objectql/state-machine.mdx:113 already described the narrower whitelist ("author-declared businessreadonly fields"); one clause is added so the prose stays the correct half instead of inverting into the loose half: "— but never the record's own primary key (id), which is the address of the write rather than a fact being restored (#8215)."

Blast radius, measured

Out of ruled scope, unchanged

Changeset: patch for @objectstack/objectql (behaviour fix on a documented flag; nothing authorable removed, so no ADR-0087 entry — the changeset is not declared-breaking).


Generated by Claude Code

…primary key (#8215)
isPreservableUnderAudit read every platform object's id as an
author-declared business field (readonly: true, no system flag), so a
historical-import (preserveAudit) by-id update kept id through the
readonly strip and the driver received SET id = 'rec_1' WHERE id =
'rec_1' — a no-op on SQL, an outright rejection on stores with immutable
primary keys. The REST ingress folds the path id into every update body
(#6479), so a bulk import hit this without ever sending an id.
The predicate now excludes the primary key (SystemFieldName.ID) before
consulting the whitelist: the row's address is not a fact a historical
import restores, and the strip protects that column for a
store-portability reason, not an authorship one. The audit/timestamp
family and genuine business readonly fields are still preserved; the
shared predicate also stops an autonumber primary key from being seeded
under a preserveAudit insert, while business autonumber identifiers stay
preservable (#5503).
The one-clause doc amendment to state-machine.mdx rides along so the
prose and the code describe the same whitelist (the prose was already
the narrower, correct half).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RDTnVvsgA6cUZ4xFVtPZRy
@vercel

vercelBot commented Aug 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
ProjectDeploymentActionsUpdated (UTC)
objectstackIgnoredIgnoredAug 13, 2026 5:08am

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/objectql.

15 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/concepts/metadata-lifecycle.mdx(via @objectstack/objectql)
  • content/docs/data-modeling/formulas.mdx(via packages/objectql)
  • content/docs/deployment/migration-from-objectql.mdx(via @objectstack/objectql)
  • content/docs/deployment/vercel.mdx(via @objectstack/objectql)
  • content/docs/kernel/contracts/data-engine.mdx(via @objectstack/objectql)
  • content/docs/kernel/runtime-services/examples.mdx(via packages/objectql)
  • content/docs/kernel/services-checklist.mdx(via @objectstack/objectql)
  • content/docs/kernel/services.mdx(via @objectstack/objectql)
  • content/docs/permissions/authentication.mdx(via @objectstack/objectql)
  • content/docs/permissions/system-context.mdx(via packages/objectql)
  • content/docs/plugins/index.mdx(via @objectstack/objectql)
  • content/docs/plugins/packages.mdx(via @objectstack/objectql)
  • content/docs/protocol/kernel/index.mdx(via @objectstack/objectql)
  • content/docs/protocol/objectql/query-syntax.mdx(via packages/objectql)
  • content/docs/protocol/objectql/state-machine.mdx(via @objectstack/objectql)

1 release-owned page(s) also reference the affected code. These are read-only:

  • content/docs/releases/implementation-status.mdx(via @objectstack/objectql)

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

@github-actionsgithub-actionsBot added documentation Improvements or additions to documentation tests tooling labels Aug 13, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review August 13, 2026 05:28
@os-zhuang
os-zhuang added this pull request to the merge queueAug 13, 2026
Merged via the queue into main with commit 4b0ebdbAug 13, 2026
28 checks passed
@os-zhuang
os-zhuang deleted the claude/issue-8215-preserveaudit-primary-key branch August 13, 2026 05:41
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentationImprovements or additions to documentationsize/mteststooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A preserveAudit by-id update hands the primary key to the driver: isPreservableUnderAudit reinstates a platform object's own id

2 participants

@os-zhuang@claude