The harness.
Discipline around every turn.

Code generation is probabilistic; shipping software is not. The JY Code harness is the deterministic execution runtime on the cloud Mac—enforcing bounded memory budgets, AST-verified patches, native compiler and GUI checks, automatic rollback on regression, and human sign-off before merge.

Production runtime architecture, failure containment & interactive loop trace.

Runtime core
Deterministic state machine
Working memory
4-tier budget · ~91% folding
Mutation safety
AST-checked hunk & git rollback
Verification
Compiler · Simulator · WebKit
Merge authority
Zero auto-push · Human gate

CONTROL LOOP / 5 STATEFUL STAGES

Every task runs
through a gated state machine.

Instead of an open-ended chat loop, each session advances through explicit grounding, planning, execution, observation, and packaging states—each guarded by a concrete exit invariant.

  1. 01GROUND

    Assemble bounded repository context

    Loads AGENTS.md invariants, symbol trees, and build targets without polluting working memory with lockfiles or DerivedData.

    ARTIFACT
    RepoMap + PinnedRuleSet
    EXIT GATE
    Rules anchored · ≤ 12% context used
  2. 02PLAN

    Lock hypothesis, blast radius & pass criteria

    Commits an explicit root-cause brief, target file lease, and measurable verification command before touching disk.

    ARTIFACT
    SessionLedger.planCheckpoint
    EXIT GATE
    Pass criteria & file scope locked
  3. 03ACT

    Apply surgical hunks & supervised builds

    Validates exact-match patches against syntax boundaries, records a git checkpoint, and runs scoped macOS toolchains.

    ARTIFACT
    GitCheckpoint + ExitTranscript
    EXIT GATE
    Syntax valid · Process group clean
  4. 04OBSERVE

    Distill diagnostics & inspect live frames

    Folds multi-thousand-line compiler stdout into file:line signals and captures Retina Simulator, Safari, or xctrace proof.

    ARTIFACT
    DiagnosticDelta + VisualProof
    EXIT GATE
    0 regressions · Visual assertions met
  5. 05PACKAGE

    Audit git hygiene & pause at the gate

    Reaps background daemons, prunes scratch captures, verifies clean git status, and bundles proof for human review.

    ARTIFACT
    VerifiedHandoffBundle
    EXIT GATE
    0 untracked files · Human sign-off

LIVE TRACE INSPECTOR / SIGNAL DISTILLATION & LEDGER

Inspect every turn,
raw stream to clean ledger.

Step through four macOS engineering scenarios. Toggle between folded compiler/GUI signals and the persisted session ledger to see how each stage verifies invariants before advancing.

TASK GOALfix/checkout-dynamic-type

Fix Dynamic Type clipping on CheckoutSheetView for iPhone 16 Pro and verify at Accessibility XXXL.

WORKING MEMORY BUDGET18.4k / 200k tokens (91% log compaction)
  • Pinned rules & map2.6k
  • Session ledger1.2k
  • Active Swift spans9.4k
  • Distilled tool I/O5.2k
STAGE 01 / 05 · GROUND · repo_outline + read_span
READ-ONLY0.42s

Assemble bounded repository context

DISPATCHrepo_outline({ scope: "Sources/Checkout", rules: ["AGENTS.md", "Package.swift"] })
RAW STREAM[fs-scan] 412 files enumerated · DerivedData/ (14,200 lines) & Package.resolved excluded by policy
DISTILLED→ Mapped 6 SwiftUI views · Isolated fixed .height(340) detent in CheckoutSheetView.swift:42
[harness] Filtered 14,200 lines of DerivedData & SPM lockfiles → 1.8k-token symbol map

The harness builds a lightweight AST symbol map and pins repository rules first, narrowing focus straight to the target SwiftUI sheet instead of grepping blindly.

harness-session-01SIMULATOR · AX3
macOS iPhone 16 Pro Simulator at Accessibility XXXL alongside simctl verification output confirming 0pt safe-area overlap
  • XCTest suite24 / 24 passed
  • Log compaction3,840 → 18 lines
  • Branch diff+68 −19 · 3 Swift files
  • Memory headroom90.8% window headroom preserved across 5 stages

MEMORY ARCHITECTURE / 4 WORKING TIERS

Engineered against
long-session context rot.

