Repository navigation
Commit e00374a
domain:server#2 · os-sales · session_01L6bhgUCizoYWQVJWjhdR6F
<!-- claude-projects-attribution: {"github_login":"os-sales"} -->
_Requested by **Sales** · [project
thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuPMZ8BHWtPf6nBTp51qSM64)_
Fixes #27444
Clause-②: no
Metadata-protocol: none
Skills-docs: none — no file under `skills/**` describes what a draft's
`_diagnostics` carries; the namespace-prefix rule itself is unchanged.
## 维护者速读
- 改了什么:对象草稿的读取诊断(`_diagnostics`)现在会带上包命名空间前缀的拒绝项
`NAMESPACE_PREFIX`,与"全部发布"拒绝时的代码和原话一致。
- 为什么改:之前草稿缺前缀时一直显示"有效",直到发布整批时才被拒、连同其它草稿一起回滚,作者在编辑处看不到问题。
- 风险与回滚:只读诊断多一条错误;草稿保存、发布行为都不变。回滚即还原 `protocol-authoring-gate.ts`
的这一处调用。
-
先看:`packages/metadata-protocol/src/protocol-authoring-gate.ts`(`draftPublishVerdict`
末尾新增的前缀判定)、`protocol.ts`(宿主接线一行)、`protocol.draft-publish-verdict.test.ts`(新增两例)。
- 两分钟验证:`pnpm --filter @objectstack/metadata-protocol exec vitest run
src/protocol.draft-publish-verdict.test.ts`,预期 17/17 通过。
- 需要你做的:无,席位落地。
## What changes
- `draftPublishVerdict` (the draft read's publish verdict, folded into
`_diagnostics` by `withPublishVerdict`) now asks, for an `object` draft,
`objectNamespacePrefixViolation` — the one judge the publish pre-flight
(`publishPackageDrafts`), the per-item publish
(`promoteDraftForPublish`) and the direct publish-mode save already ask.
One check, not a copy: the host is handed the class's own method
(`protocol.ts`, host wiring only).
- It judges against the package the draft is staged into (the draft
row's `package_id`, the package "Publish all" promotes it under and
passes as `request.packageId`). A draft bound to no package, or to a
package that declares no namespace, gets nothing — the judge's own skip.
- Finding shape: one `errors[]` entry with `code: 'NAMESPACE_PREFIX'`,
`path: 'name'`, and `message` = the exact sentence publish-drafts
refuses with (`Object 'qa_formula_pkg_r2' is missing the package
namespace prefix. Rename it to 'r2_qa_formula_pkg_r2' (namespace =
'r2').`); `valid: false`. It is listed before the gate's own issues, the
order the batch pre-flight reports it in.
- Unchanged: the draft save is still ungated (ADR-0129 D2, #4463 D1) and
answers 200 `state: "draft"`; publish-drafts and the per-item publish
refuse exactly as before.
## Tests
Two cases in
`packages/metadata-protocol/src/protocol.draft-publish-verdict.test.ts`,
through the real save, draft read and publish-drafts doors (the #26707
harness):
- an unprefixed object draft in a namespaced package saves 200 `state:
draft`; publish-drafts refuses it `outcome: refused` /
`NAMESPACE_PREFIX`; its draft read is `valid: false` and its
`NAMESPACE_PREFIX` entry's message equals the publish-drafts `error`
string, compared in the same test;
- control: a prefixed object draft in the same package reads `{ valid:
true }` and publishes.
Red before the fix (`expected true to be false` on `diagnostics.valid`,
1 failed / 16 passed); green after.
<details><summary>Ablation (scripts/ablation-replace.mjs)</summary>
Mutation: the new call `?
this.objectNamespacePrefixViolation(draft.name, draft.packageId)`
replaced with `? null` in `protocol-authoring-gate.ts`. The test imports
`./protocol.js` from `src/` (relative), so no `dist/` hop is involved.
```
ablation-replace: ok mutation landed: anchor 1 -> 0, blob c477eab -> ad467a0d1c65
× saves as a draft, and its read carries the NAMESPACE_PREFIX refusal publish-drafts gives 16ms
AssertionError: expected true to be false // Object.is equality
Tests 1 failed | 16 passed (17)
ablation-replace: ok restored: blob == HEAD (c477eab) and `git diff HEAD` is empty
```
</details>
## Acceptance notes
- The per-item publish skips sealed managed content before asking the
prefix judge; the draft verdict follows the batch pre-flight instead,
which has no such skip. Not measured whether a draft of a sealed managed
object can exist at all; noted, not filed.
- No UI change in this PR: the entry rides the same
`_diagnostics.errors` the #26707 findings already ride.
## Verification
Run on `dda53adf` (after merging `origin/main` once):
<details><summary>Local gates</summary>
- `pnpm --filter '@objectstack/metadata-protocol^...' build` :: exit 0
- `pnpm --filter @objectstack/metadata-protocol typecheck` :: exit 0
- `pnpm --filter @objectstack/metadata-protocol test` :: exit 0 — Test
Files 280 passed, 4 skipped (284); Tests 21804 passed, 26 skipped
(21830)
- `eslint --no-inline-config packages/metadata-protocol` :: exit 0
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`: 61 derived; 60 exit 0. `pnpm
check:lean-entry-closure` first exited 3 (objectql `dist/` absent),
re-run after `pnpm --filter @objectstack/objectql build` :: exit 0.
`pnpm check:dual-build-cjs-loads` :: exit 3 — NOT MEASURED, PREREQUISITE
NOT MET (needs every package's `dist/`; CI's `Lint & Repo Gates` runs
it).
- `--ran` reconciliation: 61 derived, 60 run, 1 NOT-MEASURED (the one
above), 0 UNRUN.
- Open PRs on the changed files: none of the 16 open PRs touches them,
so no `merge-tree` probe applies.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L6bhgUCizoYWQVJWjhdR6F)_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01L6bhgUCizoYWQVJWjhdR6F
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 86aaff3 commit e00374a
4 files changed
Lines changed: 92 additions & 2 deletions
File tree
- .changeset
- packages/metadata-protocol/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| |||
461 | 462 | | |
462 | 463 | | |
463 | 464 | | |
464 | | - | |
| 465 | + | |
465 | 466 | | |
466 | 467 | | |
467 | 468 | | |
| |||
490 | 491 | | |
491 | 492 | | |
492 | 493 | | |
493 | | - | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
494 | 512 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
464 | 464 | | |
465 | 465 | | |
466 | 466 | | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
467 | 522 | | |
468 | 523 | | |
469 | 524 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7218 | 7218 | | |
7219 | 7219 | | |
7220 | 7220 | | |
| 7221 | + | |
| 7222 | + | |
| 7223 | + | |
| 7224 | + | |
| 7225 | + | |
7221 | 7226 | | |
7222 | 7227 | | |
7223 | 7228 | | |
| |||
7232 | 7237 | | |
7233 | 7238 | | |
7234 | 7239 | | |
| 7240 | + | |
7235 | 7241 | | |
7236 | 7242 | | |
7237 | 7243 | | |
| |||
0 commit comments