feat(core-shared): add Analyzed brand check to assertFeatureConformance
Mirrors the existing Audited check: when a use case declares analyticsEvents.length > 0 and the bound function lacks the __analyzed brand, assertFeatureConformance throws ConformanceError at boot time. Adds three synthetic conformance tests: passes when brand present + events declared, throws naming Analyzed when events declared + brand missing, passes when events empty + brand absent. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
import type { Container } from "inversify";
|
||||
import type { FeatureManifest } from "./define-feature";
|
||||
import { isInstrumented, isCaptured, isAudited } from "./brand-runtime";
|
||||
import {
|
||||
isInstrumented,
|
||||
isCaptured,
|
||||
isAudited,
|
||||
isAnalyzed,
|
||||
} from "./brand-runtime";
|
||||
import { ConformanceError } from "./conformance-error";
|
||||
import type { BindContext } from "../di/bind-context";
|
||||
|
||||
@@ -58,5 +63,12 @@ export function assertFeatureConformance(
|
||||
);
|
||||
}
|
||||
}
|
||||
if ((useCase.analyticsEvents?.length ?? 0) > 0) {
|
||||
if (!isAnalyzed(bound)) {
|
||||
throw new ConformanceError(
|
||||
`${manifest.name}.${name}: declares analyticsEvents but binding is missing __analyzed brand — was withAnalytics applied at bind time?`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user