Appending raw build transcripts quickly drowns repository rules and architectural boundaries. The harness manages working memory in four distinct tiers so Turn 25 stays razor-sharp.

  1. TIER 011.5k – 3.0k tok

    Immutable system & repository guardrails

    PINNED · NEVER EVICTED

    Anchored at the top of every turn so architectural prohibitions, strict typing rules, and permission boundaries never drift out of attention on turn 25.

    • AGENTS.md & CLAUDE.md
    • Strict type & linter contracts
    • Branch & secret boundaries
  2. TIER 020.8k – 2.0k tok

    Transactional session state ledger

    DISK-BACKED · STRUCTURED

    Persisted on disk rather than buried in fragile chat prose. Tracks the active hypothesis, allowed file lease, last green git_checkpoint SHA, and pass criteria across every stage.

    • Locked plan & pass invariants
    • Last green git_checkpoint SHA
    • Verified test & visual status
  3. TIER 038.0k – 18.0k tok

    Sliding AST & file-span working set

    DEMAND-PAGED · STALE-EVICTED

    Pages in line-numbered code spans and call graphs on demand. Pre-edit slices are invalidated immediately after a patch lands so stale line numbers never linger in working memory.

    • Symbol tree (repo_outline)
    • Scoped read_span slices
    • Cross-file call references
  4. TIER 0490%+ COMPACTED

    Distilled compiler & GUI telemetry stream

    PARSED BEFORE INGESTION

    Raw 10,000-line xcodebuild transcripts and 50 MB .trace bundles stay on disk for human audit; only structured file:line diagnostics and visual assertions enter active context.

    • Failing file:line:col frames
    • Assertion diffs & exit codes
    • Simulator / WebKit geometry checks

FAILURE CONTAINMENT / 5 PRODUCTION SAFEGUARDS

Built for Turn 25,
not just Turn 1.

Demos fail gracefully on slides and catastrophically inside real monorepos. Every recovery mechanism below is enforced in runtime code—never left to prompt wishes.

How the JY Code harness contains common production coding agent failure modes
Failure modeUnchecked loopJY Harness containmentRuntime trigger
01Edit–test oscillationFixes test A by breaking test B, burning 100k+ tokens flipping between broken states.Hashes normalized compiler and assertion signatures per turn. Two identical signatures halt mutation, roll back to the last green git_checkpoint, and force re-planning or human escalation.2× signature match → rollback
02Large-file rewrite driftRegenerates 1,200-line files from scratch, silently dropping comments, edge branches, or types.Forbids blind whole-file overwrites. Enforces exact-context edit_hunk patches validated immediately against syntax and AST boundaries before any build runs.0 ambiguous hunks · AST gate
03Stdout flood & context rotDumps raw xcodebuild, cargo, or Playwright logs into history until early repository rules vanish.Domain parsers strip passing build phases on the Mac, surfacing compact file:line diagnostic frames while archiving full raw transcripts in the review bundle.~91% average log folding
04Orphaned servers & hung CLIsLeaves dev servers holding port 3000 or hangs indefinitely on an interactive CLI prompt.Executes every command in a non-interactive process group with wall-clock and idle-output timeouts, readiness probes, and automatic PGID teardown at stage exit.PGID lease + idle timeout
05Silent scope or dependency creepInstalls unapproved packages, weakens linter rules, or guesses ambiguous product behavior to turn tests green.Audits manifest files (Package.swift, package.json, Cargo.toml) and config diffs continuously—pausing via ask_human with concrete options whenever authority is exceeded.Manifest & config diff guard

SUBSYSTEMS / 6 ARCHITECTURAL PILLARS

Six subsystems where
autonomous loops usually break.

Most agent failures are runtime failures: bloated memory windows, corrupted large files, orphaned background servers, or infinite retry spirals.

01
CONTEXT ENGINE~91% LOG REDUCTION

Log folding & context compaction

A single xcodebuild or Playwright run can emit tens of thousands of lines. Dumping raw stdout into active memory degrades precision within three turns.

Dedicated xcresult, cargo, and Playwright parsers extract exact file:line diagnostics while archiving raw logs on disk.

02
EDIT PRIMITIVESAST-VERIFIED HUNKS

Surgical hunk patches, never blind rewrites

Whole-file regeneration wastes budget and risks silently dropping comments, concurrency annotations, or edge handlers in large files.

Context-anchored hunk edits verify unique match boundaries and syntax validity immediately, rejecting ambiguous patches before build.

03
VISUAL GROUNDINGRETINA + 120HZ PROOF

First-class macOS GUI & profiler hooks

Exit code 0 cannot tell you if a checkout CTA is clipped at Accessibility XXXL or a sticky header jitters in desktop Safari.

Native bridges for simctl, Safari 18 Web Inspector, and xctrace turn live pixels, layer trees, and frame budgets into structured checks.

04
SESSION LEDGERDISK-BACKED STATE

Transactional state & daemon supervision

Long engineering sessions break when plans exist only in ephemeral chat text or background dev servers leak sockets across retries.

Persists hypotheses, file write leases, and supervised PGID process trees on disk—ensuring clean teardown and deterministic resumption.

05
LOOP GUARDSSIGNATURE CIRCUIT BREAKER

Oscillation detection & checkpoint rollback

Unchecked loops spiral—fixing assertion A by regressing assertion B and burning compute without converging.

