Internal module guide. This module is now part of
@astrology/western; use the public package README for application setup.
rulebooks module
Western rulebook admission: manifest validation, content-hash integrity and typed technique lookup. Public imports use the package root. See the package specification and task W-13.
Run pnpm --filter @astrology/western build, check, and test. This package imports no
technique, engine or provider implementation, so admission never loads a formula or an ephemeris.
Admission
createWesternRulebookRegistry(bundles) validates every manifest, then verifies that the supplied
technique resources are exactly those the manifest declares:
- the same technique set, with no missing, duplicate or undeclared entry;
- the declared version and variant;
- a payload whose canonical SHA-256 equals the declared hash.
Any mismatch fails with RULEBOOK_INTEGRITY before a handle is served. Admitted handles store a
frozen copy, and identity.hash hashes the manifest, so it covers every technique hash. A duplicate
id@version is refused.
Lookup
resolveWesternRulebook(registry, reference) needs the exact id and version and fails with
UNKNOWN_RULEBOOK; there is no nearby-version fallback.
assertRulebookCompatible(handle, profile) requires both that the profile names this rulebook and
that the manifest lists the profile id@version; otherwise PROFILE_INCOMPATIBLE.
getWesternTechniqueRules<T>(handle, technique, validate) passes the stored payload through the
owning technique’s validator and returns AdmittedRules<T>. A missing technique is
UNKNOWN_RULEBOOK, and the validator’s own failure (for example INVALID_RULES) is preserved. The
payload is never cast to a schema it does not satisfy.
hashTechniqueRules(payload) and verifyRulebookTechniques(manifest, techniques) are exported so a
host can write and check its own manifest with the same canonical hash.
Consumer example
import {
createWesternRulebookRegistry,
getWesternTechniqueRules,
resolveWesternRulebook,
} from './rulebooks/index.js';
const registry = createWesternRulebookRegistry([{ manifest, techniques: bundles }]);
const handle = resolveWesternRulebook(registry, profile.rulebook);
const natal = getWesternTechniqueRules(handle, 'natal', validateNatalRules);
Not implemented here
Technique payload schemas, table contents, profile resolution, feature registration and evaluation.