pkg/posta: add Kind field to ActorDoc, KeyFile reader, MemoryStore #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What to build
Three small additions to
pkg/postathat unblock the /feedback room work in posta-web and the cal migration.1.
Kindfield onActorDoc. SPEC.md §5.2.2 listskindas an optional display field, but the Go struct inpkg/posta/actor.gois missing it. AddKind string \json:"kind,omitempty"`and a max-64-char validation inDecodeActorDoc. Optional on the wire; conventional values include"person","room","agent"`.2.
KeyFilereader. Liftposta-server/internal/keys/keys.goup topkg/postaso both posta-server and posta-web can share it. Surface:Load(path) (*KeyFile, error),(*KeyFile).Current() *Key, and aSign(data []byte) ([]byte, error)convenience method. Read-only (generation stays in the CLI).3.
MemoryStore. New in-memoryMessageStoreimpl.NewMemoryStore(ttl time.Duration) MessageStore. Internal map of(sender, id) → time.Time; sweep entries older thanttlon eachStoreInbound. Returns*Error{ErrDuplicateID}for repeats. Primarily for embedders that don't need persistence (cal-style responders); also useful for tests.Acceptance criteria
ActorDoc.Kindround-trips through encode/decode; omitted from JSON when empty; rejected when >64 charsKeyFile.Loadparses the existing posta-serverkeys.jsonformat;Current()returns the most-recent key bycreatedAtKeyFile.Signproduces signatures verifiable viaposta.Verifyagainst the corresponding public keyMemoryStore.StoreInboundreturns*Error{ErrDuplicateID}on a repeat(sender, id)within the TTL window; allows the same id after TTL elapsesposta-server/internal/keysis updated to import frompkg/posta(or marked deprecated with a follow-up)Blocked by
None - can start immediately.