Governance FAQ Configuration

Configuration Guide

Every knob, threshold, and environment variable. No hidden defaults.


Detection Thresholds

The detector classifies every piece of incoming content and decides whether it's worth saving. These are the thresholds that control that decision, all in src/threadweave/detector.py:

ParameterDefaultEffect
is_worth_saving min confidence0.35Content scoring below this is skipped. Lower = more saved, higher = stricter.
ANSWER weight1.0How heavily answer patterns contribute to the score.
DECISION weight1.0How heavily decision patterns contribute to the score.
REFERENCE per-match0.10Weight per reference pattern match (URLs, ticket numbers). Higher = more content classified as reference and skipped.
External source matches → force REFERENCE3+ matchesIf content matches 3 or more external source patterns (newsletters, marketing, HR digests), it's forced to REFERENCE at 0.90 confidence and skipped.
External source penalty (1-2 matches)Halve ANSWER/DECISION scoresReduce substantive scores when 1-2 external source patterns are present.
LLM confidence minimum0.35Same threshold applied when LLM detector is active (matches regex).

Sensitivity Levels

Seven levels, from least to most restrictive. The confidentiality engine in src/threadweave/confidentiality.py classifies content automatically using regex patterns. Saved entries can be manually reclassified.

LevelWho can see itExample
publicAnyone in the organizationOffice Wi-Fi password, cafeteria menu
internalAnyone in the org; never shared externally (Graph Connector excludes these)Engineering roadmap, team processes
confidentialWing members onlyClient deliverables, project plans
restrictedWing members + explicit access listPricing discussions, pre-release features
hr-confidentialHR wing onlyCompensation, personnel matters
legal-privilegedLegal wing onlyAttorney-client communications
client-confidentialPeople with access to that client_idM&A deal terms, regulatory filings

Each level is enforced at search time: entries above your clearance don't appear in results. The enforcement is at retrieval, not storage.


Server Configuration

VariableDefaultDescription
THREADWEAVE_PORT8000Port the API server listens on.
THREADWEAVE_REQUIRE_AUTH(off)Set to 1 to enable API key authentication.
THREADWEAVE_API_KEYS(none)Comma-separated tenant:key pairs. Admin key uses tenant *.
MEMPALACE_PALACE_PATH~/.mempalace/palace/defaultMemPalace data directory.

LLM Detection (Optional)

By default, ThreadWeave uses regex detection. Set these variables to enable LLM-based classification via any OpenAI-compatible endpoint. The LLM only produces a classification label — never generates text.

VariableExampleDescription
THREADWEAVE_LLM_API_KEYsk-...API key. Falls back to OPENAI_API_KEY.
THREADWEAVE_LLM_BASE_URLhttp://localhost:11434/v1Endpoint. Ollama, vLLM, or any OpenAI-compatible server.
THREADWEAVE_LLM_MODELllama3.1:8bModel name. Must exist and be reachable.
THREADWEAVE_LLM_PROVIDERollamaProvider hint. Used for logging and diagnostics.

Without THREADWEAVE_LLM_BASE_URL set, the detector falls back to regex automatically. The /api/v1/health endpoint reports which detector is active.


Microsoft 365 / Graph Connectors

VariableUsed byDescription
AZURE_TENANT_IDEmail Watcher, SharePointAzure AD tenant ID.
AZURE_CLIENT_IDEmail Watcher, SharePointApp registration client ID (needs Mail.Read, Sites.Read.All).
AZURE_CLIENT_SECRETEmail Watcher, SharePointApp registration client secret.
THREADWEAVE_GRAPH_TENANT_IDGraph External ConnectorAzure AD tenant ID (may differ from the watcher app).
THREADWEAVE_GRAPH_CLIENT_IDGraph External ConnectorApp registration client ID (needs ExternalConnection.ReadWrite.OwnedBy).
THREADWEAVE_GRAPH_CLIENT_SECRETGraph External ConnectorApp registration client secret.
MICROSOFT_APP_IDTeams BotBot Framework app ID.
MICROSOFT_APP_PASSWORDTeams BotBot Framework app password.

Google Workspace Connectors

VariableDefaultDescription
THREADWEAVE_GWS_CREDENTIALS_PATH~/.threadweave/gws_service_account.jsonPath to service account JSON key file.
THREADWEAVE_GWS_DELEGATED_ACCOUNT(required)Email of the user to impersonate via domain-wide delegation.
THREADWEAVE_GWS_SCOPESGmail + Chat + Drive read-onlyComma-separated scope overrides.

Customizing Detection Patterns

The detector patterns live in src/threadweave/detector.py. They're organized into named lists:

Pattern listLinesPurpose
DECISION_PATTERNS~40-56Explicit decisions: "we decided," "approved," "released as," "patched."
ANSWER_PATTERNS~58-76Explanations: "the reason is," "you should," "the key insight."
QUESTION_PATTERNS~78-91Questions that start with how/what/why/when or end with ?.
CHAT_PATTERNS~93-110Casual conversation: greetings, thanks, acknowledgments.
REFERENCE_PATTERNS~112-130Links, ticket numbers, PRs, file paths.
EXTERNAL_SOURCE_PATTERNS~200-240Newsletters, HR digests, marketing, system notifications (21 patterns).

Each pattern is a standard Python regex string. To add a custom pattern, append it to the relevant list. To tune for a specific language or domain, add equivalents. The patterns are plain text — no retraining, no model fine-tuning, no vendor dependency.


API Key Setup

Authentication is off by default. Enable it with:

export THREADWEAVE_REQUIRE_AUTH=1
export THREADWEAVE_API_KEYS="tenant-eng:key-abc123,tenant-legal:key-def456,*:key-admin"

Each key maps to a tenant ID. Requests with X-API-Key: key-abc123 are scoped to tenant-eng — they can only see entries belonging to that tenant. The admin key (tenant *) bypasses scoping for administrative access.

Keys can also be stored in ~/.threadweave/keys.json:

{
  "tenant-eng": "key-abc123",
  "tenant-legal": "key-def456",
  "*": "key-admin"
}

Endpoints exempt from auth (always open): GET /api/v1/health, GET /api/v1/metrics, GET /api/v1/metrics/prometheus.