Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .changeset/25634-pinyin-reconcile-off-readiness.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
'@objectstack/plugin-pinyin-search': patch
---

fix(plugin-pinyin-search): the boot companion pass no longer holds readiness, and an unchanged restart reads no rows

Clause-②: yes
Metadata-protocol: none

Before this change, `PinyinSearchPlugin` awaited a full walk of every row of every object that carries the `__search` companion inside `kernel:bootstrapped`. The kernel awaits that hook before `kernel:listening`, so the HTTP server opened only after the largest such table had been read. Every restart paid the same walk again, even when nothing had changed. In production, 6.7 M `sys_inbox_message` rows took about 4 min 50 s.

Now:

- The pass starts at `kernel:bootstrapped` and runs after readiness. Writes made through ObjectQL meanwhile are stamped by the companion hooks, as before. A failure is logged at `warn`. Plugin `destroy()` stops the pass between pages.
- When a walk of an object completes, the pass records it in one `sys_migration` receipt row (id `pinyin-search-companion`, `blocking: 0`, `verified_at: null`). A later boot reads only the rows written since that walk that still have no companion. On an unchanged table that is one query that returns no rows. A changed display field, or a kernel without `sys_migration`, falls back to the full walk.
- `rebuildSearchCompanion()` (`force: true`) still walks every row. Use it after an import that bypasses hooks and back-dates `updated_at`.
- `CompanionBackfillResult` gains `pages`, `CompanionBackfillOptions` gains `signal`, and `PinyinSearchPlugin` gains `whenReconciled()`, which resolves when the boot pass ends.

What to do: nothing. The first boot after upgrading walks each companion-bearing object once more, after readiness. Later boots read only what changed.
28 changes: 14 additions & 14 deletions content/docs/permissions/tenant-audit-census.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ are reported as `undecidable` rather than assumed either way.

The same holds twice over for the context. An options argument spelled as a
literal can be read; one spelled `options`, `{ ...opts }`, or handed through a
forwarding shim cannot, and **51 of the 239 sites are spelled that way**. A
forwarding shim cannot, and **51 of the 240 sites are spelled that way**. A
context resolved from an inline literal or a local `const` can be tested for
`isSystem`; one arriving from a helper call cannot.

Expand Down Expand Up @@ -197,10 +197,10 @@ reproduce them. Where it disagrees, it disagrees on the page:

| carried figure | where it survives | this census |
| :--- | :--- | ---: |
| 175 write call sites | quoted in the merged changeset | **239** |
| 175 write call sites | quoted in the merged changeset | **240** |
| 24 carrying no tenant context | quoted in the merged changeset | **2** provable and tenancy-enabled; **29** more whose options argument is unreadable |
| 127 of 175 statically decidable, 48 runtime-parameter-name sites | restated on the `isSystem`-scoping card | **163 of 239** decidable, **76** undecidable |
| 135 (77%) silenced by the `isSystem` guard before the posture gate | the lost issue body — **no surviving corroboration** | **not reproduced**: 136 decidably elevated, 0 decidably not, 95 undecidable |
| 127 of 175 statically decidable, 48 runtime-parameter-name sites | restated on the `isSystem`-scoping card | **163 of 240** decidable, **77** undecidable |
| 135 (77%) silenced by the `isSystem` guard before the posture gate | the lost issue body — **no surviving corroboration** | **not reproduced**: 137 decidably elevated, 0 decidably not, 95 undecidable |
| 141 and 132, two independent re-derivations | the card that filed this work | — |

**The differences are not reconciled, and deliberately so.** The old census's
Expand All @@ -217,11 +217,11 @@ would report a smaller number and would not say so.

The fourth row is the one worth flagging to anyone citing it. **The 135 / 77%
figure has no surviving corroboration anywhere in the tree.** This census reads
136 of 239 (57%) as decidably elevated, with 95 more whose elevation is a
137 of 240 (57%) as decidably elevated, with 95 more whose elevation is a
run-time fact — so the claim is neither confirmed nor refuted, and the honest
answer is that a static reading cannot settle it.

⇒ **Cite `2 / 239`, and say what it is**: the sites whose options argument was
⇒ **Cite `2 / 240`, and say what it is**: the sites whose options argument was
READ and holds no tenant context, against a decidably tenancy-enabled object.
That is the control's provable yield surface. ⛔ Do not cite it as "the sites
without tenant context" — **29 further sites** have an options argument this
Expand All @@ -233,31 +233,31 @@ cannot read, and they are neither in nor out.

| what | count |
| :--- | ---: |
| write call sites on the application surface | **239** |
| write call sites on the application surface | **240** |
| …whose object name is statically decidable | 163 |
| …whose object name is chosen at run time | 76 |
| …whose object name is chosen at run time | 77 |
| …against an object with tenancy ENABLED | 162 |
| …against an object that declares tenancy off | 1 |
| threading a tenant context | 180 |
| threading a tenant context | 181 |
| PROVABLY carrying none (options read, no context key) | **8** |
| …of those, against a decidably tenancy-enabled object | **2** |
| options argument UNREADABLE — may or may not carry one | 51 |
| …of those, against a decidably tenancy-enabled object | 29 |
| threading a decidably ELEVATED (`isSystem`) context | 136 |
| threading a decidably ELEVATED (`isSystem`) context | 137 |
| threading a context that is decidably NOT elevated | 0 |
| threading a context whose elevation is a run-time fact | 95 |

