action

package
v0.25.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package action computes the deterministic identifiers Part A's structural and LLM extraction paths both use for the actions table — most notably identity_key (spec §5.5), whose stability across re-extraction is what lets a user's done/ignored decision (action_status) survive a rerun.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildIdentityKey

func BuildIdentityKey(threadKey, kind, counterpart, summary string) string

BuildIdentityKey computes the deterministic identity_key for an action (spec §5.5). counterpart is a thread-scoped STRING identity (contact_name / email address / phone hash / entity normalized_name) — never entities.id: identity_key must be computable before entity dedup runs in the same worker tick, and must stay stable even if a future entity-merge feature renumbers entities.id (this project's own SMS source_id rekeying lesson: derived identifiers must not depend on values that change for reasons unrelated to the real-world event).

Format mirrors internal/collector/smsmap.shortHash's convention: 16 hex chars (first 8 bytes of SHA-256), prefixed "action:" for readability.

func CounterpartDisplay

func CounterpartDisplay(doc *model.Document) (name string, entityType model.EntityType, ok bool)

CounterpartDisplay returns the label a HUMAN uses for the other side of a conversation, together with the entities.type it should be filed under.

This is deliberately NOT the same string as CounterpartIdentity: that one feeds identity_key and must therefore stay byte-stable forever (it is the raw From header, the contact_name, or a phone-number hash). This one is rendered on an action card and stored in entities.name, so it prefers the display name over the address and never returns a hash — a hash is not something a user can act on.

ok=false means "there is no label worth registering": an unnamed thread whose only handle is a hashed number, or a source type that is not a conversation. Callers must leave counterpart_entity_id NULL in that case rather than inventing a placeholder entity — one shared "unknown" row that every unnamed thread points at would merge unrelated callers in the entity graph and make the /actions counterpart filter lie.

Privacy note for the number fallback: metadata carries "number" only when phone-number hashing is disabled (issue #164). With hashing enabled the key is absent, so this function returns ok=false and no raw number ever reaches the entities table — the policy flag is respected transitively, without this package needing to read config.

func CounterpartIdentity

func CounterpartIdentity(doc *model.Document, isUserAddress func(string) bool) (identity string, ok bool)

CounterpartIdentity derives the thread-scoped counterpart identity string used for kind == awaiting_my_reply, from doc.Metadata directly (NOT from an LLM-named entity). This is deliberate: for awaiting_my_reply, BOTH the structural worker and the extraction worker must compute the SAME counterpart string for the same document, or their identity_keys never converge (see BuildIdentityKey doc, spec §7.2). Deriving it from metadata for both callers — rather than letting the LLM freely name a counterpart entity for this one kind — is what guarantees the match. For the other 3 kinds (LLM-only, no convergence requirement), callers use the LLM-named entity's normalized_name instead; this function is not used there.

Returns ok=false when doc's source type is not gmail/sms/call-log/ call-transcript, or (gmail only) when "from" is the user's own address — a message the user themself sent cannot be "awaiting my reply".

func HashPhoneNumber

func HashPhoneNumber(number string) string

HashPhoneNumber mirrors smsmap.shortHash's convention for the "번호 해시를 스레드 키로" fallback when contact_name is null (spec §7.1).

func IsUserAddress

func IsUserAddress(addresses []string, candidate string) bool

IsUserAddress reports whether candidate matches one of addresses (case-insensitive, trimmed). addresses is config.UserEmailAddresses (Task 7's new USER_EMAIL_ADDRESSES env var) — a list, not a single value, to accommodate aliases on the same Gmail account.

func NormalizeSummary

func NormalizeSummary(kind, summary string) string

NormalizeSummary reduces a summary to the canonical form used as one input to BuildIdentityKey (spec §5.5, normalization rule resolved here — left unresolved in spec §13).

kind == awaiting_my_reply returns "" unconditionally: it is the only kind §7.1 also derives structurally (fixed Go-generated template text, not free text), and a thread has at most one "latest unanswered message" at a time — so including summary text would only ever prevent the structural candidate and an LLM candidate for the SAME real event from converging to the same identity_key (spec §7.2 requires convergence).

For the other 3 kinds (LLM-only — no structural equivalent, so a thread CAN legitimately hold multiple distinct actions of the same kind), text is what discriminates between them: lower-cased, whitespace-collapsed, stripped of a fixed punctuation set, truncated to 80 chars. This is lossy by design (folds away the dimensions two LLM calls on the same input most commonly differ on) but is NOT semantic dedup — a re-extraction that paraphrases past char 80 gets a new identity_key and a fresh open action.

func ThreadKeyCall

func ThreadKeyCall(contactName string) string

ThreadKeyCall returns the thread_key shared by BOTH call-log and call-transcript documents (spec §7.1 table groups them under one "call:" prefix so a phone call and its transcript are one conversation thread).

func ThreadKeyGmail

func ThreadKeyGmail(threadID string) string

ThreadKeyGmail returns the thread_key for a gmail document (spec §7.1 table).

func ThreadKeySMS

func ThreadKeySMS(contactName string) string

ThreadKeySMS returns the thread_key for an sms document. contactName may be empty — callers must fall back to HashPhoneNumber (spec §7.1: "contact_name이 null이면... 전화번호 해시를 스레드 키로").

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL