Skip to content

Commit 532fd27

Browse files
grypezclaude
andcommitted
refactor(kernel-utils): remove unused sheaf revocation API
revokePoint, revokeAll, and getExported are unused in application code — the evm-wallet prototype rebuilds the sheaf wholesale when the grant set changes rather than revoking individual sections. Remove the implementation, the Grant type, the revoked flag in buildSection, and all associated tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 5318a9f commit 532fd27

3 files changed

Lines changed: 2 additions & 187 deletions

File tree

packages/kernel-utils/src/sheaf/sheafify.test.ts

Lines changed: 0 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -516,105 +516,6 @@ describe('sheafify', () => {
516516
expect(await E(wallet).getBalance('alice')).toBe(42);
517517
});
518518

519-
// ---------------------------------------------------------------------------
520-
// Revocation
521-
// ---------------------------------------------------------------------------
522-
523-
it('revokePoint revokes sections covering the point', async () => {
524-
const sections: PresheafSection<{ cost: number }>[] = [
525-
{
526-
exo: makeExo(
527-
'Wallet:0',
528-
M.interface('Wallet:0', {
529-
getBalance: M.call(M.string()).returns(M.number()),
530-
}),
531-
{ getBalance: (_acct: string) => 42 },
532-
) as unknown as Section,
533-
metadata: constant({ cost: 1 }),
534-
},
535-
];
536-
537-
const sheaf = sheafify({ name: 'Wallet', sections });
538-
const wallet = sheaf.getGlobalSection({
539-
async *lift(germs) {
540-
yield germs[0]!;
541-
},
542-
});
543-
544-
expect(await E(wallet).getBalance('alice')).toBe(42);
545-
546-
sheaf.revokePoint('getBalance', 'alice');
547-
548-
// Entire section is revoked, not just the specific point
549-
await expect(E(wallet).getBalance('alice')).rejects.toThrow(
550-
'Section revoked',
551-
);
552-
await expect(E(wallet).getBalance('bob')).rejects.toThrow(
553-
'Section revoked',
554-
);
555-
});
556-
557-
it('revokeAll revokes all sections', async () => {
558-
const sections: PresheafSection<{ cost: number }>[] = [
559-
{
560-
exo: makeExo(
561-
'Wallet:0',
562-
M.interface('Wallet:0', {
563-
getBalance: M.call(M.string()).returns(M.number()),
564-
}),
565-
{ getBalance: (_acct: string) => 42 },
566-
) as unknown as Section,
567-
metadata: constant({ cost: 1 }),
568-
},
569-
];
570-
571-
const sheaf = sheafify({ name: 'Wallet', sections });
572-
const wallet = sheaf.getGlobalSection({
573-
async *lift(germs) {
574-
yield germs[0]!;
575-
},
576-
});
577-
578-
expect(await E(wallet).getBalance('alice')).toBe(42);
579-
580-
sheaf.revokeAll();
581-
582-
await expect(E(wallet).getBalance('alice')).rejects.toThrow(
583-
'Section revoked',
584-
);
585-
});
586-
587-
it('getExported returns union of active section guards', () => {
588-
const sections: PresheafSection<{ cost: number }>[] = [
589-
{
590-
exo: makeExo(
591-
'Wallet:0',
592-
M.interface('Wallet:0', {
593-
getBalance: M.call(M.string()).returns(M.number()),
594-
}),
595-
{ getBalance: (_acct: string) => 42 },
596-
) as unknown as Section,
597-
metadata: constant({ cost: 1 }),
598-
},
599-
];
600-
601-
const sheaf = sheafify({ name: 'Wallet', sections });
602-
603-
// No sections granted yet
604-
expect(sheaf.getExported()).toBeUndefined();
605-
606-
sheaf.getGlobalSection({
607-
async *lift(germs) {
608-
yield germs[0]!;
609-
},
610-
});
611-
612-
const exported = sheaf.getExported();
613-
expect(exported).toBeDefined();
614-
const { methodGuards } = getInterfaceGuardPayload(exported!);
615-
expect(methodGuards).toHaveProperty('getBalance');
616-
});
617-
618519
it('getDiscoverableGlobalSection exposes __getDescription__', async () => {
619520
const schema = {
620521
getBalance: {
@@ -671,31 +572,4 @@ describe('sheafify', () => {
671572
(section as Record<string, unknown>)[GET_DESCRIPTION],
672573
).toBeUndefined();
673574
});
674-
675-
it('getExported excludes revoked sections', () => {
676-
const sections: PresheafSection<{ cost: number }>[] = [
677-
{
678-
exo: makeExo(
679-
'Wallet:0',
680-
M.interface('Wallet:0', {
681-
getBalance: M.call(M.string()).returns(M.number()),
682-
}),
683-
{ getBalance: (_acct: string) => 42 },
684-
) as unknown as Section,
685-
metadata: constant({ cost: 1 }),
686-
},
687-
];
688-
689-
const sheaf = sheafify({ name: 'Wallet', sections });
690-
sheaf.getGlobalSection({
691-
async *lift(germs) {
692-
yield germs[0]!;
693-
},
694-
});
695-
696-
expect(sheaf.getExported()).toBeDefined();
697-
698-
sheaf.revokeAll();
699-
expect(sheaf.getExported()).toBeUndefined();
700-
});
701575
});

packages/kernel-utils/src/sheaf/sheafify.ts

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Sheafify a presheaf into an authority manager.
33
*
44
* `sheafify({ name, sections })` returns a `Sheaf` — an immutable object
5-
* that tracks granted authority and produces revocable dispatch sections.
5+
* that produces dispatch sections over a fixed presheaf.
66
*
77
* Each dispatch through a granted section:
88
* 1. Computes the stalk (getStalk — presheaf sections matching the point)
@@ -28,7 +28,7 @@ import { collectSheafGuard } from './guard.ts';
2828
import type { MethodGuardPayload } from './guard.ts';
2929
import { evaluateMetadata, resolveMetaDataSpec } from './metadata.ts';
3030
import type { ResolvedMetaDataSpec } from './metadata.ts';
31-
import { getStalk, guardCoversPoint } from './stalk.ts';
31+
import { getStalk } from './stalk.ts';
3232
import type {
3333
EvaluatedSection,
3434
Lift,
@@ -178,13 +178,6 @@ const invokeExo = (exo: Section, method: string, args: unknown[]): unknown => {
178178
return fn.call(obj, ...args);
179179
};
180180

181-
type Grant = {
182-
exo: Section;
183-
guard: InterfaceGuard;
184-
revoke: () => void;
185-
isRevoked: () => boolean;
186-
};
187-
188181
type ResolvedSection<M extends Record<string, unknown>> = {
189182
exo: Section;
190183
spec: ResolvedMetaDataSpec<M> | undefined;
@@ -210,8 +203,6 @@ export const sheafify = <
210203
: resolveMetaDataSpec(section.metadata, compartment),
211204
})),
212205
);
213-
const grants: Grant[] = [];
214-
215206
const buildSection = ({
216207
guard,
217208
lift,
@@ -231,16 +222,10 @@ export const sheafify = <
231222
defaultGuards: 'passable',
232223
});
233224

