//DOCS Concepts

Runtime loop, routes, side effects, SOM, artifacts, and approvals.
GitHub Docs

Punk Concepts

This page defines the mental model shared by the docs, dashboard, SDK, and API.

One-Sentence Model

Punk observes every agent run, governs what the agent can do, structures web context into machine-readable SOM, learns repeated work, proves optimized paths through replay and shadow evaluation, and routes future work through the cheapest safe path.

Runtime Loop

Observe -> Govern -> Structure -> Optimize -> Prove -> Route -> Audit -> Learn
StepMeaning
ObserveCapture the request, model call, tool calls, web fetches, side effects, costs, latency, and output.
GovernEvaluate identity, trust, policies, side-effect level, approvals, and tenant mode.
StructureNormalize prompts, tools, outputs, and web pages. Web pages become SOM snapshots.
OptimizeCheck caches, fingerprints, patterns, artifacts, and route confidence.
ProveUse replay, shadow evaluation, and promotion gates before serving an optimized path live.
RouteSelect live, cache, artifact, SOM cache, tool cache, hybrid, blocked, or approval-required behavior.
AuditPersist route explanations, policy decisions, trace events, side effects, approvals, and audit records.
LearnDiscover patterns, synthesize artifacts, update confidence, detect drift, and improve routing.

Core Entities

EntityWhat it is
TenantIsolation boundary for data, settings, keys, runs, policies, caches, and artifacts.
AppLogical application sending traffic through Punk.
AgentRuntime actor with trust tier, trust score, tags, and audit identity.
SubjectPseudonymous end-user or scope used as a cache-key safety dimension.
RunOne model request or runtime interaction observed by Punk.
Trace eventAppend-only event in the run ledger.
Route explanationHuman-readable and machine-readable reason for the selected route.
PatternCluster of repeated runs grouped by fingerprint and behavior.
ArtifactVerified deterministic or semi-deterministic replacement for repeated work.
EvaluationReplay, shadow, or live confidence evidence for an artifact.
ApprovalHuman decision record for policy exceptions or artifact promotions.
SOM snapshotSemantic Object Model representation of a web page.
Audit eventGovernance evidence: actor, action, decision, policy, reason, metadata.

Routes

RouteMeaning
liveRequest was served by the live provider.
exact_cacheIdentical normalized request was served from cache.
semantic_cacheSemantically equivalent request was served from cache.
tool_cacheRead-only tool result was reused.
som_cacheWeb page semantic snapshot was reused.
plan_cacheStable plan was reused while fresh reads may still run.
artifactPromoted deterministic artifact served the response.
hybrid_artifactArtifact handled part of the route with model fallback.
blockedPolicy denied the request.

Every optimized or blocked response should have a route explanation.

Gateway Modes

ModeBehavior
optimizePunk may cache, serve artifacts, enforce policy blocks, and record savings.
observePunk records what it would have done, but always returns live provider responses and does not block. Savings are tracked as ghost savings.

Gateway mode is pinned to API keys. Use observe mode for pilots where trust must be earned before optimization affects traffic.

Side-Effect Levels

LevelMeaningDefault behavior
0Pure computationCacheable and replayable.
1Read-only external callCacheable with TTL and subject/auth scope.
2Reversible or idempotent writeRequires idempotency/rollback thinking.
3User-visible writeNot cached; suppressed in replay/shadow; policy-gated.
4High-impact writeLive plus approval by default.

Undeclared tools default conservatively to level 3.

SOM

SOM means Semantic Object Model. It is Punk's structured representation of web pages for agents:

  • Semantic regions such as navigation, main, form, header, footer, dialog.
  • Semantic elements such as links, buttons, inputs, tables, headings, paragraphs.
  • Stable element IDs.
  • Explicit actions such as click, type, select, and submit.
  • Metadata for byte counts and token-savings estimates.

SOM lets Punk cache, diff, replay, and reason over web context without sending raw HTML to a model.

Web sessions build on SOM. A session holds a page state, executes protocol-level actions against stable SOM element IDs, and recompiles the resulting page. type and select are session-local pure actions, click is usually a read/navigation action, and submit is a user-visible write that must be governed like any other side effect. Form-button clicks should be reviewed as submit-sensitive behavior.

Artifact Lifecycle

Common states:

  • observed: repeated pattern detected.
  • candidate: candidate artifact exists.
  • replay_passed / replay_failed: historical proof result.
  • shadowing / shadow_failed: live shadow evidence.
  • promoted: eligible for live route use.
  • canary: limited rollout when canary mode is enabled.
  • stable: default for matched traffic.
  • degraded: confidence lowered.
  • quarantined: blocked from runtime use.
  • retired: intentionally removed or superseded.

Promotion should be evidence-based, policy-aware, auditable, and reversible.

Approvals

Approvals cover two high-frequency human decisions:

  • Policy exception: a request matched requiresApproval.
  • Artifact promotion: a candidate passed gates and needs operator sign-off.

Approvals are visible in the dashboard, API, and PunkBar. Decisions are written to audit.