invariant.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /**
  2. * Package-owned invariant companion for `@deepseek-ai/dsh-session-projection-cache`.
  3. * @module @deepseek-ai/dsh-session-projection-cache/invariant
  4. */
  5. /* jscpd:ignore-start */
  6. import type { Context } from '@deepseek-ai/cordis'
  7. import type { InvariantInstaller } from '@deepseek-ai/dsh-invariants'
  8. const PACKAGE_NAME = '@deepseek-ai/dsh-session-projection-cache'
  9. /** Cordis companion plugin name. */
  10. export const name = 'session-projection-cache-invariant'
  11. /** Service required before the companion can reserve package ownership. */
  12. export const inject = ['invariants']
  13. /**
  14. * No runtime invariant: the cache's correctness relation (a stored row equals
  15. * the registry fold at its `seq` watermark) is only checkable by re-running the
  16. * fold over the persisted log — duplicating the implementation rather than
  17. * detecting drift — and its staleness is by design (fail-soft writes). The
  18. * durable boundary is already schema-validated by the storage-domain layer
  19. * on every reopen, and the read ladder's version/watermark guards are proven
  20. * by the package spec.
  21. */
  22. const install: InvariantInstaller = () => {}
  23. /**
  24. * Register this package's invariant companion.
  25. * @param ctx - Cordis context carrying the invariant service.
  26. * @returns the installed registration's disposer after setup succeeds.
  27. */
  28. export const apply = (ctx: Context): Promise<() => void> =>
  29. Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install))
  30. /* jscpd:ignore-end */