234-
let revoked = false;
235-
236225
const dispatch = async (
237226
method: string,
238227
args: unknown[],
239228
): Promise<unknown> => {
240-
if (revoked) {
241-
throw new Error(`Section revoked: ${name}`);
242-
}
243-
244229
const stalk = getStalk(frozenSections, method, args);
245230
const evaluatedStalk: EvaluatedSection<MetaData>[] = stalk.map(
246231
(section) => ({
@@ -304,15 +289,6 @@ export const sheafify = <
304289
asyncGuard,
305290
)) as unknown as Section;
306291

307-
grants.push({
308-
exo,
309-
guard: resolvedGuard,
310-
revoke: () => {
311-
revoked = true;
312-
},
313-
isRevoked: () => revoked,
314-
});
315-
316292
return exo;
317293
};
318294

@@ -351,39 +327,10 @@ export const sheafify = <
351327
schema: Record<string, MethodSchema>;
352328
}): object => buildSection({ guard: unionGuard(), lift, schema });
353329

354-
const revokePoint = (method: string, ...args: unknown[]): void => {
355-
for (const grant of grants) {
356-
if (!grant.isRevoked() && guardCoversPoint(grant.guard, method, args)) {
357-
grant.revoke();
358-
}
359-
}
360-
};
361-
362-
const getExported = (): InterfaceGuard | undefined => {
363-
const activeExos = grants
364-
.filter((grant) => !grant.isRevoked())
365-
.map((grant) => grant.exo);
366-
if (activeExos.length === 0) {
367-
return undefined;
368-
}
369-
return collectSheafGuard(`${name}:exported`, activeExos);
370-
};
371-
372-
const revokeAll = (): void => {
373-
for (const grant of grants) {
374-
if (!grant.isRevoked()) {
375-
grant.revoke();
376-
}
377-
}
378-
};
379-
380330
return {
381331
getSection,
382332
getDiscoverableSection,
383333
getGlobalSection,
384334
getDiscoverableGlobalSection,
385-
revokePoint,
386-
getExported,
387-
revokeAll,
388335
};
389336
};

packages/kernel-utils/src/sheaf/types.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,4 @@ export type Sheaf<MetaData extends Record<string, unknown>> = {
121121
lift: Lift<MetaData>;
122122
schema: Record<string, MethodSchema>;
123123
}) => object;
124-
/** Revoke every granted section whose guard covers the point (method, ...args). */
125-
revokePoint: (method: string, ...args: unknown[]) => void;
126-
/** Union guard of all active (non-revoked) granted sections, or undefined. */
127-
getExported: () => InterfaceGuard | undefined;
128-
/** Revoke all granted sections. */
129-
revokeAll: () => void;
130124
};

0 commit comments

Comments
 (0)