Skip to content

feat(emergent): forged code runs through an executor interface; a CI run measures QuickJS - #148

Merged
jddunn merged 5 commits into
masterfrom
feat/forge-executor-seam
Oct 8, 2026
Merged

jddunn merged 5 commits into
masterfrom
feat/forge-executor-seam

Conversation

@jddunn

@jddunn jddunn commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

What this changes

  • Forged code runs through an executor interface. SandboxedToolForge validates the source, pre-parses it and builds the granted functions, then hands each run to a ForgedCodeExecutor (name, isolates, run). The default, InProcessExecutor, is the CodeSandbox path moved behind the interface; every message a host sees is unchanged, and it declares isolates: false. A host may pass its own executor (new SandboxedToolForge({ executor })); forge.executor names the one in use. Exported: InProcessExecutor, ForgedCodeExecutor, ExecutorRunRequest, ExecutorRunResult.
  • A corpus of forged tools in tests/fixtures/forged-tools/: the forged code of the library's own forge tests, verbatim (29), and a written set (32) of computational models, language features, built-in globals and each capability. tests/emergent/forged-corpus.integration.spec.ts runs all of them through the forge on the in-process executor, capability fixtures under a ceiling through the broker.
  • An evidence job (.github/workflows/forge-executor-evidence.yml, evidence/forge-executors/) that runs a prototype QuickJS-in-WebAssembly executor through the same forge and reports what follows. Nothing about QuickJS ships; quickjs-emscripten 0.32.0 is installed only by the job.
  • Documentation: an Executors section; the Safety Invariants line now says that codeGeneration applies to the context's own intrinsics and that the host constructors handed to the in-process context carry the host's Function.

Evidence (run 37730116146, commit f6398c7)

