Technology

Lenses, bounded records, controlled experiments.

Agents place lenses and capture data in running applications on their own. lensd separates three decisions: what to observe, how much to keep, and what to change.

01

Capabilities

StatusCapabilityDetail
Available in HypersetTargeted runtime captureThe agent places a lens at a function or other locus and receives bounded, structured records of arguments, returns, exceptions and flow. Covers JavaScript and TypeScript on Node.js, Deno, Bun and Electron, along with Python, Go, Java and the JVM, native binaries and browser pages.
Available in HypersetBrowser stream captureConsole output, network requests and uncaught exceptions from a browser page or an Electron window, on one clock.
ExperimentalBound experimentsRun a unit with specified dependency responses and record what follows. The same unit, the same starting state, one changed response.
ExperimentalWrite actionsDeclarative stubs applied to a running application with no source change: return, throw, delay or sink at a boundary, scoped to one flow.
ProposedDirect invocationRe-fire a captured call site in the running application with arguments the agent supplies, without a round-trip through the interface.
ProposedExecution replayRe-drive a recorded history with one condition changed, keeping the state a fresh run would lose.
02

The lens specification

A lens specification is a declaration: where to look, what to capture, and how much to keep. The agent writes it and places it without a person in the loop. It does not edit the application's source.

Every lens carries a budget that caps hits, depth, bytes and sample rate, so the cost of looking is fixed before the agent looks. What comes back is a structured record with a stable schema, which an agent, a person and a test harness can all read.

{
  "id": "checkout",
  "target":  { "locus": { "kind": "function_entry", "symbol": "applyDiscount" } },
  "capture": [ { "kind": "arg_name", "name": "cart" } ],
  "budget":  { "max_hits": 50, "max_depth": 3, "sample_rate": 1.0 }
}
03

The experiment contract

Proposed

There are two verbs, with separate permissions: observe a declared target, and run a declared experiment. An experiment changes one named condition and returns five things, so that its result can be compared with a control and checked by someone else:

IdentityWhich target and build were run.
ConditionExactly what was changed.
BoundaryThe isolation and reset used.
EvidenceWhat was collected, with provenance.
GapsWhat was not observed.

Figure 01 in note 02 runs this loop: observe, hypothesise, intervene, evaluate.

04

Write actions

Experimental

A lens declares what to read. A stub specification declares what to change: at this boundary, for this flow, when the arguments match, return this value in place of the real call. It is mocking that an agent programs at runtime, in the real application, without editing a line of source.

Reading and writing are separate specifications with separate permissions. Holding a lens never grants the ability to act.

{
  "id": "payments-429",
  "target": { "locus": { "kind": "function_entry", "symbol": "payments.charge" } },
  "when":   { "arg": "amount", "gt": 0 },
  "action": { "kind": "throw", "value": { "status": 429, "retry_after": 2 } },
  "scope":  { "flow": "f_8c21" },
  "budget": { "max_hits": 10, "on_exhaust": "keep_acting" }
}
ClassActionsWhat it changesAuthority
Valuereturn · throw · delay · sinkThe value at one boundary, for one flow.Flow scope and containment.
InvocationinvokeA new entry into live state at a call site the lens has already seen.Flow scope, containment, and a captured call site as proof the target is reachable.
IdentityidentityWho the run is: a scratch principal created for this turn.Its own gate. It never inherits authority from the other two.

The predicate is data, never code. A when clause is a bounded comparison over captured values. It cannot call into the target, walk an object or trigger a getter, so deciding whether to act cannot itself change the program.

A hit is proven, never assumed. An attached stub that the caller routes around is worse than none, because the agent believes a boundary is fenced while the real call lands. Every run distinguishes three states:

BoundThe stub is attached at the declared locus.
AppliedA record shows this flow reached the stub and received its value. A control run without the stub reaches the real dependency.
ContainedThe effect is blocked independently of the stub, so a missed stub still cannot cause it.

Experiments keep their own ledger. A record from an intervened run carries the specification, the locus and the action that touched it. Four things stay distinct all the way to the verdict: an observed attempt, a simulated response, an independently blocked effect, and a committed effect. A simulated success is never reported as a commit.

The specification is pinned to what it was written for. If the application changes underneath it, the specification is revoked along with any verdict that rested on it.

The techniques these actions enable, from unhappy-path stubs to fenced reproduction, are in the technique catalogue.