Skip to content

feat: provide a TableTheory-backed FaceTheory ISR MetaStore (so FaceTheory can drop DynamoDbIsrMetaStore) #72

@aron23

Description

@aron23

Motivation
FaceTheory currently ships a DynamoDB-shaped ISR store (DynamoDbIsrMetaStore + DynamoDbIsrMetaClient) in FaceTheory/ts/src/isr.ts. Even though it doesn’t import the AWS SDK directly, it effectively pushes DynamoDB conditional-write semantics into FaceTheory/app code.

We want a stricter layering rule: all DynamoDB access patterns and conditional expressions live in TableTheory.

Goal
Add a small, first-class helper in TableTheory (TS first) that implements FaceTheory’s ISR metadata + lease/lock operations using TableTheory primitives, so FaceTheory apps don’t implement DynamoDB calls themselves.

References

  • Schema + transaction recipes already exist:
    • docs/facetheory/isr-cache-schema.md
    • docs/facetheory/isr-transaction-recipes.md
  • FaceTheory ISR store interface:
    • FaceTheory/ts/src/isr.ts (IsrMetaStore)

Proposed API (TS)
One of:

  • new FaceTheoryIsrMetaStore({ client: TheorydbClient, tableName, ... }) OR
  • createFaceTheoryIsrMetaStore(...)

Implement methods compatible with FaceTheory’s IsrMetaStore shape:

  • get(cacheKey)
  • tryAcquireLease({ cacheKey, leaseOwner, nowMs, leaseDurationMs, ... })
  • commitGeneration({ cacheKey, leaseOwner, leaseToken, htmlPointer, generatedAt, ... })
  • releaseLease({ cacheKey, leaseOwner, leaseToken }) (best-effort)

Implementation sketch

  • Use the existing LeaseManager for LOCK rows.
  • Use TheorydbClient.transactWrite() for the “publish META + release LOCK” atomic step (Recipe A in the docs).
  • Map FaceTheory’s cacheKey to TableTheory’s pk; use sk values META and LOCK as in the docs.

Acceptance Criteria

  • TableTheory exports a supported TS helper for FaceTheory ISR metadata/leases.
  • Unit + DynamoDB Local integration tests exist (similar rigor to LeaseManager tests).
  • A short doc section shows how a FaceTheory app wires this store, including env var FACETHEORY_CACHE_TABLE_NAME.

Follow-up (FaceTheory)
Once this exists, FaceTheory can deprecate/remove DynamoDbIsrMetaStore / DynamoDbIsrMetaClient and point users to the TableTheory implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions