Skip to content

Commit 2990c4c

Browse files
committed
docs(metadata): the boot write-back note is its own changeset line; onlyBoundStampAdded is kept
The changeset carries epic ruling 6801410166's one-line note as its own bullet. onlyBoundStampAdded stays: with the source skip in place an ablation of it reds the two round-6 pins that register loadMany's stamped bodies back without the skip, and nothing else, so it still holds for every register of such a body outside the boot pass. The round-6 helper's doc now says it models that register, not the pass. Claude-Session: https://claude.ai/code/session_01Utp6CZu9RRx2o8sFUUpEPU Co-authored-by: Claude <noreply@anthropic.com>
1 parent fefaa51 commit 2990c4c

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

‎.changeset/31699-email-template-names-per-namespace.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ The bare-name one-holder rule (`bare-name-one-holder.ts`) has narrowed for `emai
2626
- The flow `notify` node records the package whose own flow body is armed (`AutomationEngine.flowCallerPackage`, now public) beside its template reference (`template:`, or a template named in the node's literal `payload.template`, which the channels read alike), as the delivery payload's `templateCallerPackageId`; the email and inbox channels hand it to the send. An environment-authored flow, or an environment override of a packaged one, records none; a `templateCallerPackageId` key in the node's literal `payload` is dropped, never forwarded. A delivery row queued before this release carries no such key and sends as before, with no package.
2727

2828
- `MetadataManager`'s in-memory store keeps one slot per `(package, name)` for `email_template` (`PACKAGE_SLOTTED_STORE_TYPES` in `@objectstack/metadata`, now `api`, `agent`, `skill`, `action`, `email_template` and `permission`): two packages' templates of one name both stay in it, `get(type, name, packageId)` answers that package's own (never another package's), and `get` naming no package of a two-holder name refuses `409` naming both (D3), where the second package's item overwrote the first's. The loaders follow the same rules (`DatabaseLoader`, `MemoryLoader`): a save fills `package_id`; a rollback and a delete by name are refused as (5) and (6) state; and their unscoped reads keep every member of every slot (one row per `(package, name, member)`, the canonical locale stored as `bundle_member` NULL), so no locale of any package's bundle is dropped. `MetadataManager.loadMany` and `loadManyKeyed` likewise answer one entry per `(package, name, member)` for an email template, where they answered one per name; `loadMany` reads a row's package from its `package_id` column when the body carries no stamp, and hands such a body on stamped with it (`_packageId`).
29-
- The database loader's save of an email template (`DatabaseLoader.save`) writes the row of the member the body declares, FROM the slot's first row whatever its locale (so a save of `fr-FR` replaced the stored `en-US` body, and a boot's priming pass, which registers every stored member back, did so at every boot) TO that member's own row, inserting it with its `bundle_member` when the slot has none. It never writes over another member's row. A save whose body differs from its row only by a `_packageId` stamp naming the row's own package writes nothing. Every other type stored per `(package, name)` keeps one row per slot. Not a refusal: no write that succeeded before is refused. A boot no longer writes back rows it read from the same loader: the priming pass registers each stored item without saving it into the loader it was read from (`MetadataManager.register`'s `skipSourceLoader`), and an item read from another loader still seeds the database loader.
29+
- The database loader's save of an email template (`DatabaseLoader.save`) writes the row of the member the body declares, FROM the slot's first row whatever its locale (so a save of `fr-FR` replaced the stored `en-US` body, and a boot's priming pass, which registers every stored member back, did so at every boot) TO that member's own row, inserting it with its `bundle_member` when the slot has none. It never writes over another member's row. A save whose body differs from its row only by a `_packageId` stamp naming the row's own package writes nothing. Every other type stored per `(package, name)` keeps one row per slot. Not a refusal: no write that succeeded before is refused.
30+
- A boot no longer writes back rows it read from the same loader: the priming pass registers each stored item without saving it into the loader it was read from (`MetadataManager.register`'s `skipSourceLoader`), and a file-system item still seeds the database loader.
3031

3132
So a package no longer has to rename an email template because a package of another namespace already ships one of that name, and each package's flows keep sending their own.
3233

‎packages/metadata/src/loaders/database-loader.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1842,7 +1842,7 @@ describe('[#31699 R4-A] the save of a bundled type writes its own member\'s row'
18421842
m.registerLoader(new DatabaseLoader({ driver }));
18431843
return m;
18441844
};
1845-
/** `MetadataPlugin._loadFromFileSystem`'s priming pass, over the manager's loaders. */
1845+
/** Each `loadMany` item registered back WITHOUT the R5-A source skip: the pass as it ran before, or any other caller. */
18461846
const prime = async (m: MetadataManager) => {
18471847
for (const item of (await m.loadMany('email_template')) as Array<{ name?: string }>) {
18481848
if (item?.name) await m.register('email_template', item.name, item, { notify: false });

‎packages/metadata/src/loaders/database-loader.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1943,7 +1943,9 @@ function storedBodyUnchanged(row: Record<string, unknown>, type: string, hash: s
19431943
* [#31699 R4-B] Whether `data` is `row`'s stored body plus nothing but a
19441944
* `_packageId` stamp naming the package `row` is already bound to: the stamp
19451945
* `MetadataManager.loadMany` puts on a body its row binds by the `package_id`
1946-
* column alone. Such a save writes nothing new, so it is no change.
1946+
* column alone. Such a save writes nothing new, so it is no change. Kept
1947+
* after R5-A: the boot pass's source skip covers that pass only, not any other
1948+
* register of such a body.
19471949
*/
19481950
function onlyBoundStampAdded(row: Record<string, unknown>, type: string, data: unknown, packageId: string | undefined): boolean {
19491951
if (packageId === undefined || storedRowPackageId(row) !== packageId) return false;

0 commit comments

Comments
 (0)