Skip to content

Commit df287e6

Browse files
claude[bot]claude
andauthored
refactor(plugin-sharing): put the shared logger contract on the precise signature (#11236)
Spell OptionalSharingLogger's members as a string message plus an optional Record of string keys to any values, and absorb sharing-rule-provenance.ts onto the shared type instead of a seventh local MinimalLogger. The shared shape shipped with the loose (msg: any, ...rest: any[]) spelling inherited from the two byte-identical declarations it replaced. That spelling documents nothing and catches nothing -- the same complaint this card levels at bare Function -- so the third module was unified onto the strict spelling it already declared, rather than the reverse. Caller cost is zero: every caller passes ctx.logger as any, or undefined. All 12 in-module call sites already pass exactly (string, object?). check:optional-error-sink membership is unchanged: 37 / 12 / 23 / 2, still 2 baselined. record-orphan-cleanup.ts's bare-Function members stay untouched -- tightening them moves that gate's population and remains open on #10692. Part of #10692 Claude-Session: https://claude.ai/code/session_01APWX2AwT3a4xDcjPCe8bk4 Co-authored-by: Claude <noreply@anthropic.com>
1 parent e4a71d4 commit df287e6

3 files changed

Lines changed: 62 additions & 15 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
"@objectstack/plugin-sharing": patch
3+
---
4+
5+
Put `plugin-sharing`'s shared `{ info?, warn? }` logger contract on the precise
6+
member signature and absorb the third module onto it (#10692). Internal types
7+
only — no local `MinimalLogger` was ever exported, so there is no published
8+
surface change and no runtime behaviour change.
9+
10+
`OptionalSharingLogger` in `logger-shapes.ts` shipped with the loose spelling
11+
`(msg: any, ...rest: any[]) => void`, inherited from the two byte-identical
12+
declarations it replaced. Its members are now spelled
13+
`(msg: string, meta?: Record<string, any>) => void`, and
14+
`sharing-rule-provenance.ts` — which already declared exactly that stricter
15+
signature under its own local `MinimalLogger` — now imports the shared type
16+
instead of declaring a seventh copy.
17+
18+
That direction was chosen deliberately over unifying on the loose spelling.
19+
`(msg: any, ...rest: any[])` documents nothing and catches nothing, which is the
20+
same complaint this card levels at bare `Function`; folding the stricter module
21+
onto it would have deleted real checking to buy uniformity. Taking the precise
22+
spelling instead tightens the two modules that were already on the shared type,
23+
and buys arity and type checking at all 12 in-module call sites — every one of
24+
which already passes exactly a string message plus an optional metadata object.
25+
26+
Caller cost is zero: every caller of the three affected binders passes
27+
`ctx.logger as any` or `undefined`, so no caller constrains the signature.
28+
29+
`check:optional-error-sink` (#9754) membership is unchanged and was verified
30+
before and after: 37 sinks declare `error`, 12 required, 23 optional beside a
31+
required `warn`, 2 permit silence, 2 baselined. The shared shape still declares
32+
no `error` and must not grow one — that would enrol every module using it into
33+
that gate's population, which is a contract decision for the #10556 family
34+
rather than a side effect of de-duplication.
35+
36+
`record-orphan-cleanup.ts`'s bare-`Function` members are deliberately untouched:
37+
tightening them requires tightening two publicly exported option types first,
38+
which moves that gate's population and remains open on #10692.

packages/plugins/plugin-sharing/src/logger-shapes.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,24 @@
1919
* between this shape and a module that still declares its own, the diagnostic
2020
* names two different types instead of the same one twice.
2121
*
22+
* ## Why the members are spelled precisely, and must stay that way
23+
*
24+
* The members take a `string` message and an optional `Record` of string keys
25+
* to `any` values as structured metadata — NOT `(msg: any, ...rest: any[])`.
26+
*
27+
* This shape first shipped with that loose spelling, carried over from the two
28+
* byte-identical declarations it replaced. `sharing-rule-provenance.ts` was
29+
* left out of it precisely BECAUSE its own declaration was stricter, and
30+
* folding it onto the loose spelling would have deleted real checking. That
31+
* open question was ruled the other way (#10692): the shared contract takes the
32+
* PRECISE spelling and the third module joins it.
33+
*
34+
* ⛔ Do not loosen these members back to `any` to make some new caller fit.
35+
* `(msg: any, ...rest: any[])` documents nothing and catches nothing — the same
36+
* complaint this package's card levels at bare `Function`. All call sites on
37+
* this shape already pass exactly a message plus an optional metadata object;
38+
* a caller that does not fit is the thing to look at, not this declaration.
39+
*
2240
* ## ⛔ Why this shape declares no `error`, and must not grow one
2341
*
2442
* `check:optional-error-sink` (#9754) draws its population STRUCTURALLY: a sink
@@ -47,15 +65,9 @@
4765
* `SharingServiceOptions['logger']` and `ShareLinkServiceOptions['logger']` —
4866
* are themselves spelled with bare `Function`. Tightening it requires
4967
* tightening those producers first, which is a gate-population change, not a
50-
* refactor. Recorded on #10692 rather than done quietly here.
51-
* - `sharing-rule-provenance.ts` — `{ info?, warn? }` by OPTIONALITY but with a
52-
* stricter member signature, `(msg: string, meta?: Record<string, any>)`.
53-
* Folding it onto the `(msg: any, ...rest: any[])` spelling below would DELETE
54-
* real checking at its call sites; folding the others onto ITS spelling would
55-
* tighten two modules. Either direction changes meaning, so neither is a
56-
* de-duplication — see #10692 for the open contract question.
68+
* refactor. It stays open on #10692 rather than being done quietly here.
5769
*/
5870
export interface OptionalSharingLogger {
59-
info?: (msg: any, ...rest: any[]) => void;
60-
warn?: (msg: any, ...rest: any[]) => void;
71+
info?: (msg: string, meta?: Record<string, any>) => void;
72+
warn?: (msg: string, meta?: Record<string, any>) => void;
6173
}

packages/plugins/plugin-sharing/src/sharing-rule-provenance.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,19 @@
2626
* `input.id`) are not stamped — every rule-editing UI path updates by id.
2727
*/
2828

29+
import type { OptionalSharingLogger } from './logger-shapes.js';
30+
2931
interface MinimalEngine {
3032
find(object: string, opts?: any): Promise<any[]>;
3133
registerHook(event: string, handler: (ctx: any) => any, options?: Record<string, any>): void;
3234
unregisterHooksByPackage(packageId: string): number;
3335
}
3436

35-
interface MinimalLogger {
36-
info?: (msg: string, meta?: Record<string, any>) => void;
37-
warn?: (msg: string, meta?: Record<string, any>) => void;
38-
}
39-
4037
export const SHARING_RULE_PROVENANCE_PACKAGE = 'plugin-sharing:rule-provenance';
4138

4239
const SYSTEM_CTX = { isSystem: true, positions: [], permissions: [] } as const;
4340

44-
export function bindRuleProvenanceStamp(engine: MinimalEngine, logger?: MinimalLogger): void {
41+
export function bindRuleProvenanceStamp(engine: MinimalEngine, logger?: OptionalSharingLogger): void {
4542
engine.registerHook(
4643
'beforeUpdate',
4744
async (ctx: any) => {

0 commit comments

Comments
 (0)