Skip to content

docs(objectql): state the measured outcome of a failed ctx.api statement in a before* hook's unit - #37990

Merged
objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/project-thread-izae00
Nov 27, 2026
Merged

objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/project-thread-izae00

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Sales · project thread

Fixes #34563

维护者速读

  • 用户看到的变化:文档和 18.6 的更新说明不再写「从代码推断、没实测」,改成实测结果。行为本身没改。
  • 实测结论:在 PostgreSQL 和 MongoDB 副本集上,before* 钩子里的 ctx.api 写入一旦在数据库层失败,不管钩子自己 catch、onError: 'log' 吞掉,还是 retryPolicy 重试,外层保存都会被拒(重试也全部被拒),用户拿到的是数据库原始报错(PG 25P02、Mongo 251),记录和钩子写入都不留。SQLite 上同样情况保存会成功。MongoDB 单机(非副本集)上,带这种钩子的对象每次保存都失败,哪怕什么都没出错,加 retryWrites=false 也没用。
  • 出问题会怎样:只改文字,最坏是说法不准,回滚这个合并即可。
  • 需要你做的:无。

What changes

Docs only. Two places said the before* hook unit's failure rules were "read in the driver's code, not measured"; both now state the measurement:

  • content/docs/automation/hooks.mdx (After hooks run inside the unit of work): the MongoDB standalone outcome, and the failed-statement rule widened from PostgreSQL alone to PostgreSQL and a MongoDB replica set, with the exact error each answers, the retry outcome and the SQLite contrast. The "not yet measured; tracked in review follow-ups of PR #34503 #34563" pointer is removed.
  • packages/objectql/CHANGELOG.md, the released a8e09bb entry (18.6): the two "Inside the new unit" bullets (MongoDB, PostgreSQL) amended in place, as AGENTS.md's Documentation Guardrails row for packages/*/CHANGELOG.md prescribes for a factual error in a released entry (a dedicated docs-only PR, never an erratum in a later entry).

Why

The card's Done-when: both cells measured, linked on the card, and the docs say exactly what was measured. The comment's N5 cell (replica set) is measured too.

Verification

Measured with a throwaway vitest probe (not committed) in packages/runtime: a real ObjectQL over a real SqlDriver / MongoDBDriver, bindHooksToEngine with one metadata-bound beforeInsert hook on zz_case whose ctx.api insert into zz_note hits a unique constraint on a pre-seeded value. Tree: objectstack-ai/objectstack origin/main 57ab087. Servers: PostgreSQL 16.15, MongoDB 8.0.38 standalone and single-node replica set (rs0), SQLite (better-sqlite3) as the contrast.

Path SQLite PostgreSQL 16.15 MongoDB 8.0 replica set MongoDB 8.0 standalone
control: hook writes a valid row stored, both rows stored, both rows stored, both rows refused: "does not support retryable writes", nothing stored
hook body catches the failure stored, side write absent refused 25P02, nothing stored refused code 251 "Transaction … has been aborted", nothing stored refused (same message as control)
onError: 'log' stored ([hook] handler failed (onError=log; suppressing)) refused 25P02, nothing stored refused 251, nothing stored refused (same)
retryPolicy {maxRetries: 2}, 2nd attempt writes a valid row stored after 2 attempts, retry row kept refused 25P02; both retries answered 25P02; nothing stored refused 251; both retries answered 251; nothing stored refused (same)
retryPolicy + onError: 'log' stored after 2 attempts refused 25P02, nothing stored refused 251, nothing stored refused (same)
  • On PostgreSQL the hook saw DuplicateRecordError (DUPLICATE_RECORD, 409, cause SQLSTATE 23505); the outer write's error is the raw driver error (code: '25P02', no status), not an ADR-0112 refusal.
  • The standalone row was re-run with retryWrites=false on the connection string: the same message on all five paths. A write to an object with no such hook (the seed insert, and a mongosh insert) succeeds on the same server.
  • Raw results (one JSON line per cell × path) and the probe are in the project thread's files; the card carries the table.
  • Gates run locally: check:doc-authoring, check:doc-anchors, check:docs-transcript-drift, check:pm-skill-id-lint: all green.

Not in this PR, for the seat: skills/objectstack-data/references/data-hooks.md:60 and its eval hooks-security-seeds-datasources.json:317 still say "MongoDB needs a replica set (read in code, not measured)" (Tier H, its own card); content/docs/releases/v18/18-6.mdx:411 is release-owned and names the failed-statement rule for PostgreSQL only.

