Skip to content

Commit e8106eb

Browse files
committed
fix(runtime): the re-bind puts back the kept function's own holder entry, read off the holder set
Claude-Session: https://claude.ai/code/session_016WV4cz4f7zEQZ2C9GTG382 Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 90423f6 commit e8106eb

1 file changed

Lines changed: 14 additions & 16 deletions

File tree

‎packages/runtime/src/app-artifact-handlers.ts‎

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,6 @@ interface FunctionHoldingEngine {
551551
functionHoldersOf?(name: string): {
552552
readonly packageHolders: readonly string[];
553553
packageItem(packageId: string): { readonly handler: any; readonly packageId?: string; readonly effect?: unknown } | undefined;
554-
platformItem?(): unknown;
555554
};
556555
}
557556

@@ -581,19 +580,19 @@ function hookHandlersOf(groups: readonly HookBindingGroup[], owner: string): str
581580
* [#31700, epic seat ruling R3-B] Only for a name one package holds: two
582581
* namespaces' packages may each hold one function name, and the bare read of
583582
* such a name is refused (409, ADR-0150 D3) and answers no reader, so for it
584-
* `holder`'s own entry is all that is read and put back. [#32907] The same
585-
* for a name the platform (an owner-less registration) holds beside
586-
* `holder`: its bare read is refused too.
587-
*
588-
* [#32907, #32933] The bare slot is read off the holder set, never through
589-
* the bare read: for a name `holder`'s package alone holds, the bare map's
590-
* entry IS that package's holder entry (`registerFunction` stores one entry
591-
* object in both, and the engine puts the holder's entry back in the bare map
592-
* when another holder's last registration leaves). The bare read is a
593-
* resolution, not that slot: it refuses a name the platform holds beside the
594-
* package, which would abort this teardown, and answers nothing for a
595-
* disabled package, which would re-register the kept function under
596-
* `holder`'s spelling only and drop the spelling the slot held.
583+
* `holder`'s own entry is all that is read and put back.
584+
*
585+
* [#32907, #32933] What is put back is `holder`'s package's own holder entry,
586+
* read off the holder set, never through the bare read. For a name that
587+
* package alone holds, that entry IS the bare slot (`registerFunction` stores
588+
* one entry object in both, and the engine puts the holder's entry back in
589+
* the bare map when another holder's last registration leaves). The bare read
590+
* is a resolution, not that slot: it refuses a name the platform (an
591+
* owner-less registration) holds beside the package, which would abort this
592+
* teardown, and answers nothing for a disabled package, which would drop the
593+
* owner spelling the package held the kept function by. Beside the platform,
594+
* the package's entry is put back under its own spelling too; the bare read
595+
* of that name is refused either way.
597596
*/
598597
function releaseMovedFunctions(engine: FunctionHoldingEngine, holder: string, moved: readonly string[], known: Iterable<string>): void {
599598
if (typeof engine.registerFunction !== 'function' || typeof engine.functionHoldersOf !== 'function') return;
@@ -604,8 +603,7 @@ function releaseMovedFunctions(engine: FunctionHoldingEngine, holder: string, mo
604603
if (leaving.has(name)) continue;
605604
const holders = engine.functionHoldersOf(name);
606605
const entry = holders.packageItem(packageId);
607-
const shared = holders.packageHolders.length > 1 || holders.platformItem?.() !== undefined;
608-
if (entry) keep.push({ name, entry, bare: shared ? undefined : entry });
606+
if (entry) keep.push({ name, entry, bare: holders.packageHolders.length > 1 ? undefined : entry });
609607
}
610608
engine.unregisterFunctionsByPackage?.(holder);
611609
for (const { name, entry, bare } of keep) {

0 commit comments

Comments
 (0)