Tracks diagnostic signature hashes and diff entropy across turns, rolling back to a verified git checkpoint when progress stalls.

06
REPO GOVERNANCEPINNED INVARIANTS

Native AGENTS.md & manifest enforcement

Mature codebases carry non-negotiable contracts around strict types, module boundaries, dependencies, and formatting.

AGENTS.md instructions, lockfile guards, and strict linter gates stay pinned in Tier-01 memory and are audited prior to packaging.

TOOL INTERFACE / 16 TYPED PRIMITIVES

Typed tool contracts,
never raw shell chaos.

Every action on the cloud Mac executes through schema-validated, scoped primitives—enforcing consistent edit accuracy, process supervision, secret scrubbing, and visual telemetry.

Code & repository

FILESYSTEM
  • repo_outlineREAD · Lockfile-filtered
    AST symbol & module map without build-cache noise
  • read_spanREAD · Byte-capped
    Line-numbered slices with automatic stale-span eviction
  • edit_hunkMUTATE · Syntax-checked
    Exact-anchor atomic patch; rejects ambiguous matches
  • ripgrepREAD · Sub-second
    Scoped regex & symbol-boundary search across packages

Shell & build

EXECUTION
  • exec_commandEXEC · Timeout + scrub
    Non-interactive zsh run with secret redaction & log folding
  • bg_processDAEMON · PGID lease
    Supervised dev servers with readiness probe & port reaping
  • test_runnerVERIFY · Typed digest
    Structured XCTest, Playwright, cargo & pytest parser
  • env_probeREAD · arm64 audit
    Xcode SDK, toolchain version & Mach-O linkage inspection

macOS GUI & profiling

VISUAL & PERF
  • simctl_captureGUI · WindowServer
    Boot Simulator & assert Dynamic Type / appearance frames
  • webkit_inspectGUI · Safari 18
    Desktop WebKit DOM, CLS & composited-layer telemetry
  • appkit_launchGUI · Isolated bundle
    Launch & inspect native macOS windows or menu bar apps
  • xctrace_summaryPERF · Symbol delta
    Distill Time Profiler & Leaks .trace bundles to hot frames

State & governance

CONTROL
  • plan_checkpointSTATE · Scope lock
    Commit hypothesis, file lease & quantitative pass criteria
  • git_checkpointSAFETY · Reversible
    Snapshot clean working states for deterministic rollback
  • ask_humanESCALATE · Zero guess
    Suspend cleanly with verified options when tradeoffs surface
  • handoff_bundleGATE · Hygiene audit
    Prune scratch files, verify git status & package proof

EVERY INVOCATION PASSES THROUGH 4 RUNTIME GATES

  1. 01Schema & path boundary check

    Validates typed arguments, workspace path confinement, and manifest write policies before dispatch.

  2. 02Supervised macOS execution

    Runs inside an isolated process group with non-interactive stdin, CPU/wall timeouts, and port tracking.

  3. 03Secret & credential scrubbing

    Strips injected environment tokens, signing keys, and auth headers before logs touch disk or active context.

  4. 04Parser folding & ledger commit

    Compacts verbose compiler stdout into structured diagnostics and updates the persisted session ledger.

GOVERNANCE & AUDITABILITY / AUTONOMY × GATES

Autonomous in the loop.
Accountable at the gate.

AUTONOMOUS INSIDE THE LOOP

  • Indexing source trees, git blame history, and AGENTS.md contracts
  • Applying syntax-verified hunk edits on an isolated session branch
  • Running Xcode, Swift 6, Playwright, cargo, and pytest suites
  • Booting iOS Simulator, Safari 18, and Instruments for visual/perf checks
  • Rolling back oscillating edits to the last verified git checkpoint

ALWAYS GATED ON HUMAN SIGN-OFF

  • Merging pull requests or pushing commits to protected branches
  • Mutating CI/CD workflows, infrastructure configs, or production secrets
  • Adding external dependencies, upgrading SDKs, or altering licenses
  • Weakening linter, typecheck, or concurrency compiler flags to force pass
  • Resolving ambiguous product, API contract, or UX tradeoffs silently
  • 01Ephemeral secret redaction

    Workspace credentials are injected at child-process spawn and scrubbed automatically from command transcripts, error digests, and review bundles.

  • 02Deterministic turn replay

    Every ledger transition, hunk patch, tool exit code, and checkpoint SHA is sealed into an auditable timeline for engineering review.

  • 03Zero artifact contamination

    Multi-megabyte .trace bundles, DerivedData caches, and temporary screenshots are pruned before any branch handoff is packaged.

  • 04Workspace & manifest confinement

    Each task executes in an isolated branch checkout with scoped file write leases, frozen lockfiles, and zero unsolicited remote mutations.

Every session seals an auditable replay log and pauses with verified proof before merge.Request beta access →