← Bundles

architecture@ben_baj~$39 · 39 credits

Embedding Pattern Finder — Temporal Health Associations

Go engine: night-bucketed backward-read, embedding synonym clustering, frequency-framed safe associations from typed health logs.

What it does

Drop-in Go package that turns typed temporal health logs into frequency-framed behaviour→outcome associations — without causal or diagnostic claims. Includes 12h night bucketing (2am outcomes group with prior evening), probe-based affect classification, greedy embedding synonym clustering, minNightsWith noise gate, and 8 network-free tests. Wire to any Postgres session store + any Embedder implementation.

Why this beats rebuild

Embedding-driven backward-read pattern finder that buckets 2am outcomes with prior-evening actions, clusters synonymous behaviours, and frames co-occurrence without causal or diagnostic language.

Why Claude fails

  • 12h nightOffset groups small-hours outcomes with prior-evening actions — non-obvious temporal rule enforced by tests
  • Affect classification via cosine to fixed probes, not keyword lists — handles paraphrase without enumeration
  • Greedy clustering on 'label: verbatim' with threshold 0.45 and minNightsWith=3 tuned on real demo data
  • Safety framing + no-causal-language test encode production constraints Claude skips in one-shot rebuilds

Stripped out

  • Next.js frontend (PatternChatFeed, warm-glass CSS, landing page)
  • WebGL+D3 chain graph renderer
  • Anthropic extraction + OpenAI embed-on-write ingestion pipeline
  • Exa suggest/retrieval engine
  • Seed handler, Render deploy, session/auth wiring

Stack

Go, Postgres, pgvector, embeddings

Integration contract

Check the supported stack and delivery plan before you buy. Commands and full implementation details unlock with the bundle.

Frameworks

  • Go 1.22+
  • Postgres 15+

Dependencies

  • github.com/jackc/pgx/v5 · go-module
  • github.com/google/uuid · go-module
  • embedding provider (OpenAI/Cohere/local) · external-api

How you’ll verify it

  1. Unit tests pass with included fake embedder (no network)Expected: ok patterns (8 tests)
  2. Package compiles cleanlyExpected: exit 0, no errors

Rollback plan

  1. Remove the patterns package and HTTP route
  2. Drop nodes table if added solely for this bundle

Compatibility notes

  • Requires nodes table with kind/type/label/verbatim/occurred_at per schema/nodes_table.sql
  • Embedder interface is provider-agnostic — any batch embedding API works
  • Outcome types: sleep, food, activity, cognitive_state, mood

Preview

package patterns

// Finder is the query/pattern-finding side of the health graph.
// Pipeline:
//
//	load session nodes  →  split outcomes vs behaviours
//	classify each outcome-night negative/positive (embedding nearness)
//	cluster behaviour labels into neighbourhoods (embedding nearness)
//	per behaviour cluster, tally nights-with vs nights-bad  →  frequency framing
//
// Borrowed mechanism: embed text, compare by cosine. Fresh meaning: the
// action→outcome backward read, the night bucketing, and the safe framing.

import (
	"context"
	"fmt"
	"log"
	"math"
	"sort"
	"time"

	"github.com/google/uuid"
	"github.com/jackc/pgx/v5/pgxpool"
)

const (
	// nightOffset shifts an event back before bucketing to a date, so a 2am
	// "slept badly" outcome groups with the prior evening's actions rather

Get this bundle · ~$39 · 39 credits

9 source files, drop-in steps, and verify/rollback. Ask your agent to purchase_bundle then get_bundle.

A $10/month buyer membership includes 10 credits at signup and each renewal. This bundle uses 39 credits from your balance; membership does not make every bundle free. If needed, your agent can run join_membership, then buy_credits to top up before purchase_bundle.

Two ways to get the files after purchase: your agent calls get_bundle (writes them into your project), or download a zip here with your access token.