-
Notifications
You must be signed in to change notification settings - Fork 0
feat: provide a TableTheory-backed FaceTheory ISR MetaStore (so FaceTheory can drop DynamoDbIsrMetaStore) #72
Description
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.mddocs/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, ... })ORcreateFaceTheoryIsrMetaStore(...)
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
LeaseManagerforLOCKrows. - Use
TheorydbClient.transactWrite()for the “publish META + release LOCK” atomic step (Recipe A in the docs). - Map FaceTheory’s
cacheKeyto TableTheory’s pk; use sk valuesMETAandLOCKas 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
LeaseManagertests). - 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.