Clause-②: no
Metadata-protocol: none

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic. (not touched)
  • 2. Every name I added uses the casing for its kind. (none added)
  • 3. No formatter ran; pnpm lint passes. (docs only; no lintable source changed)
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset: nothing publishes from this diff (skip-changeset).
  • 6. packages/spec touched: not touched.
  • 7. No hand edits to packages/*/CHANGELOG.md: deliberately edited. This is the dedicated docs-only amendment of a released entry that AGENTS.md's Documentation Guardrails row prescribes.
  • 8. Title, body and comments are in English (the 维护者速读 block is the maintainer's Chinese summary).
  • The Before Submitting list in CONTRIBUTING.md is done.

🤖 Generated with Claude Code

https://claude.ai/code/session_01L6bhgWfqiK4KtAFo9PN4Xr


Generated by Claude Code

…ent in a before* hook's unit

Measured on PostgreSQL 16.15, a MongoDB 8.0.38 replica set and a MongoDB
8.0.38 standalone server (card #34563), with a beforeInsert hook whose
ctx.api insert hits a unique constraint:

- PostgreSQL and a MongoDB replica set refuse the outer write when the hook
  body catches the error, when onError: 'log' swallows it, and when
  retryPolicy re-runs it (every retry is refused too). The answer is the
  database's own error (25P02 on PostgreSQL, code 251 on MongoDB); neither
  the row nor the hook's writes are stored. SQLite lets the write through.
- A MongoDB standalone server refuses every write on such an object, even
  when nothing in the write fails, and retryWrites=false does not change it.

hooks.mdx and the released 18.6 objectql CHANGELOG entry said "read in the
driver's code, not measured"; both now say what was measured.

Claude-Session: https://claude.ai/code/session_01L6bhgWfqiK4KtAFo9PN4Xr
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet objectstack-fleet Bot added documentation Improvements or additions to documentation skip-changeset PR has no user-facing published change; bypasses the changeset gate labels Nov 27, 2026
@objectstack-fleet objectstack-fleet Bot mentioned this pull request Nov 27, 2026
2 tasks
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

⚠️ 1 changed file(s) yielded no anchor (packages/objectql/CHANGELOG.md), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files. Nothing else in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 1 changed package(s)).

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/objectql/CHANGELOG.md) — pages documenting those are invisible to this run
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 21 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 57ab08760c7ffd506454864b22c0ce7d9a614164 → packageMentionDocs.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA

席位核对 — ACCEPT · head 5c0e0ef · card #34563 · area s2-data · 2026-11-27T14:52Z

L1 checklist (no review face on this file list: this record is the review of record)

  • Shape and checks. All checks green on the head, expected skips only; docs only (content/docs/automation/hooks.mdx, an in-place fix of a published packages/objectql/CHANGELOG.md entry), 34 changed lines, not governed; skip-changeset accepted by Check Changeset.
  • The docs say what was measured. The card's measurement comments carry the probe's raw results for every cell: PostgreSQL 16 refuses the outer write with 25P02 on the caught, onError: 'log', retryPolicy and retry-plus-log paths, storing neither the row nor the hook's write; a MongoDB 8.0 replica set refuses with code 251 the same way; a MongoDB standalone refuses every write on the hooked object, even a valid one, with the driver's retryable-writes message, also with retryWrites=false; the unhooked control object's write is stored on every standalone run; SQLite lets the write through. Each sentence of the new hooks.mdx paragraph and of the corrected CHANGELOG lines matches one of these readings; the "not measured" wording and the pointer to this card are gone.
  • Left out, rightly. content/docs/releases/v18/18-6.mdx is release-owned and untouched. The skills page and eval case that still say "not measured" are skills: objectstack-data says a MongoDB before* unit needs a replica set "read in code, not measured"; #34563 measured it #37992 (Tier H); the misleading standalone refusal is MongoDB standalone: a write on an object with a metadata before* hook is refused with a driver hint (retryWrites=false) that does not fix it, and nothing says so at boot #37991.
  • Declarations. Clause-②: no, Metadata-protocol: none. Fixes #34563 is right: S1, N3 and N5 are all measured.

Tier: S. Landing: ready and auto-merge in this stroke.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 27, 2026 14:52
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 27, 2026
Merged via the queue into main with commit 77b6706 Nov 27, 2026
66 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-izae00 branch November 27, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/s skip-changeset PR has no user-facing published change; bypasses the changeset gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

review follow-ups of PR #34503

2 participants