| how the instrument reached the site | count |
| :--- | ---: |
| receiver carried a readable engine type | 184 |
| receiver carried a readable engine type | 185 |
| receiver erased, placed by the object NAME | 45 |
| receiver erased, placed by an `object: string` PARAMETER | 5 |
| receiver erased, placed by an `UNTYPED_RECEIVERS` row | 5 |

| object name spelled inline | 112 |
| object name spelled through a `const` | 51 |
| object name is an `object: string` parameter | 7 |
| object name is some other run-time expression | 69 |
| object name is some other run-time expression | 70 |

### Subtractions the census could NOT defend — enforced

Expand Down Expand Up @@ -307,11 +307,11 @@ holds still. They are required to be HERE and to say WHEN they were true;
their values are not compared. The reasoning, and the measurement behind it,
are in `scripts/check-tenant-audit-census.mjs`.

Measured on 2026-10-24 at `28b6d27e7`.
Measured on 2026-10-25 at `ca3ca05b0`.

| corpus scale (not enforced) | count |
| :--- | ---: |
| tracked non-test sources scanned | 767 |
| tracked non-test sources scanned | 768 |
| engine-shaped types recognised | 87 |
| declared objects in the registry | 117 |
| same-named calls subtracted as non-engine | 176 |
Expand Down
13 changes: 7 additions & 6 deletions docs/audits/2026-08-tenant-audit-write-call-sites.counts.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ silent, and `node scripts/tenant-audit-census.mjs --write` is the resolution.

| Measure | Value |
|---|---:|
| Write call sites | 239 |
| Write call sites | 240 |
| Object name statically decidable | 163 |
| Object name chosen at run time | 76 |
| Object name chosen at run time | 77 |
| Against a tenancy-enabled object | 162 |
| Against an object declaring tenancy off | 1 |
| Threading a tenant context | 180 |
| Threading a tenant context | 181 |
| Provably carrying none | 8 |
| …and decidably tenancy-enabled | 2 |
| Options argument unreadable | 51 |
| …and decidably tenancy-enabled | 29 |
| Threading a decidably elevated context | 136 |
| Threading a decidably elevated context | 137 |
| Threading a decidably non-elevated context | 0 |
| Threading a context of undecidable elevation | 95 |

Expand Down Expand Up @@ -90,11 +90,11 @@ holds still. They are required to be HERE and to say WHEN they were true;
their values are not compared. The reasoning, and the measurement behind it,
are in `scripts/check-tenant-audit-census.mjs`.

Measured on 2026-10-24 at `28b6d27e7`.
Measured on 2026-10-25 at `ca3ca05b0`.

| corpus scale (not enforced) | count |
| :--- | ---: |
| tracked non-test sources scanned | 767 |
| tracked non-test sources scanned | 768 |
| engine-shaped types recognised | 87 |
| declared objects in the registry | 117 |
| same-named calls subtracted as non-engine | 176 |
Expand Down Expand Up @@ -169,6 +169,7 @@ Measured on 2026-10-24 at `28b6d27e7`.
| `packages/plugins/plugin-email/src/attachment-reclaim.ts` | `update` | `object` | undecidable | elevated | 1 |
| `packages/plugins/plugin-email/src/email-plugin.ts` | `insert` | `object` | undecidable | elevated | 1 |
| `packages/plugins/plugin-email/src/email-plugin.ts` | `update` | `object` | undecidable | elevated | 1 |
| `packages/plugins/plugin-pinyin-search/src/boot-reconcile.ts` | `update` | `DATA_MIGRATION_FLAG_OBJECT` | undecidable | elevated | 1 |
| `packages/plugins/plugin-pinyin-search/src/companion-projection.ts` | `update` | `schema.name` | undecidable | elevated | 1 |
| `packages/plugins/plugin-security/src/auto-org-admin-grant.ts` | `delete` | `object` | undecidable | elevated | 1 |
| `packages/plugins/plugin-security/src/auto-org-admin-grant.ts` | `insert` | `object` | undecidable | elevated | 1 |
Expand Down
3 changes: 3 additions & 0 deletions packages/plugins/plugin-pinyin-search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@
"dependencies": {
"@objectstack/core": "workspace:*",
"@objectstack/objectql": "workspace:*",
"@objectstack/spec": "workspace:*",
"@objectstack/types": "workspace:*",
"pinyin-pro": "^3.29.4"
},
"devDependencies": {
"@objectstack/driver-sql": "workspace:*",
"@objectstack/platform-objects": "workspace:*",
"@types/node": "^26.6.3",
"tsx": "^4.23.15",
"typescript": "^6.0.3",
Expand Down
Loading
Loading