QuickJS held three ways: one shared module, one shared module on a memory capped at 256 MB, and an instance per call (the module compiled once, each call on a fresh WebAssembly.Memory whose maximum is the call's memoryMB).

Question Shared module Instance per call
Can guest code await an asynchronous host function? yes, 5 of 5 (fetch, fs.readFile, three in parallel, a refused host caught, 20 in sequence) yes, 5 of 5
Does the corpus run on it? 59 of 61; Intl is missing, and string code generation inside the guest is allowed (it reaches only the guest's own realm) the same 59 of 61
Start-up and per call 34 ms start-up; 1.1 ms median overhead over in-process (p95 1.2 ms) 5.9 ms to compile once; 2.4 ms median overhead (p95 3.1 ms)
A guest past its 16 MB limit QuickJS's own limit counts only each allocation's overhead under Emscripten, so the guest grew the WebAssembly memory to 2,048 MB and the host kept about 1,980 MB out of memory in 27 ms at 16 MB; the host kept 0.35 MB after collection
A guest that yields once and then spins stopped at its deadline in all six variants (the in-process executor does not stop it) the same
Escape probes, past the forge's validation 9 of 9 contained 9 of 9 contained

A 256 MB cap on a shared module stopped the guest at 248 MB, and the host kept the 248 MB. At QuickJS's 1 MiB stack limit, deep recursion exhausts V8's own stack first. At 256 KiB it ends as the guest's own "stack overflow", and a recursion 1,000 deep still succeeds.

Tests

  • src/cognition/emergent/__tests__/forge-executor.test.ts: what the executor receives (code, input, granted functions, limits, the call's signal under a ceiling) and how each way a run ends comes back; validation, the pre-parse and a missing call handle never reach it.
  • tests/emergent/forged-corpus.integration.spec.ts: 61 forged tools through the forge on the in-process executor.
  • Every existing emergent test passes unchanged.

🤖 Generated with Claude Code

…e in-process executor

The library's own forge test fixtures, copied verbatim, and a written set (computational models, language features, built-in globals, each capability), each with the result the in-process executor returns. Capability fixtures run under a ceiling through the broker against a local server and a directory of files.
@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Repository: framerslab/agentos/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Team
  • Run ID: cacc8cf8-589b-4d04-9c43-f57b03e2911e
📥 Commits

Reviewing files that changed from the base of the PR and between fee43be and f6398c7.

📒 Files selected for processing (21)
  • .github/workflows/ci.yml
  • .github/workflows/forge-executor-evidence.yml
  • .gitignore
  • docs/architecture/EMERGENT_CAPABILITIES.md
  • evidence/forge-executors/README.md
  • evidence/forge-executors/guest-prelude.cjs
  • evidence/forge-executors/guest-surface.ts
  • evidence/forge-executors/in-process-child.ts
  • evidence/forge-executors/package.json
  • evidence/forge-executors/quickjs-executor.ts
  • evidence/forge-executors/run.ts
  • src/cognition/emergent/SandboxedToolForge.ts
  • src/cognition/emergent/__tests__/forge-executor.test.ts
  • src/cognition/emergent/executor/InProcessExecutor.ts
  • src/cognition/emergent/executor/types.ts
  • src/cognition/emergent/index.ts
  • tests/emergent/forged-corpus.integration.spec.ts
  • tests/fixtures/forged-tools/README.md
  • tests/fixtures/forged-tools/environment.ts
  • tests/fixtures/forged-tools/library.json
  • tests/fixtures/forged-tools/written.json
 __________________________
< Needle. Haystack. Found. >
 --------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Oct 8, 2026

Copy link
Copy Markdown

Reviewer's Guide

Introduces a reusable forged-tool corpus and deterministic HTTP/filesystem environment, then adds an integration suite that executes every fixture in-process, routing capability-enabled tools through the broker and checking declared outcomes. The corpus is also documented as the shared input for a separate executor evidence run measuring QuickJS.

File-Level Changes

Change Details Files
Add a shared forged-tool corpus and fixture environment for validating generated code across execution paths.
  • Add JSON corpora containing library-derived and newly authored forged tools, inputs, allowlists, deadlines, and expected outcomes.
  • Create an isolated HTTP/file fixture environment with placeholder substitution and reusable expectation checking.
  • Document corpus provenance, capability ceilings, fixture semantics, and how the corpus is consumed.
tests/fixtures/forged-tools/README.md
tests/fixtures/forged-tools/environment.ts
tests/fixtures/forged-tools/library.json
tests/fixtures/forged-tools/written.json
Exercise every corpus fixture through the in-process executor with capability calls routed through the broker.
  • Run non-capability fixtures directly and capability fixtures under a resolved ceiling with a call handle.
  • Ensure broker calls are ended after execution and the fixture environment is cleaned up.
  • Assert unique fixture IDs and validate each result against its declared success, output, or error expectation.
tests/emergent/forged-corpus.integration.spec.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

jddunn added 4 commits October 7, 2026 21:13
SandboxedToolForge validates, pre-parses and builds the granted functions, then hands each run to a ForgedCodeExecutor (name, isolates, run). The default InProcessExecutor is the CodeSandbox path moved behind the interface with every message unchanged; it declares isolates: false. A host may pass its own executor (SandboxedToolForgeConfig.executor); forge.executor names the one in use.
…xt hands forged code

Exports InProcessExecutor, ForgedCodeExecutor, ExecutorRunRequest and ExecutorRunResult. The guide gains an Executors section; the memory row and the configuration reference name the executor; the Safety Invariants line says that codeGeneration applies to the context's own intrinsics and that the host's constructors handed to the context carry the host's Function. The documentation word check reads the two executor files.
… an executor for forged code

A job on pull requests that touch the forge, the sandbox or the corpus. It runs a prototype QuickJS executor (quickjs-emscripten 0.32.0, installed only by the job) through the same forge as the in-process executor, and reports: awaiting host functions, the forged-tool corpus, start-up and per-call time, the memory limit, a guest that spins after a yield, and escape probes. Verdicts are evidence; only a harness error fails the job.
…d an instance per call

The first run found that QuickJS's own memory limit does not bound a guest under Emscripten: it counts only each allocation's overhead, so a guest under a 16 MB limit grew the host by about 2 GB before an allocation failed. The build imports its memory and grows it only to that memory's maximum, so the run now also measures a shared module on a capped memory and an instance per call, compiled once, on a memory capped at the call's limit. Q4 now bounds the host's RSS growth (garbage collection forced), every question runs on the per-call instance too, a new section tries QuickJS stack limits of 1 MiB, 256 KiB and 64 KiB, and each section reports the teardowns that failed.
@jddunn
jddunn marked this pull request as ready for review October 8, 2026 05:03
@jddunn
jddunn requested a review from Victor-Evogor as a code owner October 8, 2026 05:03
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@jddunn
jddunn merged commit 3c5832a into master Oct 8, 2026
6 checks passed
@sourcery-ai

sourcery-ai Bot commented Oct 8, 2026

Copy link
Copy Markdown

Sorry @jddunn, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 3 days and 11 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Add a forged-code executor interface and QuickJS evidence job

✨ Enhancement 🧪 Tests 📝 Documentation ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Let hosts supply a forged-code executor while preserving the default in-process behavior.
• Add a 61-tool corpus to test executor compatibility and brokered capabilities.
• Measure a non-shipping QuickJS prototype in CI and clarify the default executor’s isolation
 limits.
Diagram

graph TD
  Host["Host"] --> Forge["Tool Forge"] --> Contract["Executor Interface"] --> Default["In-Process Executor"] --> Sandbox["CodeSandbox"]
  Forge --> Broker["Capability Broker"] --> Contract
  Contract --> Prototype["QuickJS Prototype"]
  Corpus["Forged-Tool Corpus"] --> Default
  Corpus --> Prototype
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Ship an isolated executor immediately
  • ➕ Could provide enforceable guest memory and deadline boundaries sooner.
  • ➖ Would make production depend on an unaudited prototype whose corpus still differs on two fixtures.
  • ➖ Would require resolving runtime compatibility and memory architecture before adoption.

Recommendation: Keep the interface and evidence job separate from the production default. This preserves existing results while making isolation candidates measurable; do not treat an executor's self-declared isolates value or the prototype's passing probes as verified isolation.

Files changed (20) +3409 / -126

Enhancement (3) +154 / -122
SandboxedToolForge.tsDelegate validated forged-code runs to an executor +88/-122

Delegate validated forged-code runs to an executor

• Accepts and exposes a configurable executor while retaining validation, pre-parsing, grants, and broker integration in the forge. Maps executor outcomes back to forge results and defaults to the in-process implementation.

src/cognition/emergent/SandboxedToolForge.ts

types.tsDefine the forged-code executor contract +64/-0

Define the forged-code executor contract

• Introduces executor identity and isolation claims, per-run source, input, globals and limits, and discriminated execution outcomes.

src/cognition/emergent/executor/types.ts

index.tsExport the executor API +2/-0

Export the executor API

• Makes the in-process implementation and executor request, result, and interface types available through the emergent public barrel.

src/cognition/emergent/index.ts

Refactor (1) +87 / -0
InProcessExecutor.tsMove existing CodeSandbox execution behind the interface +87/-0

Move existing CodeSandbox execution behind the interface

• Preserves the wrapper, result marker, output parsing, error messages, and heap-delta telemetry. Explicitly declares that this in-process executor does not isolate forged code.

src/cognition/emergent/executor/InProcessExecutor.ts

Documentation (3) +81 / -3
EMERGENT_CAPABILITIES.mdDocument executor configuration and isolation limits +28/-3

Document executor configuration and isolation limits

• Explains the custom executor contract and memory budget. Clarifies that the default context receives host constructors and does not provide a security boundary.

docs/architecture/EMERGENT_CAPABILITIES.md

README.mdExplain the non-shipping executor evidence run +23/-0

Explain the non-shipping executor evidence run

• Documents its questions, component files, CI behavior, and the distinction between a failed measurement and a harness failure.

evidence/forge-executors/README.md

README.mdDocument the reusable forged-tool corpus +30/-0

Document the reusable forged-tool corpus

• Describes fixture provenance, local capability resources, expectations, and how integration tests and evidence runs share the corpus.

tests/fixtures/forged-tools/README.md

Other (13) +3087 / -1
ci.ymlInclude executor files in the isolation-documentation check +2/-1

Include executor files in the isolation-documentation check

• Extends the existing CI check so changes to the executor contract or in-process implementation are considered when validating isolation claims.

.github/workflows/ci.yml

forge-executor-evidence.ymlRun and publish QuickJS executor evidence +63/-0

Run and publish QuickJS executor evidence

• Adds a targeted and manually dispatchable job that builds the library, installs the evidence-only dependency, runs measurements, and uploads reports.

.github/workflows/forge-executor-evidence.yml

guest-prelude.cjsRecreate granted globals inside the QuickJS guest +407/-0

Recreate granted globals inside the QuickJS guest

• Builds guest-side built-ins and capability facades over data-only host bindings for compatibility testing. Removes binding names and masks globals absent from the in-process context.

evidence/forge-executors/guest-prelude.cjs

guest-surface.tsTranslate granted capabilities into guest bindings +139/-0

Translate granted capabilities into guest bindings

• Provides the evidence prototype with data-oriented bindings for encoding, URLs, fetch, file reads, and crypto, plus its guest prelude.

evidence/forge-executors/guest-surface.ts

in-process-child.tsIsolate hazardous baseline cases for measurement +31/-0

Isolate hazardous baseline cases for measurement

• Runs spinning or allocating in-process cases in a child process so the evidence harness can impose an external deadline.

evidence/forge-executors/in-process-child.ts

package.jsonScope QuickJS dependency to evidence +9/-0

Scope QuickJS dependency to evidence

• Declares quickjs-emscripten 0.32.0 in a private evidence package rather than adding it to the published library.

evidence/forge-executors/package.json

quickjs-executor.tsPrototype a QuickJS implementation of the executor contract +457/-0

Prototype a QuickJS implementation of the executor contract

• Implements shared and per-call WebAssembly variants with guest memory, stack, and deadline controls. Bridges asynchronous host functions into guest promises for the evidence run; it does not ship.

evidence/forge-executors/quickjs-executor.ts

run.tsMeasure compatibility, resource bounds, and containment +732/-0

Measure compatibility, resource bounds, and containment

• Compares QuickJS variants with the in-process executor across the corpus, async capabilities, timing, memory, spins, and escape probes. Writes JSON and Markdown reports, failing the job only for harness errors.

evidence/forge-executors/run.ts

forge-executor.test.tsTest executor requests and outcome mapping +140/-0

Test executor requests and outcome mapping

• Checks default selection, granted globals, limits, ceiling signals, result statuses, and rejected runs. Confirms invalid source and missing ceiling call handles never reach the executor.

src/cognition/emergent/tests/forge-executor.test.ts

forged-corpus.integration.spec.tsRun every forged-tool fixture on the default executor +81/-0

Run every forged-tool fixture on the default executor

• Checks corpus expectations through the forge, using the capability broker and call handles for fixtures that request capabilities.

tests/emergent/forged-corpus.integration.spec.ts

environment.tsProvide shared corpus resources and assertions +151/-0

Provide shared corpus resources and assertions

• Loads fixtures, checks their expected outcomes, and creates a local HTTP server and temporary files for capability cases.

tests/fixtures/forged-tools/environment.ts

library.jsonCapture forged code from existing library tests +236/-0

Capture forged code from existing library tests

• Records 29 existing forged-code cases with inputs and expected in-process results as a compatibility baseline.

tests/fixtures/forged-tools/library.json

written.jsonAdd broader language and capability fixtures +639/-0

Add broader language and capability fixtures

• Adds 32 cases covering computational models, JavaScript features, built-ins, and fetch, file-read, and crypto capabilities.

tests/fixtures/forged-tools/written.json

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (1) 📜 Skill insights (0)

Grey Divider


Action required

1. Benchmarks land in the source repository 📘 Rule violation ⚙ Maintainability
Description
questionTime in evidence/forge-executors/run.ts warms up the executors, repeatedly times forged
calls, and calculates latency statistics. The new workflow runs it on relevant pull requests and
uploads the results, keeping a benchmark implementation in this repository.
Code

evidence/forge-executors/run.ts[R315-318]

+  const measure = async (set: ForgeSet, fixture: CorpusFixture, n: number) => {
+    const times: number[] = [];
+    for (let i = 0; i < n + 10; i++) {
+      const outcome = await set.run(fixture.code, fixture.input, fixture.allowlist);
Evidence
Rule 10 prohibits benchmark implementations in this repository. The added timing routine performs
warm-ups and repeated measurements, and the added workflow executes the runner.

AGENTS.md: Keep Benchmarks Outside This Repository
evidence/forge-executors/run.ts[308-361]
.github/workflows/forge-executor-evidence.yml[43-48]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The evidence runner implements repeatable executor latency benchmarks in the AgentOS source repository.

## Fix Focus Areas
- evidence/forge-executors/run.ts[308-364]
- .github/workflows/forge-executor-evidence.yml[43-48]

## Recommended Fix
Move the timing benchmark and its CI execution to agentos-bench. Keep any non-benchmark compatibility or safety checks needed here separate from the timing measurements.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Large fetches bypass the guest memory cap 🐞 Bug ☼ Reliability
Description
guestSurface reads a granted fetch response completely into host memory before QuickJSExecutor
copies it into the memory-limited guest. Without a ceiling, the forge's fetch wrapper imposes no
response-size limit, so a large response can exhaust host memory before the guest's limit takes
effect.
Code

evidence/forge-executors/guest-surface.ts[80]

+      const body = new Uint8Array(await response.arrayBuffer());
Evidence
The added binding calls response.arrayBuffer() before returning data to the guest; the executor
subsequently copies byte arrays into a guest ArrayBuffer. The forge's non-brokered fetch wrapper
returns the native response without a body-size check.

evidence/forge-executors/guest-surface.ts[73-90]
evidence/forge-executors/quickjs-executor.ts[332-343]
src/cognition/emergent/SandboxedToolForge.ts[493-507]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The prototype buffers an entire fetched response on the host before the guest memory cap can apply.
## Fix Focus Areas
- evidence/forge-executors/guest-surface.ts[73-91]
- evidence/forge-executors/quickjs-executor.ts[332-343]
## Recommended Fix
Enforce a per-call response byte limit while streaming the body, cancel oversized responses, and include this case in the memory evidence.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Guest hashes grow uncapped host state 🐞 Bug ☼ Reliability
Description
guestSurface stores every new hash or keyed-hash object in a host-side Map until forged code
calls digest(). A tool granted crypto can repeatedly create objects without digesting them,
growing host memory independently of the QuickJS memory limit for the duration of its call.
Code

evidence/forge-executors/guest-surface.ts[R111-114]

+      const id = next;
+      next += 1;
+      digests.set(id, digest);
+      return id;
Evidence
Each crypto_start adds a host digest to digests; only crypto_digest deletes it. The guest
prelude exposes createHash and createHmac through this binding, while the prototype's memory
limits are set on the QuickJS runtime and WebAssembly memory, not on that host Map.

evidence/forge-executors/guest-surface.ts[100-135]
evidence/forge-executors/guest-prelude.cjs[369-395]
evidence/forge-executors/quickjs-executor.ts[120-137]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Guest-created digest objects accumulate in a host Map outside the guest memory budget.
## Fix Focus Areas
- evidence/forge-executors/guest-surface.ts[100-135]
- evidence/forge-executors/quickjs-executor.ts[185-190]
## Recommended Fix
Bound outstanding digest objects per call, reject creation beyond that bound, and add a memory probe that creates hashes without digesting them.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
Review mode: Auto: 🧠 Deep: Broad executor, sandbox, capability, CI, and evidence logic creates many independent defect opportunities.

Grey Divider

Tip of the day
💡 Did you know, you can keep summaries lean with Findings visible per group, which tucks the rest behind a View link

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment on lines +315 to +318
const measure = async (set: ForgeSet, fixture: CorpusFixture, n: number) => {
const times: number[] = [];
for (let i = 0; i < n + 10; i++) {
const outcome = await set.run(fixture.code, fixture.input, fixture.allowlist);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Benchmarks land in the source repository 📘 Rule violation ⚙ Maintainability

questionTime in evidence/forge-executors/run.ts warms up the executors, repeatedly times forged
calls, and calculates latency statistics. The new workflow runs it on relevant pull requests and
uploads the results, keeping a benchmark implementation in this repository.
Agent Prompt
## Issue description
The evidence runner implements repeatable executor latency benchmarks in the AgentOS source repository.

## Fix Focus Areas
- evidence/forge-executors/run.ts[308-364]
- .github/workflows/forge-executor-evidence.yml[43-48]

## Recommended Fix
Move the timing benchmark and its CI execution to agentos-bench. Keep any non-benchmark compatibility or safety checks needed here separate from the timing measurements.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

input,
init === null ? undefined : init,
)) as Response;
const body = new Uint8Array(await response.arrayBuffer());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

2. Large fetches bypass the guest memory cap 🐞 Bug ☼ Reliability

guestSurface reads a granted fetch response completely into host memory before QuickJSExecutor
copies it into the memory-limited guest. Without a ceiling, the forge's fetch wrapper imposes no
response-size limit, so a large response can exhaust host memory before the guest's limit takes
effect.
Agent Prompt
## Issue description
The prototype buffers an entire fetched response on the host before the guest memory cap can apply.
## Fix Focus Areas
- evidence/forge-executors/guest-surface.ts[73-91]
- evidence/forge-executors/quickjs-executor.ts[332-343]
## Recommended Fix
Enforce a per-call response byte limit while streaming the body, cancel oversized responses, and include this case in the memory evidence.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +111 to +114
const id = next;
next += 1;
digests.set(id, digest);
return id;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

3. Guest hashes grow uncapped host state 🐞 Bug ☼ Reliability

guestSurface stores every new hash or keyed-hash object in a host-side Map until forged code
calls digest(). A tool granted crypto can repeatedly create objects without digesting them,
growing host memory independently of the QuickJS memory limit for the duration of its call.
Agent Prompt
## Issue description
Guest-created digest objects accumulate in a host Map outside the guest memory budget.
## Fix Focus Areas
- evidence/forge-executors/guest-surface.ts[100-135]
- evidence/forge-executors/quickjs-executor.ts[185-190]
## Recommended Fix
Bound outstanding digest objects per call, reject creation beyond that bound, and add a memory probe that creates hashes without digesting them.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

github-actions Bot pushed a commit that referenced this pull request Oct 8, 2026
## [0.12.10](v0.12.9...v0.12.10) (2026-10-08)

### feat

* **emergent:** forged code runs through an executor interface, and a CI run measures QuickJS (#148) ([3c5832a](3c5832a))

### docs

* audit follow-ups to the GMI step contract and gateway docs (#147) ([000547a](000547a))
* **gmi:** correct the step contract and document completion options, history and the gateway (#145) ([ff883a4](ff883a4))

### ci

* check that package exports point at built files (#146) ([fee43be](fee43be))
@jddunn
jddunn deleted the feat/forge-executor-seam branch October 10, 2026 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant