Skip to document
← TrailforgeAbdul Moiz / Engineering studies Download PDF
Contents 12 chapters + figures

A technical study of a custom agent execution harness

Bound the work. Preserve the trail.

The contracts, durable checkpoints, evidence boundaries, recovery semantics, and host-controlled approvals behind a provider-independent Python agent harness.

  • Agent harness
  • Durable execution
  • Verification
  • Python / SQLite

Part I / The problem

01

An agent needs a boundary, not just a prompt.

A capable model can propose work without proving that the work is complete, safe to repeat, or authorized to affect an external system. Trailforge addresses the control layer around that intelligence: admit a finite goal, bound each task, preserve evidence, and keep uncertain outcomes visible.

The application host owns identity, product policy, model selection, real provider limits, and acceptance criteria. The harness records what was admitted and observed; it does not turn a model's confidence into permission. The public package is an MIT alpha, v0.1.0a1, with a standard-library-only base runtime and Python 3.11 or later.

ResponsibilityTrailforgeApplication host
ExecutionBounded tasks, admission, checkpoints, attempts, receiptsChoose adapters and finite work
AcceptanceRequire typed, goal-bound verification resultsDefine and protect meaningful criteria
External effectsBind approvals and preserve publication uncertaintyAuthenticate people, check live policy, integrate a real publisher
Model useA provider-independent adapter contractSelect models, credentials, prompts, tokens, timeouts, and price limits

Part II / Architecture

02

One kernel. Separate authority planes.

The neutral Harness executes typed Goal and Task records under SQLite authority. Develop is a profile layered on this kernel. A separate OfflineController runs a fixed Review demonstration using fixtures and mock output; its protocol and database integrations must not be confused with generic execution.

The host owns authority. The harness bounds execution.Trailforge / System map
Trusted application hostNeutral execution kernelBounded integrations
Identity & policytenant · resource · permissions · provider limits
Goal + ordered tasksexplicit effects · budget · required checks
Protected acceptancehost-controlled criteria and verification
Harnessadmit → execute → check → complete or hold
SQLite authoritycheckpoints · journal · reservations · versions
Develop profilefinite rounds · candidate/check continuity
Registered adaptersMODEL · TOOL · VERIFY / trusted host code
Artifacts & retrievalbounded bytes · revision-bound exact matches
Linux Docker runnerseparately configured isolation boundary
GuardedPublisherseparate exact approval / effect boundary
SQLite is the neutral runtime's authority. Optional PostgreSQL supports the separate legacy Review profile, not generic Goal/Task execution.
ComponentPurposeImportant boundary
runtime / portsScoped Goal/Task contracts, explicit adapter capabilities, bounded attempts, and typed verifier results.Trusted host code and configured authority, not implicit model permissions.
storeSQLite checkpoints, journal consistency, optimistic state versions, and atomic admission with shared local ledgers.Trusted host code and configured authority, not implicit model permissions.
developAllowlisted candidate writes, protected checks, finite phase rounds, continuity, and verified handoff artifacts.Trusted host code and configured authority, not implicit model permissions.
evidence / controllerThe separate Offline Review profile: bound snapshots, exact citation validation, coverage gaps, and review drafts.Separate fixed Review protocol, not a live multi-model product.
publicationExact intents, expiring host approvals, durable operation admission, and inspect-only reconciliation.Trusted host code and configured authority, not implicit model permissions.
adapters / telemetryLinux Docker execution, exact retrieval, optional orchestration and legacy database/broker integrations, plus allowlisted event projections.Optional integrations require explicit host composition.

LangGraph can schedule a kernel advance, but SQLite remains the neutral resume authority. The PostgreSQL, outbox, and broker adapters belong to the legacy Review/controller path. They are not a generic distributed PostgreSQL backend for the neutral Harness.

Part II / Architecture

03

Declare the work before it begins.

A Goal binds tenant, resource, objective, ordered tasks, required checks, allowed effects, and limits. Tasks identify a registered adapter, bounded input, and dependencies on earlier tasks. Between 1 and 128 unique tasks are admitted in topological order; at least one required check must reference a VERIFY adapter.

ContractWhat it carries
Tasktask_id, adapter_id, input, earlier dependencies
AdapterCapabilitiesMODEL / TOOL / VERIFY kind, effect, protocol, input/output bounds, reservation units
TaskRequestRun/task identity, exact scope, goal digest, detached input and completed dependency outputs
VerifiedResultPASS / FAIL / UNKNOWN, the same goal digest, bounded evidence

PURE, SCOPED_READ, and explicitly admitted CANDIDATE_WRITE effects are supported by the neutral plan. EXTERNAL_WRITE is denied there and belongs at a separate publisher boundary. Adapter kinds are integration roles, not operating-system privileges.

Part III / Execution

04

Admission is durable before execution.

Start records a READY run. Before each synchronous callback, the kernel reserves declared units and persists the attempt with an active lease. It passes detached JSON observations, validates the returned value, and records a digest-bound result receipt before proceeding.

Persist admission before executing the taskTrailforge / System map
Bound contractDurable admissionTrusted callbackRecorded result
READYscope + goal + adapter binding
RUNNINGreserve units · persist attempt + lease
Adapterbounded input / dependencies → output
CHECKINGstore result + digest-bound receipt
Required checks → PASS: COMPLETED / FAIL: FAILED / UNKNOWN: WAITING_HUMAN. Callback uncertainty also holds the run. Cancellation is terminal.
Ambiguous outcomes retain the admitted attempt and units. A trusted host must explicitly choose RETRY or CANCEL; a lease fences commits, not callback execution.

Completed task outputs are reused after reconstructing the host. Resume requires the same goal, adapter metadata, scope, and store; changed bindings are rejected. A pause after a task records its result without granting approval. Tasks execute sequentially within one run, not concurrently.

ObservationMeaning
CHECKINGA task result is recorded; the complete goal may still have work remaining.
COMPLETEDEvery required check passed after the declared task sequence.
FAILEDA required check failed.
WAITING_HUMANUnknown evidence, exhausted attempts, or denied budget requires a host decision.
CANCELLEDTerminal cancellation; previously admitted units and uncertainty remain.

Part III / Execution

05

Unknown is a state, not an invitation to retry.

Exceptions, invalid or oversized output, and expired active attempts retain uncertainty rather than masquerading as success. UNKNOWN holds the run. A trusted host explicitly resolves the affected task with RETRY or CANCEL; retry does not reset the consumed attempts or units.

LimitDefaultMeaning
Per-goal units32Declared adapter reservations, not tokens or dollars
Attempts per task3 maximumRetained through explicit recovery
Input / output65,536 bytes eachAdapter-specific bounded JSON
Lease30 secondsCommit ownership; supported duration is greater than zero and at most 300 seconds
Tenant / global units1,000 / 10,000Shared only within the same SQLite authority file

A lease can reject a late commit; it cannot interrupt synchronous Python or undo a provider call. Cancellation likewise revokes commitment without promising remote cancellation. Hosts need actual provider timeouts, spend policies, and idempotency where those services support them.

Part III / Execution

06

A checkpoint must agree with its journal.

SQLite stores a canonical run payload, binding digest, state version, and checksum. The latest journal sequence and state digest must agree with that checkpoint when it is loaded. Compare-and-swap updates reject a stale state version or changed binding.

Neutral task admission uses BEGIN IMMEDIATE to reserve tenant/global units and commit the new checkpoint and journal event atomically. Reconstructing a host does not reset its ledger, and configured caps cannot be silently changed. Separate database files are separate authorities.

RecordRetained information
runsRun identity, version, canonical payload, binding and checksum
eventsRun sequence, transition kind and resulting state digest
execution_limitsAuthority-scoped caps and admitted reservations
publication_approvals / operationsExact approval consumption and durable effect observations

Part IV / Profiles & evidence

07

Build candidates. Protect the checks.

Develop declares one to three six-phase rounds before admission: PLAN, RESEARCH, BUILD, DEBUG, VERIFY, HEALTH. Five phases are host adapters; HEALTH is built in. Only BUILD receives CANDIDATE_WRITE. Other phases may be pure or scoped reads, and protected criteria live outside the candidate tree.

Finite development rounds. Protected acceptance.Trailforge / System map
UnderstandCreate & inspectVerify & retain
PLANbounded objective and proposed approach
RESEARCHscoped observations · no candidate writes
BUILDonly phase granted CANDIDATE_WRITE
DEBUGinspect outcomes · no candidate writes
VERIFYhost criterion + exact candidate/check digests
HEALTHbuilt-in candidate continuity check
Handoffreview artifact, not deployment permission
One to three rounds are declared up front. The final round's VERIFY and HEALTH are required checks. A handoff requires the same candidate and protected check trees.

CandidateWorkspace admits an explicit list of 1–128 canonical paths, rejects case aliases and linked-file variants, bounds file bytes, and replaces writes atomically through a temporary file. Pre/post tree checks detect unauthorized candidate changes and altered protected checks.

VERIFY binds host evidence to the candidate, check tree, round, and goal. HEALTH checks candidate continuity. The final round's verification and health are required for completion, and a handoff is rejected if the candidate or checks change afterward.

Part IV / Profiles & evidence

08

An exact quote is evidence, not a verdict.

The fixed Offline Review path captures scoped, revision-bound source bytes and validates findings against exact paths, one-based line ranges, preserved quotes, and receipts. Its security, correctness, tests, and documentation roles are configured outputs of one mock callback, not four built-in live agents.

Source evidence is data, not authorityTrailforge / System map
CaptureProposeValidateReview
Bound snapshotscope · revision · paths · byte digests
Mock findingrole · path · lines · preserved quote
Evidence checksreceipt + exact source correspondence
Human reviewretained gaps · COMPLETE or PARTIAL
A complete workflow is not calibrated model quality. Independent acceptance and real-provider evaluations remain separate responsibilities.
The fixed Offline Review demonstration uses a mock callback. Exact citation validation establishes source correspondence, not that a proposed defect is real.

Unsupported files, truncation, malformed findings, and timeouts leave coverage gaps. A draft always needs human review; the critic is not implemented and reliability is unset. COMPLETE means the configured workflow's coverage is complete, not that every reported issue is a real defect.

LocalArtifactStore provides bounded, content-addressed bytes with scope and integrity receipts. LocalRetrieval performs revision-bound, case-insensitive EXACT_LITERAL matching over allowlisted files. It returns matching files in sorted order—not semantic rankings or vector chunks—and marks them as untrusted source data.

Part V / Integration boundaries

09

Approve an exact effect. Inspect ambiguity.

GuardedPublisher binds an intent to tenant, resource, goal and policy digests, revision, action, payload, adapter, and execution mode. A live host guard authorizes approval, execution, revocation, and reconciliation. Approval expiry defaults to 300 seconds and cannot be treated as lasting authority.

Approval is bound to an exact effectTrailforge / System map
Intent & authorityDurable dispatchObserve outcome
Exact intentscope · goal · policy · revision · action · payload
Host approvallive authorization · expiry · revocation
SENDINGconsume approval + persist operation first
Publisher adapterexecute the bound operation
ACCEPTEDvalid acknowledgement for the same operation
UNKNOWNlost response or invalid acknowledgement
Reconcileinspect the same operation · no re-execution
The included publisher is a durable local simulation. Real external publishers and customer identity are host integrations; ambiguous publication is inspected, never blindly resent.

Before dispatch, approval consumption and a stable SENDING operation are persisted. A valid bound acknowledgement yields ACCEPTED. A lost response or invalid acknowledgement yields UNKNOWN. Replaying the same intent observes the stored operation; reconciliation only calls inspect, never blindly executes it again.

Part V / Integration boundaries

10

Optional integrations retain their own limits.

IntegrationImplemented roleBoundary
Linux DockerDigest-pinned image, no network, read-only mounts/root, non-root execution, dropped capabilities, bounded resources/output and owned cleanupLocal Linux-container engine required; no automatic pull or host-shell fallback
PostgreSQLLegacy Review authority, fenced leases, ledgers, migrations, transactional outboxNot the neutral Goal/Task backend; documented database validation is Linux-specific
BrokerClosed proposals checked against roles, scope, policy, session, revisions and versionsA model proposal is not a credential; broker and neutral approvals are not interchangeable
LangGraphSTART → kernel → END scheduling facadeSQLite remains authoritative; no separate graph checkpoint or approval mechanism
JsonEventSinkExplicit allowlisted operational JSON projectionsNo automatic cloud exporter, metrics server, or cross-process delivery guarantee

Docker execution receipts bind command, image, candidate/check trees, goal, and output. They default to an UNKNOWN criterion verdict: exit code zero alone cannot establish semantic acceptance. A trusted verifier must interpret that execution evidence against the original requirement.

Telemetry deliberately excludes arbitrary prompts, source text, tokens, and actor/provider fields. Hosts can monitor held attempts, budget denial, stale leases, ambiguous publication, dispatch exhaustion, and cleanup failures while keeping full authority records out of routine operational logs.

Part VI / Evidence & adoption

11

Conformance is not model accuracy.

The v0.1.0a1 guide records installed-package conformance coverage for the alpha release. These are documented release results, not new test runs performed by this portfolio and not measurements of real-provider answer quality.

Release suiteDocumented execution
Portable installed wheel62 cases per matrix cell: Ubuntu 24.04 / Windows 2022 × Python 3.11 / 3.13.15
Optional LangGraph2 installed-extra cases against the accepted base wheel
Legacy PostgreSQL56 installed-extra cases on Linux PostgreSQL 18.6
Native Linux Docker5 installed-wheel container-boundary cases
Suite acceptanceZero failures, errors, skips, or expected failures in accepted reports

A separate evaluation would need representative data, independently protected acceptance, diagnostic correctness, cost, latency, and unsafe-action measurements. A repository-owned workflow and test suite cannot substitute for independently administered review.

Part VI / Evidence & adoption

12

Keep the host responsible.

  • Pin the release and required extras; keep authority stores and credentials private.
  • Define exact tenant/resource identity, finite tasks, explicit effects, and meaningful protected checks.
  • Version material adapter/model/prompt choices; enforce real provider timeouts and cost limits separately.
  • Make UNKNOWN, exhausted budgets, and cancellation visible to an operator.
  • Use a tested Linux runner for untrusted commands; trusted callbacks are not an operating-system isolation boundary.
  • Integrate real publishers only with current identity, policy, revision checks and tested inspect/reconciliation behavior.

Potential extensions include a general distributed-authority adapter, richer retrieval, additional product profiles, calibrated model evaluations, and independent acceptance infrastructure. They are roadmap directions—not shipped capabilities of this alpha.