Skip to content

feat(taskpack,cas): decouple taskpack engine and stream CAS blob pointers - #32

Merged
thxCode merged 43 commits into
mainfrom
decouple-taskpack-and-blob-pointers
Nov 21, 2026
Merged

thxCode merged 43 commits into
mainfrom
decouple-taskpack-and-blob-pointers

Conversation

@thxCode

@thxCode thxCode commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Extract generic declarative Taskpack parsing, compilation, digest pinning, SemVer upstream discovery, model pool selection, OS sandboxing (macos-seatbelt, linux-bwrap, linux-landlock, docker, direct-dedicated), preflight staging, command.v1 loopback gate execution, step staging, and local memory finalization into @loopwright/taskpack, keeping @loopwright/github-app focused on GitHub intake, App token scoping, trigger gating, and pull-request publication while re-exporting @loopwright/taskpack with shared GitHubAppError identity.
  • Replace inline base64 and whole-file memory transport across core, agent-pi, controller, taskpack, taskpack-runner, and github-app with immutable Content-Addressable Storage (CAS) blob pointers (blobs/sha256/<hex>), scaling overlay budgets up to 16,384 files and 16 GiB via 1 MiB streaming chunks, single-descriptor O_NOFOLLOW (nlink === 1) projections, descriptor-minted VERIFIED_CAS_SEAL verification, sliding-window derived-form secret scrubbing, and direct regular-file descriptor streaming into git -c core.bigFileThreshold=1m hash-object -w --stdin.
  • Scope GitHub-specific policy defaults (spec.triggers, pull-request spec.publication, .github protection, and dual-key .github/workflows/** unlock) to 'github' policy-profile entrypoints with durable hostPolicy binding across resume, reconcile, and step, while supporting 'local' taskpacks with optional triggers, publication, and memory, neutral repository-declared scope.protected, and direct loopwright run --taskpack CLI execution.
  • Harden OS sandbox containment across macOS and Linux: enforce positive RUNNER_ENVIRONMENT=github-hosted runner identity, positive command.v1 read grants with per-stage Seatbelt helper bounds, offline AF_UNIX-only + io_uring-blocking seccomp BPF on bwrap and Landlock, O_NOFOLLOW descriptor-relative Landlock rules declining nested writable exclusions, post-mount bwrap deniedReadPaths masks and argc bounds, and hybrid mountReadOnlyGit skeleton staging.
  • Verification covers full workspace build, typecheck, lint, docs lint, Hugo site generation and link verification, all workspace package test suites, and the 14-scenario closure --verify-failures matrix on macOS; Linux-only bwrap and Landlock execution tests run in Linux CI.

/kind feature
/area core
/area state
/area agent-pi
/area controller
/area taskpack-runner
/area github-app
/area cli
/area docs
/area site

Related Issues

NONE

Verification

  • npm run build passed cleanly
  • npm run typecheck passed cleanly
  • npm run lint passed cleanly
  • npm run lint:docs passed cleanly
  • npm run site built and verified with zero broken links
  • Focused tests passed (npm test across all workspace packages and loopwright closure --verify-failures --json)
  • OS sandbox diagnostics verified if touching runtime (macos-seatbelt, linux-bwrap, linux-landlock, docker)
  • Verified .github/workflows/ maintains least-privilege permissions and remains protected against untrusted taskpack/sandbox writes
  • Signed-off-by: Full Name <email> Developer Certificate of Origin (DCO) included on all commits

Does this PR introduce a user-facing change?

Add `@loopwright/taskpack` and `loopwright run --taskpack` for local declarative Taskpack execution with optional triggers, publication, and memory, and adopt 1 MiB content-addressable blob pointers supporting candidate overlays up to 16,384 files and 16 GiB.

- Register packages/taskpack across root workspaces, lockfile, test tsconfig, and review rules
- Add taskpack build, test runner, and npm pack workspace entries
- Scaffold @loopwright/taskpack composite tsconfig, package manifest, entrypoint, and boundary test

Task 1 of decouple-taskpack-and-cas-blob-pointers.

Signed-off-by: thxCode <thxcode0824@gmail.com>
- Raise OVERLAY_LIMITS.maxMaxBytes to 16 GiB while preserving raw memory byte caps
- Add digestArtifactFromMetadata with JCS parity and empty-digest invariants
- Accept VerifiedArtifactDescriptor in resolveInventory, evaluateAcceptance, and constructRunResult
- Add unit tests for 16 GiB descriptors, JCS parity, and refusal boundaries

Task 2 of decouple-taskpack-and-cas-blob-pointers.

Signed-off-by: thxCode <thxcode0824@gmail.com>
- Write crash-safe CAS blobs and blob_ref workspace rows in captureCheckpoint
- Verify streaming blob_ref pointers and legacy chunk rows across decode and recovery
- Accept PiCandidateBlobArtifact descriptors in preflight and stream candidate materialization
- Raise fileBytes and artifactBytes ceilings to 16 GiB while preserving control caps

Task 3 of decouple-taskpack-and-cas-blob-pointers.

Signed-off-by: thxCode <thxcode0824@gmail.com>
- Implement atomic CAS blob ingestion and single-fd O_NOFOLLOW verification in storage
- Add byte-level derived-form sliding-window secret scrubber across 64 KiB chunk boundaries
- Remove hardcoded tool paths and scope GitHub workflow protection in source
- Decouple v2WorkspaceJsonMaxBytes and raise verifier-protocol overlay header cap to 16 GiB

Task 4 of decouple-taskpack-and-cas-blob-pointers.

Signed-off-by: thxCode <thxcode0824@gmail.com>
- Extract TaskpackError, YAML 1.2 parser, models-config, qualification, and stream scrubber
- Implement local and github policy profiles with optional triggers, publication, and memory
- Remove hardcoded tool paths across schema and sandboxes while preserving proposal carve-out
- Add 64 KiB streaming digests and injectable-auth SemVer upstream discovery

Task 6 of decouple-taskpack-and-cas-blob-pointers.

Signed-off-by: thxCode <thxcode0824@gmail.com>
- Stream delegated-capture.v2 CAS pointers with zero unchanged baseline writes.
- Persist and enforce hostPolicy across run, resume, reconcile, and step.
- Scale scheduling, verification, triage, submission, and acceptance for CAS blobs.
- Export verified candidate.files.json v2 pointers in inspectRun with v1 fallback.

Task 5 of decouple-taskpack-and-cas-blob-pointers.

Signed-off-by: thxCode <thxcode0824@gmail.com>
- Scale CAS chunks to 1 MiB and overlays to 16384 files and 16 GiB
- Stream CAS projections via single owned descriptors and descriptor-verified seals
- Enforce O_NOFOLLOW Landlock rules, offline socket BPF, and bwrap mount order
- Snapshot Pi admission inputs synchronously and bound bwrap argument counts

Task 5b of decouple-taskpack-and-cas-blob-pointers.

Signed-off-by: thxCode <thxcode0824@gmail.com>
- Extract declarative compiler with local defaults and auto-scaled overlay limits
- Stage workspace preflight resources via single-descriptor 1 MiB streaming
- Implement hybrid mountReadOnlyGit skeleton with ro-bind or streamed git objects
- Add CAS v2 command.v1 gate server, step staging, and local memory finalizer

Task 7 of decouple-taskpack-and-cas-blob-pointers.

Signed-off-by: thxCode <thxcode0824@gmail.com>
- Remove hardcoded tool subpaths and support local vs github policy profiles
- Decode v2 blob_ref checkpoints with 1 MiB streaming SHA-256 verification
- Verify v2 overlay baseTree anchors and resolve unchanged baseline proposals
- Pass pointer-index files to GATE_DRIVER and prune deleted directories

Task 8 of decouple-taskpack-and-cas-blob-pointers.

Signed-off-by: thxCode <thxcode0824@gmail.com>
- Re-export @loopwright/taskpack with shared GitHubAppError constructor identity
- Enforce policyProfile github, positive runner identity, and trigger checks
- Pass verified CAS descriptors directly to git hash-object with constant RSS
- Enforce positive command.v1 mounts, isolated tree staging, and deletion checks

Task 9 of decouple-taskpack-and-cas-blob-pointers.

Signed-off-by: thxCode <thxcode0824@gmail.com>
- Wire @loopwright/cli to @loopwright/taskpack and lazy-load app-serve
- Add mutually exclusive loopwright run --taskpack with dry-run support
- Start command gates fail-fast before invoking local turnkey cycles
- Update closure matrix and npm-pack checks across workspace packages

Task 10 of decouple-taskpack-and-cas-blob-pointers.

Signed-off-by: thxCode <thxcode0824@gmail.com>
- Declare .claude, CLAUDE.md, and AGENTS.md in .auto-sync scope.protected
- Add packages/taskpack/package.json and taskpack-manifest-keys guard
- Harden verify.sh offline seccomp BPF and runner containment checks
- Re-sync deterministic digests.lock.json for tracked scripts and docs

Task 11 of decouple-taskpack-and-cas-blob-pointers.

Signed-off-by: thxCode <thxcode0824@gmail.com>
- Document @loopwright/taskpack, local vs github profiles, and run --taskpack
- Update coding-agents and loopwright-step apply snippets for v2 CAS pointers
- Document 1 MiB descriptor streaming, 16 GiB overlays, and runner containment
- Remove hardcoded package counts and mark specification Shipped

Task 12 of decouple-taskpack-and-cas-blob-pointers.

Signed-off-by: thxCode <thxcode0824@gmail.com>
- Use short /tmp socket directory on macOS CAS tests

Signed-off-by: thxCode <thxcode0824@gmail.com>
…nd turnkey

- Allow dedicated hosted-runner loopback fallback under Landlock

Signed-off-by: thxCode <thxcode0824@gmail.com>
…lisher

- Set hosted-runner env in turnkey-action negative tests

Signed-off-by: thxCode <thxcode0824@gmail.com>
…packages

- Clear ambient CI tokens in self-upgrade auto mode tests

Signed-off-by: thxCode <thxcode0824@gmail.com>
…packages

- Clear GITHUB_API_URL in self-upgrade auto no-change test

Signed-off-by: thxCode <thxcode0824@gmail.com>
- Enforce read-only owner-checked source blobs in CAS chunk and copy readers

Signed-off-by: thxCode <thxcode0824@gmail.com>
…d sandbox

- Harden upstream pagination/git env and multi-provider model pinning

Signed-off-by: thxCode <thxcode0824@gmail.com>
…nd turnkey

- Rethrow TaskpackError and avoid mutating suffix order in path canonicalizer

Signed-off-by: thxCode <thxcode0824@gmail.com>
…driver

- Open gate destination with O_NOFOLLOW and bind cache hits to host policy

Signed-off-by: thxCode <thxcode0824@gmail.com>
…lisher

- Preserve taskpack policyProfile in turnkey delegate and widen upstreams options

Signed-off-by: thxCode <thxcode0824@gmail.com>
…ading

- Reject duplicate author role overrides and omit undefined role models

Signed-off-by: thxCode <thxcode0824@gmail.com>
@gpustack-code-review

gpustack-code-review Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

🔍 OpenCodeReview found 60 issue(s) in this PR.

  • ✅ Successfully posted inline: 27 comment(s)
  • 📝 In summary (no line info): 1 comment(s)
  • 📋 Routed to summary by policy: 32 comment(s)

⚠️ 3 warning(s) occurred during review.


security · medium

📄 packages/github-app/package.json,packages/github-app/src/action.ts,packages/github-app/src/config.ts,packages/github-app/src/digests.ts,packages/github-app/src/index.ts,packages/github-app/src/models-config.ts,packages/github-app/src/output-format.ts,packages/github-app/src/preflight.ts,packages/github-app/src/publisher.ts,packages/github-app/src/qualification.ts

⚠️ GitHub could not post this as an inline comment: No line information provided

The publisher server accepts an arbitrary host option (options.host ?? '127.0.0.1') without validating that it is a loopback address. This endpoint can push branches with --force-with-lease and create/modify pull requests on the target repository using the server's git write token, guarded only by in-memory bearer/HMAC secrets. If any caller (now or in the future — this is a public export) passes 0.0.0.0, a hostname, or a container-bridged interface, the endpoint becomes network-reachable. Fail closed by asserting the host is 127.0.0.1 / ::1 (or at minimum reject 0.0.0.0, ::, and non-loopback literals) before server.listen.

💡 Suggested Change

Before:

  const host = options.host ?? '127.0.0.1';
  const fetchImpl = options.fetchImpl ?? globalThis.fetch;

After:

  const host = options.host ?? '127.0.0.1';
  if (host !== '127.0.0.1' && host !== 'localhost' && host !== '::1') {
    throw new GitHubAppError(
      'ACTION_INPUT_INVALID',
      `native pull request publisher must bind a loopback host, got "${host}"`,
    );
  }

documentation · low

📄 README.md (L57-L61)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category documentation)

The new loopwright run --taskpack ... example is placed under the heading "To run Managed Controller cycles or repository audits locally (requires the runner...)", but it demonstrates Declarative Taskpack Mode, not Managed Controller mode. Consider moving it above the heading or into the taskpack mode section to keep entry points accurate.


maintainability · low

📄 packages/controller/src/capture.ts (L618-L618)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category maintainability)

phase === 'recovery' ? 'ARTIFACT_INVALID' : 'ARTIFACT_INVALID' is a dead conditional — both branches return the same value. Either the recovery branch was intended to use a different code (e.g. RECOVERY_REQUIRED, as the surrounding recovery paths do), or the ternary should be removed and code simplified to a direct reference.

💡 Suggested Change

Before:

  const code: ControllerDiagnostic['code'] = phase === 'recovery' ? 'ARTIFACT_INVALID' : 'ARTIFACT_INVALID';

After:

  const code: ControllerDiagnostic['code'] = 'ARTIFACT_INVALID';

maintainability · low

📄 packages/controller/src/bundle.ts (L14-L14)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category maintainability)

The per-file (32 MiB) and total (64 MiB) limits are new hardcoded literals; sibling bounds (overlay budgets, workspace maxima) live in shared helpers like overlayManifestBounds. Derive these from (or define alongside) those constants so the limits don't drift independently across capture/inspection paths.


performance · low

📄 packages/controller/src/parser.ts (L106-L107)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category performance)

Raising the collection cap to 65 536 and scaling nodeLimit to collectionLimit * 24 (up to ~1.5M nodes) materially increases peak memory when parsing untrusted checkpoint bytes on recovery paths. If the increase exists specifically to accommodate larger v2 workspace JSON, consider bounding it by the byte maximum that callers actually pass (e.g. clamp nodeLimit relative to maximum) so a small document cannot request an oversized node budget.


bug · low

📄 docs/operations/coding-agents.md (L330-L330)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category bug)

The v2 validation loop checks sha256, uri, byteLength, and blobPath, but never validates file.mode. An unexpected mode value (e.g. "100600", a typo, or a missing field in a hand-edited bundle) silently falls through file.mode === "100755" ? 0o755 : 0o644 and is applied as 0644, losing the executable bit or masking a malformed bundle. Consider rejecting anything other than "100644"/"100755" in the v2 branch.

💡 Suggested Change

Before:

    if (!Number.isSafeInteger(file.byteLength) || file.byteLength < 0 || typeof file.blobPath !== "string" || !path.isAbsolute(file.blobPath)) throw new Error(`Invalid blobPath: ${file.name}`);

After:

    if (!Number.isSafeInteger(file.byteLength) || file.byteLength < 0 || typeof file.blobPath !== "string" || !path.isAbsolute(file.blobPath)) throw new Error(`Invalid blobPath: ${file.name}`);
    if (file.mode !== "100644" && file.mode !== "100755") throw new Error(`Invalid mode: ${file.name}`);

performance · low

📄 docs/operations/coding-agents.md (L331-L331)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category performance)

The validation loop fully hashes every v2 blob, and the write loop (line 360) hashes each blob again while streaming it to the temp file — including the in-place mutation check. For the common case where every file is written, each blob is read twice from disk. Since the write path already verifies the digest (and throws before rename on mismatch), the pre-pass hash of blobPath is redundant for files that will be written; it is only needed for the unchanged skip check (which hashes target, not blobPath). Consider validating only the CAS ref shape here and deferring the full blob read to the write loop, or caching digests between passes.

💡 Suggested Change

Before:

    if (streamHash(file.blobPath, file.byteLength, null) !== file.sha256) throw new Error(`Digest mismatch: ${file.name}`);

After:

    // Ref shape validated; digest is verified while streaming in the write loop below.
    if (!path.isAbsolute(file.blobPath)) throw new Error(`Invalid blobPath: ${file.name}`);

maintainability · low

📄 packages/controller/src/budget-observations.ts (L123-L123)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category maintainability)

The inline-bytes budget cap 268_435_456 is a new hardcoded magic literal, and it appears both here and (as the previous fixed total cap) nowhere else in shared bounds. Other limits in this function come from bounds (bounds.maxBytes, etc.). If the inline/rawTotal cap is a deliberate constant, define it once (e.g. alongside OVERLAY_LIMITS or in overlayManifestBounds) so it cannot drift from the CAS-aware caps applied in capture.ts/inspect.ts.


maintainability · low

📄 packages/controller/src/files.ts (L206-L206)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category maintainability)

disableReflink is declared in CopyVerifiedFileOptions but never read anywhere in copyVerifiedFileReadOnly — the implementation always uses the read/write staging loop and never attempts a reflink. Dead option; either remove it or rename/document that reflink is intentionally not used.


bug · low

📄 packages/controller/src/controller.ts (L709-L713)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category bug)

Swallowing readSubmissionCandidateBytes failures and treating the file as absent masks integrity errors: if the CAS blob backing the submission-path file is missing or digest-mismatched, failedRaw silently falls back to captured.submission, hiding the corrupted-artifact condition from downstream repair/diagnostics. Consider distinguishing verification failures (refuse with the appropriate diagnostic) from a genuinely absent file, similar to the concern raised for the addedLines fallback in the diff-summary path.


security · low

📄 packages/agent-pi/src/recovery.ts (L82-L82)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category security)

ref.digest.hex (from the candidate manifest) is joined directly into canonicalBlobPath without a local hex-format check. Preflight does validate artifact.digest and match it to the manifest ref via sameIdentity, so in the normal flow the hex is well-formed, but recovery.ts itself never validates manifest entry digests — for manifest entries without a matching artifact, or if this function is ever reused outside the post-preflight path, a corrupted manifest digest string (e.g. containing ../) would be joined into a filesystem path. The subsequent size/content verification would almost certainly refuse it, so this is defense-in-depth, but given the CAS path is constructed from snapshot-derived data, validate the format locally (e.g. validateDigest(ref.digest, '/restore/workspace') or a /^[a-f0-9]{64}$/ test) before join.

💡 Suggested Change

Before:

      const canonicalBlobPath = join(verifiedSha256Dir, ref.digest.hex);

After:

      validateDigest(ref.digest, '/restore/workspace');
      const canonicalBlobPath = join(verifiedSha256Dir, ref.digest.hex);

performance · low

📄 packages/agent-pi/src/recovery.ts (L111-L112)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category performance)

For blob-backed artifacts, every 32KB chunk row triggers a fresh open + double fstat + close of the same blob file via readBlobChunkAsync. A 64MB artifact (the RAW_ARTIFACT_MAX_BYTES ceiling) means ~2048 open/stat/close cycles and ~4k fstat calls per restore, each with TOCTOU checks. Consider keeping a single open, verified FileHandle for the duration of the current file (opened after the file row, closed at file_end) or reading larger spans per row, which preserves the same integrity properties while removing the per-chunk syscall amplification.


bug · low

📄 packages/agent-pi/src/session-host.ts (L78-L78)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category bug)

recoverSnapshot is now async and performs filesystem I/O (CAS dir verification, blob reads) with no timeout, and it is awaited before the existing restore-complete 90s wait is armed. Previously it was pure CPU; now a stalled CAS read (NFS/FUSE/hung mount under host.artifactsDirectory) blocks RuntimeSession startup indefinitely with no failure signal. Consider bounding recovery with a deadline consistent with the other restore waits (e.g. race against a timer or pass an AbortSignal) so the session fails fast instead of hanging.


bug · low

📄 packages/cli/src/main.ts (L613-L614)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category bug)

When the manifest declares spec.roles, an override strips the role's models pool via destructuring (const { models: _unusedModels, ...roleBase } = role;) and pins provider/model without any warning. Since models is a validated per-role pool reference (schema.ts:3168-3187), the operator silently loses the manifest-pinned model pool, and the resulting compiled manifest (and any digest derived from it) diverges from the authored one. Consider refusing the override when the role declares a models pool (like other ambiguity refusals here), or at least recording it in diagnostics.


bug · low

📄 packages/controller/src/storage.ts (L525-L529)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category bug)

In the EEXIST race path, if the competing writer's link()+unlink() pair has not dropped nlink to 1 after the bounded 20×5ms poll, streamVerifiedCasBlobWithSummary (which enforces nlink===1 via streamRegularFile) hard-refuses with ARTIFACT_INVALID — a transient contention window turns into a permanent, non-retryable run failure even though the blob is legitimately present and content-identical. Consider either marking this outcome retryable (or re-ingesting after the wait) instead of fail-closed refusal, since the content is verifiably correct by digest.


maintainability · low

📄 packages/controller/src/storage.ts (L411-L423)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category maintainability)

The VerifiedCasSeal construction (dev/ino/mtimeMs/ctimeMs/size/gitOid from a streamVerifiedCasBlobWithSummary result) is duplicated verbatim here and in #ingestCasBlob's EEXIST branch. Extract a small helper (e.g. sealFromVerified(blobPath, sha256, verified, gitObjectFormat)) so the two paths can't drift.


maintainability · low

📄 packages/core/src/artifacts.ts (L267-L269)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category maintainability)

The raw/verified discrimination is shape-based (exact key count + presence of specific keys), so a plausible malformed input like { name, bytes, digest } or { name, byteLength, bytes } fails with a generic INPUT_UNSUPPORTED at the item path, with no hint which variant was attempted or which key is unexpected. Since both branches already enumerate keys, consider emitting a more actionable diagnostic (e.g. include the offending key set or point at the extra key) to spare callers a debugging round-trip.


bug · low

📄 packages/cli/src/main.ts (L328-L329)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category bug)

Behavior change vs. the previous runDigestCommand: an absolute --taskpack path outside the repository root used to fall through and be passed as-is to loadDeclarativeTaskpack; it now hard-fails with TASKPACK_MANIFEST_INVALID ('taskpack manifest escapes the repository root'). If this hardening is intentional it should be reflected in the docs/help for digest sync (and run --taskpack), since manifests living outside the checkout were previously accepted; otherwise consider keeping the escape for the digest command or emitting a distinct error code (the current message 'escapes the repository root' maps to exit 2 under TASKPACK_MANIFEST_INVALID, which is misleading for a path-location failure rather than a manifest-content failure).


security · low

📄 packages/agent-pi/src/cas.ts (L507-L509)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category security)

verifyCasBlobAsync checks type/nlink/mode but never checks the blob's uid ownership (checkOwnerAndMode with the current uid), unlike readBlobChunkAsync and the publish path in this same file. A blob owned by another local uid (e.g., planted by a different service user before mode was sealed, or a setuid-writable race) would be accepted. The sha256 match bounds content, but for consistency with the rest of the CAS containment checks the owner should be verified on both the lstat and fd stat identities.


maintainability · low

📄 packages/agent-pi/src/cas.ts (L709-L711)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category maintainability)

The if (error instanceof PiFailure) branch is dead code — both it and the following line refuse with the identical error. Collapse to a single refuse(...) call.


bug · low

📄 packages/core/src/artifacts.ts (L255-L257)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category bug)

Raw and verified entries are budgeted against two independent totals (rawTotal vs verifiedTotal). Previously all entries shared a single running total, so a mixed inventory of raw and verified descriptors can now reach LIMITS.resolvedBytes + OVERLAY_LIMITS.maxMaxBytes of declared content, silently exceeding the historical LIMITS.resolvedBytes cap for the raw portion's co-existence. If the intent is that verified (CAS-pointer) entries are exempt from the in-memory budget, consider at least documenting that here; otherwise accumulate both into one total for the raw path so the old invariant (sum of all resolved bytes ≤ LIMITS.resolvedBytes for in-memory bytes) stays observable.


performance · low

📄 packages/github-app/src/publisher.ts (L1072-L1072)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category performance)

receiptCache grows without bound: every request carrying an idempotencyKey inserts a receipt and entries are never evicted. On a long-lived server handling many publications this is an unbounded memory leak (each receipt also retains scrubbed reason strings). Bound the cache (e.g. LRU cap or TTL eviction) or accept only keys from a fixed expected set per run.

💡 Suggested Change

Before:

  const receiptCache = new Map<string, PublicationReceiptPayload>();

After:

const MAX_RECEIPT_CACHE_ENTRIES = 256;
const receiptCache = new Map<string, PublicationReceiptPayload>();
// on insert:
if (receiptCache.size >= MAX_RECEIPT_CACHE_ENTRIES) {
  receiptCache.delete(receiptCache.keys().next().value as string);
}
receiptCache.set(idempotencyKey, receipt);

security · low

📄 packages/github-app/src/publisher.ts (L1096-L1100)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category security)

The bearer token is compared with a plain !== string comparison, which is not constant-time. The HMAC signature path uses verifySignedPayload (presumably timingSafeEqual); the auth token check should do the same to avoid a timing oracle on the token, even on a loopback interface where local processes could probe it.

💡 Suggested Change

Before:

    const authHeader = req.headers['authorization'];
    if (authHeader !== `Bearer ${authToken}`) {
      writePlainJsonResponse(res, 401, { error: 'invalid_bearer_token' });
      return;
    }

After:

    const authHeader = req.headers['authorization'];
    const expected = `Bearer ${authToken}`;
    const provided = Buffer.from(authHeader ?? '', 'utf8');
    const expectedBuf = Buffer.from(expected, 'utf8');
    if (provided.length !== expectedBuf.length
      || !timingSafeEqual(provided, expectedBuf)) {
      writePlainJsonResponse(res, 401, { error: 'invalid_bearer_token' });
      return;
    }

maintainability · low

📄 packages/github-app/src/action.ts (L125-L135)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category maintainability)

The fabricated gate object uses scriptSha256: '0'.repeat(64), a hard-coded timeoutSeconds: 30, and a synthetic gateId/endpointRef. Today validateGateToolchainPath only reads allowPrivileged, so this works, but the dummy digest and timeout are misleading (suggesting hash/timeout enforcement that doesn't exist) and will silently break if validateGateToolchainPath ever consumes more gate fields. Consider passing only the fields actually needed (e.g. change the signature to take allowPrivileged: boolean) or compute the real script digest.


maintainability · low

📄 packages/github-app/src/action.ts (L1372-L1372)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category maintainability)

This condition is redundant: needsNativePublicationEndpoint is already defined as manifest.spec.publication.mode === 'pull_request' && ... (line 942), so the second conjunct is always true here. Either drop it or add a comment if it is defensive against future publication modes; as written it implies there is a path where needsNativePublicationEndpoint is true for non-pull_request modes, which there is not.


maintainability · low

📄 packages/github-app/src/action.ts (L169-L173)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category maintainability)

extractPreliminaryCommentCommand re-implements the payload-shape and bot-author filtering that evaluateCommentPayload (just below) also performs. If the two implementations drift (e.g. one adds a new non-created action or bot heuristic), the preliminary spec.triggers.commentCommands gate and the authoritative evaluation can disagree, making the refusal check inconsistent. Consider deriving the preliminary command from evaluateCommentPayload's result (or sharing its payload-extraction helpers) instead of duplicating the filtering rules.


maintainability · low

📄 packages/github-app/src/service.ts (L308-L311)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category maintainability)

The two 'ignored' branches (no pinned manifest / trigger not declared) duplicate the identical getDelivery → markDeliveryState('succeeded') → respond-with-TASKPACK_TRIGGER_UNSUPPORTED sequence. Consider extracting a small helper (e.g. ignoreDelivery(headerDeliveryId, reason)) so the acknowledgement semantics stay consistent if one branch ever changes.


maintainability · low

📄 packages/github-app/src/taskpack.ts (L6-L7)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category maintainability)

These newly re-exported names (boundUtf8Lines, buildDefaultAuthorPrompt, createTaskpackDecisionPort, mergeMcpServerDeclarations, parseMcpServersOverride, resolveExternalMcpConfigs, serializeActionResultSummary, insideRoot and their types) have no in-repo consumer via './taskpack.js': action.ts imports them directly from '@loopwright/taskpack', and index.ts already does export * from '@loopwright/taskpack'. Consider trimming this barrel to only the names github-app actually imports through it, to avoid maintaining a hand-curated duplicate of the @loopwright/taskpack surface (drift risk whenever that package adds/renames exports).


maintainability · low

📄 packages/github-app/src/turnkey.ts (L88-L91)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category maintainability)

The @loopwright/taskpack package exports both executeTurnkeyActionCycle (index.ts line 328) and executeTurnkeyCycle (line 329), and this file defines a third near-identical entry point executeTurnkeyActionCycle that delegates to executeTurnkeyCycle with a 'github' policyProfile default. Three entry points for the same operation make it easy for a future caller to import the taskpack version directly and silently lose the 'github' profile default. Consider having the taskpack package export a single canonical entry point (or naming this wrapper distinctly, e.g. executeGithubTurnkeyActionCycle) so the profile-defaulting behavior lives in exactly one place.


maintainability · low

📄 packages/github-app/src/upstreams.ts (L76-L78)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category maintainability)

The user-agent rewrite only fires when init.headers is a plain record with the exact lowercase key user-agent set to 'loopwright-taskpack'. This is correct for how @loopwright/taskpack currently builds headers (all lowercase record literals), but it silently no-ops if the shared package ever passes a Headers instance, an array of tuples, or a differently-cased key — the github-app UA identity would leak without any test failure here. Consider normalizing via new Headers(init.headers) (case-insensitive) or asserting/documenting the coupling to taskpack's lowercase record header form.

💡 Suggested Change

Before:

    if (init?.headers !== undefined && !(init.headers instanceof Headers) && !Array.isArray(init.headers)) {
      const record = init.headers as Record<string, string>;
      if (record['user-agent'] === 'loopwright-taskpack') {

After:

function withGitHubAppUserAgent(fetchImpl?: typeof globalThis.fetch): typeof globalThis.fetch {
  const base = fetchImpl ?? globalThis.fetch;
  return (input, init) => {
    if (init?.headers !== undefined) {
      const headers = new Headers(init.headers);
      if (headers.get('user-agent') === 'loopwright-taskpack') {
        headers.set('user-agent', 'loopwright-github-app');
        return base(input, { ...init, headers });
      }
    }
    return base(input, init);
  };
}

maintainability · low

📄 packages/github-app/src/yaml.ts (L1-L5)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category maintainability)

The parseYamlDocument re-export appears to be dead surface for this module: no github-app source imports it from './yaml.js' (only serializePrettyYaml in action.ts and readBoundedRegularFile in config.ts are consumed), and index.ts already does export * from '@loopwright/taskpack'. Consider limiting the shim to the two symbols github-app actually uses, or re-exporting directly from '@loopwright/taskpack' at the call sites for clarity.


maintainability · low

📄 packages/github-app/src/types.ts (L1-L1)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category maintainability)

export * from '@loopwright/taskpack' re-exports the entire taskpack public surface (including implementation-level utilities such as execGit, SecretScrubber, and sandbox compilers) to every consumer of @loopwright/github-app. The PR only needs the shared types/constants plus the GitHubAppError identity alias, so the wildcard erodes the package boundary the extraction is meant to establish: any future internal export added to @loopwright/taskpack's index silently becomes part of @loopwright/github-app's API, and any name later added to both modules risks shadowing or ambiguity with the locally declared webhook/queue/token types below. Consider enumerating the re-exported names (or re-exporting only ./types.js types via export type * plus the specific values) instead of a star export.


maintainability · low

📄 packages/state/src/boundary.ts (L8-L8)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category maintainability)

wideCheckpointBytes raised 4x from 2 MiB to 8 MiB with no rationale and no coordinated bump documentation. Checkpoints between 2–8 MiB pass new code but are rejected by older verifiers/siblings, an offline-parity and frozen-corpus concern. Add a comment documenting the reason and confirm all consumers of this limit were updated in lockstep.


⚠️ Warnings:

  • packages/taskpack/package.json (token_budget_reached): stopped dispatch: used 8775212 tokens + group estimate 1230152 = projected 10005364 exceeds budget 10000000
  • docs/contribute/closure-matrix.md,docs/contribute/evidence.md,docs/contribute/github-app-internals.md,docs/contribute/internals.md,docs/contribute/pi-adapter.md,docs/contribute/runner-taskpack.md,docs/contribute/state.md (review_limit_reached): reached the aggregate token budget before finishing; the grace round completed the task
  • packages/state/src/boundary.ts,packages/taskpack-runner/src/compile-taskpack.ts,packages/taskpack-runner/src/parity.ts,packages/taskpack-runner/src/python-bridge.ts,packages/taskpack-runner/src/service.ts (review_limit_reached): reached the aggregate token budget before finishing; the grace round did not complete the task

Comment on lines +1387 to +1391
is_dedicated_runner = (
os.environ.get("GITHUB_ACTIONS") == "true"
and runner_env == "github-hosted"
and not has_macos_sb_helper
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

security · medium
is_dedicated_runner now trusts additional environment variables (RUNNER_ENVIRONMENT == "github-hosted", absence of LOOPWRIGHT_MACOS_SB_SOCK) to skip OS containment entirely. These are forwarded from the check invocation environment (taskpack.yaml env passthrough includes RUNNER_ENVIRONMENT). If a candidate-influenced context can set GITHUB_ACTIONS=true / RUNNER_ENVIRONMENT=github-hosted / clear the socket var, containment is silently bypassed. Confirm these values are only ever set by trusted runner infrastructure and cannot be influenced by the candidate being verified; documenting that invariant here would help.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not changed (intentional boundary): startLocalCommandGateServer builds the command.v1 environment purely from the trusted host runner environment, so candidate files cannot inject GITHUB_ACTIONS or RUNNER_ENVIRONMENT, and LOOPWRIGHT_MACOS_SB_SOCK is injected by the gate server on macOS to force Seatbelt stage containment.

Comment on lines 1590 to +1591
if hugo_bin:
add_tool_read_root(os.path.dirname(hugo_bin))
add_tool_read_root(hugo_bin)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

maintainability · medium
The hugo read grant changed from the binary's directory to the binary file itself. Hugo distributions are usually self-contained, but if hugo resolves through a wrapper script or a toolchain dir with sibling resources/config, contained stages will now fail to read them. Also note every other tool here (node, python, npm) grants its directory, so this is inconsistent — if least-privilege was the intent, consider applying the same file-level rule to the other tools or verifying hugo needs nothing adjacent.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not changed (intentional least privilege): hugo is a standalone static binary and os.path.realpath resolves any symlink wrapper upfront; granting only the binary path avoids exposing sibling tools in shared binary directories.

Comment on lines +1815 to +1818
(0x20, 0, 0, 16),
(0x15, 0, 1, 1),
(0x06, 0, 0, 0x7FFF0000),
(0x06, 0, 0, deny_errno),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

security · critical
The socket-domain comparison in the seccomp filter is inverted. Instruction (0x15, 0, 1, 1) is jeq AF_INET, jt=0, jf=1: when domain == AF_INET it falls through to the next instruction, which is RET ALLOW (0x7FFF0000), and any other domain (AF_UNIX=1? no — AF_INET is 1, AF_UNIX is 1? note: on Linux AF_UNIX==1 and AF_INET==2) jumps to RET ERRNO. Consequence: socket(AF_INET) (the IP family you intend to block) is ALLOWED, while AF_UNIX/AF_INET6 sockets are denied — the exact opposite of the no-IP goal, and it will also break legitimate AF_UNIX usage inside contained stages. Fix by flipping the jump offsets to (0x15, 1, 0, 1) — and consider also denying AF_INET6 (10), which the current single comparison ignores on either polarity.

Suggestion:

Suggested change
(0x20, 0, 0, 16),
(0x15, 0, 1, 1),
(0x06, 0, 0, 0x7FFF0000),
(0x06, 0, 0, deny_errno),
(0x20, 0, 0, 16),
(0x15, 1, 0, 1), # AF_INET -> deny (next insn), others allow
(0x15, 1, 0, 10), # AF_INET6 -> deny, others allow
(0x06, 0, 0, 0x7FFF0000),
(0x06, 0, 0, deny_errno),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not changed (false positive): on Linux AF_UNIX == 1 (AF_INET == 2, AF_INET6 == 10). (0x15, 0, 1, 1) falls through (jt=0) to RET ALLOW only when domain == AF_UNIX (1), and jumps (jf=1) to RET ERRNO for every other socket family including AF_INET and AF_INET6.

Comment on lines +2139 to +2141
if platform_name != "darwin":
if network_mode == "none":
bpf_bytes = build_no_ip_seccomp_bpf(os.uname().machine)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

bug · high
On Linux, network_mode="loopback-only" currently gets no network enforcement at all: the seccomp filter is only installed for network_mode == "none", and the bwrap invocation uses --unshare-all, which creates a fresh network namespace where the loopback interface exists but is DOWN (and nothing brings it up). So the runtime-gates stage either silently loses loopback connectivity (breaking any test that binds/connects on localhost) or, if that is somehow changed, has no IP-blocking guarantee. Either add a loopback-capable path for Linux (e.g. --unshare-net plus bringing lo up, or extend the seccomp filter to allow only loopback destinations) or fail closed for loopback-only on this backend.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not changed (false positive): Bubblewrap's --unshare-all creates an isolated network namespace (CLONE_NEWNET) and brings lo (127.0.0.1/8 and ::1/128) IFF_UP automatically via netlink with no external interfaces or routes, providing kernel-enforced loopback-only isolation.

Comment on lines +47 to +52
const casArtifacts: readonly PiCandidateBlobArtifact[] = manifest.spec.entries.map(ref => ({
name: ref.name,
byteLength: ref.byteLength,
digest: ref.digest,
blobPath: join(casSha256Dir, ref.digest.hex),
}));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

bug · medium
Restoring a pre-existing checkpoint now unconditionally maps every manifest entry to a CAS blob path (artifactsDirectory/blobs/sha256/) and passes those as artifacts to recoverSnapshot. Checkpoints written before this change (chunk-format workspace rows, no CAS blobs published) will hit the chunk branch in recovery.ts, which for a blob artifact calls readBlobChunkAsync(artifact.blobPath) — a file that was never published — and fail with RESOURCE_MISMATCH. Unless every producer is guaranteed to republish blobs into the CAS before restore is attempted (e.g., the controller upgrade path), legacy checkpoints become unrestorable. Consider verifying the blob exists (or republishing from candidate.root as a fallback) on this restore-existing branch.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not changed (deferred upgrade compatibility): restoring pre-upgrade checkpoints written without CAS blobs is an upgrade backward-compatibility path outside this change's scope.

Comment on lines +358 to +360
if (carvedOutPattern !== null) {
protectedPatterns = protectedPatterns.filter(pattern => pattern !== carvedOutPattern);
} else {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

security · high
controlRootCarveOutPattern removes the entire <root>/** protected pattern (which may be caller-supplied via options.scope.protected) when the proposal file lives under a hidden root — e.g. .autosync/proposal.json causes .autosync/** to be dropped wholesale from protectedPatterns. All other files under that root then become writable-by-default with no host authorization, weakening the protected surface far beyond the single proposal file. Consider carving out only the exact proposal path (e.g. replacing <root>/** with <root>/** minus the exact path via explicit patterns), or requiring host opt-in for the carve-out.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not changed (false positive): TaskContract scope is deny-by-default unless matched by scope.writable, and controlRootCarveOutPattern (lines 253-257) explicitly requires proposalPath to be an exact writablePatterns entry while rejecting the carve-out if any other writable pattern overlaps <root>/**.

Comment on lines +440 to +442
for (const artifact of state.input.candidate.artifacts) {
files.set(artifact.name, 'bytes' in artifact ? Buffer.from(artifact.bytes) : readFileSync(artifact.blobPath));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

bug · medium
manifestFor mixes async parity harness code with a synchronous readFileSync in a loop. A missing/unreadable blobPath throws synchronously, aborting the whole harness with an unhandled rejection instead of a graded failure, and large blobs block the event loop. Wrap in try/catch (or use readFile via making the caller async) and return a graded failure.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not changed (test harness scope): manifestFor is an internal helper in the deterministic FakeAdapterPlan parity harness operating on pre-verified small fixture blobs rather than production runtime paths.

Comment on lines +126 to +129
const timer = setTimeout(() => {
try { child.kill('SIGKILL'); } catch { /* ignore */ }
finish(null);
}, 30_000);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

bug · medium
readGitBlobDigests has a fixed 30s SIGKILL timeout; on large baseline trees with many unique blobs this silently returns null, which turns a perfectly valid snapshot into a gate denial ('candidate digest does not match registered candidate snapshot'). Consider scaling the timeout with the number of OIDs or surfacing a distinct failure reason.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not changed (intentional bound): readGitBlobDigests streams all OIDs through a single git cat-file --batch pipe and only runs on legacy full-snapshot manifests (v2 sparse overlays skip full-tree hashing); the 30s subprocess timeout is an intentional fail-closed bound.

Comment on lines +1253 to +1258
const effectiveDeleted: string[] = [];
for (const basePath of baseline.regularFiles.keys()) {
if (reconstructed.has(basePath)) continue;
if (!isSafeCandidatePath(basePath, effectivePolicy)) return null;
effectiveDeleted.push(basePath);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

security · high
In the snapshot-diff branch, effectiveDeleted is derived only from baseline.regularFiles; baseline symlinks that a candidate removes or overwrites are not subjected to isSafeCandidatePath policy checks. A snapshot manifest entry at a path where the baseline has a symlink is rejected (via hasSymlinkAncestor), but outright deletion of baseline symlinks (implicitly, by not appearing in reconstructed) is silently permitted, bypassing the path policy.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not changed (classic v1 representation): classic v1 ArtifactManifest documents only represent regular files, so untouched baseline symlinks never appear in reconstructed and treating them as deletions would reject repositories with unchanged symlinks; overwriting symlinks is blocked at line 1263, GATE_DRIVER refuses symlink targets at line 546, and v2 overlays track spec.deleted explicitly.

Comment on lines 1450 to 1451
if (fromRun !== null) return fromRun;
return null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

bug · medium
resolveCandidateEntries returns null for benign reconstruction failures (checkpoint NDJSON over 64 MiB, CAS blob with nlink!=1, timeout in git helpers), which the gate reports uniformly as 'candidate digest does not match registered candidate snapshot'. This conflates integrity violations with size/transport limits and makes legitimate large runs permanently un-gateable with a misleading denial reason. Consider returning a typed failure so the verdict can distinguish digest mismatch from reconstruction limits.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not changed (intentional fail-closed gate boundary): resolveCandidateEntries enforces the same checkpoint size and nlink === 1 sealed-CAS invariants as the controller (wideCheckpointBytes = 8 MiB in @loopwright/state) and denies unverifiable snapshots without exposing host filesystem details in gate responses.

- Enforce configured overlay.maxBytes on verified descriptors in resolveInventory

Signed-off-by: thxCode <thxcode0824@gmail.com>
- Enforce CAS owner/mode checks in preflight, file verifiers, and recovery

Signed-off-by: thxCode <thxcode0824@gmail.com>
…Policy

- Propagate ControllerFailure in CAS diff line counting

Signed-off-by: thxCode <thxcode0824@gmail.com>
…driver

- Normalize case-insensitive workflow scope checks in runner compiler

Signed-off-by: thxCode <thxcode0824@gmail.com>
…lisher

- Harden publisher loopback/auth/scratch bounds, service controlRoot, and empty API URL

Signed-off-by: thxCode <thxcode0824@gmail.com>
…ading

- Scrub compiled CLI artifacts before writing and return non-zero default exit

Signed-off-by: thxCode <thxcode0824@gmail.com>
…askpack

- Validate file.mode in v2 candidate apply snippet across docs and skill

Signed-off-by: thxCode <thxcode0824@gmail.com>
@thxCode

thxCode commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Automated Review Triage Summary (Round 1)

All 60 items from review 6000208417 and summary comment 7052116992 (27 inline threads + 33 summary-routed items) were verified against the source tree:

Fixed Engineering Issues

  • Inline threads (9 resolved):
    • T6 (packages/agent-pi/src/cas.ts:393): Enforced checkOwnerAndMode on before.uid in verifyRegularFileSync and verifyRegularFileAsync.
    • T7 (packages/agent-pi/src/preflight.ts:233): Enforced checkOwnerAndMode (0o022 on the canonical artifacts root and 0o077 on blobs/ and blobs/sha256/) in resolveAuthoritativeCasSha256DirSync and resolveAuthoritativeCasSha256DirAsync.
    • T8 (packages/cli/src/main.ts:704): Changed the unmapped fallback in turnkeySummaryExit to return exit code 4 instead of summary.ok ? 0 : 4.
    • T9 (packages/cli/src/main.ts:732 & packages/github-app/src/action.ts:1153): Ran assertCleanArtifact checks in memory before writing compiled registry, config, and instruction resource files to disk.
    • T12 (packages/controller/src/controller.ts:404): Propagated ControllerFailure from streamVerifiedCasBlob instead of swallowing CAS integrity errors during diff line counting.
    • T17 (packages/core/src/artifacts.ts:299): Enforced overlay?.maxBytes ?? OVERLAY_LIMITS.maxMaxBytes on verifiedTotal in resolveInventory with unit test coverage.
    • T18 (packages/github-app/src/publisher.ts:1179): Moved per-request workRoot creation (mkdtemp + chmod) and buildGitAuthEnv inside the request try block with guarded finally cleanup.
    • T19 (packages/github-app/src/service.ts:157): Used resolveManifestControlRoot in startGitHubAppControlPlane when validating manifest scope invariants.
    • T22 (packages/taskpack-runner/src/compile-taskpack.ts:320): Applied case-insensitive comparisons consistently for .github/workflows/** unlock checks and protectedPatterns matching.
  • Summary-routed items (7 addressed):
    • S1 (packages/github-app/src/publisher.ts): Enforced loopback-only host binding (127.0.0.1, ::1, localhost) before server.listen, with regression coverage.
    • S3 (packages/controller/src/capture.ts:618): Simplified duplicate 'ARTIFACT_INVALID' conditional.
    • S6 (docs/operations/coding-agents.md:330): Validated file.mode ("100644" or "100755") in the v2 bundle apply snippet.
    • S11 (packages/agent-pi/src/recovery.ts:82): Validated /^[0-9a-f]{64}$/ on ref.digest.hex before constructing canonicalBlobPath.
    • S19 & S20 (packages/agent-pi/src/cas.ts:507, 709): Enforced checkOwnerAndMode in verifyCasBlobAsync and simplified duplicate refusal branch in publishCandidateFileToCas.
    • S22 & S23 (packages/github-app/src/publisher.ts:1072, 1096): Bounded receiptCache to 256 entries and switched bearer-token verification to timingSafeEqual.

Not Changed (Left Open for Transparency)

  • False positives & intentional contracts (16 inline threads + 23 summary items):
    • T1, T2, T3, T4 (.auto-sync/checks/verify.sh): command.v1 env comes from the trusted host gate server; hugo file-level read grant is intentional least privilege; AF_UNIX == 1 in Linux sys/socket.h (so (0x15, 0, 1, 1) allows AF_UNIX and denies AF_INET/AF_INET6); bwrap --unshare-all brings lo IFF_UP automatically via netlink in an isolated netns.
    • T10, T11 (packages/cli/src/main.ts): --dry-run spawns no child processes; check-only no-change runs execute zero LLM steps and intentionally tolerate absent models.json/provider tokens while refusing OAuth providers.
    • T13, T14, T16 (inspect.ts, source.ts, core/src/artifacts.ts): candidate.files.json carries explicit v1/v2 format discriminators; tool-neutral engine host protection (.git/** plus .github/** under github profile, with repo-specific agent files in spec.scope.protected) and pure digestArtifactFromMetadata construction follow the specification.
    • T20, T21 (service.ts, turnkey-memory.ts): intakeWebhookDelivery vs isGitHubTriggerDeclared layering and targetBranch ?? 'main' fallback when publication.mode is disabled are intentional.
    • T23, T24, T25, T26, T27 (taskpack-runner): TaskContract is deny-by-default and controlRootCarveOutPattern rejects overlapping writable patterns (T23); manifestFor is an internal parity fixture helper (T24); 30s git cat-file --batch timeout (T25), classic v1 regular-file snapshot representation (T26), and fail-closed null gate denials (T27) are intentional.
    • Summary items S2, S4, S5, S7–S10, S12–S17, S21, S24–S32: Non-blocking style/refactor preferences or intentional split raw-vs-verified CAS limits (S21, S8), existing barrel exports (S28–S32), and bounded retry-free CAS sealing (S15).
  • Deferred upgrade-compatibility items (2 inline threads + 2 summary items — T5, T15, S18, S33):
    • Pre-upgrade non-CAS checkpoint restore (T5), pre-upgrade step-meta.json allowWorkflowWrites without hostPolicy (T15), external --taskpack path fallback (S18), and cross-version wideCheckpointBytes (S33) concern upgrade backward-compatibility paths outside this change's scope.

…d sandbox

Signed-off-by: thxCode <thxcode0824@gmail.com>
…driver

Signed-off-by: thxCode <thxcode0824@gmail.com>
…lisher

Signed-off-by: thxCode <thxcode0824@gmail.com>
…Policy

Signed-off-by: thxCode <thxcode0824@gmail.com>
…d sandbox

Signed-off-by: thxCode <thxcode0824@gmail.com>
…nd turnkey

Signed-off-by: thxCode <thxcode0824@gmail.com>
…driver

Signed-off-by: thxCode <thxcode0824@gmail.com>
…lisher

Signed-off-by: thxCode <thxcode0824@gmail.com>
…ading

Signed-off-by: thxCode <thxcode0824@gmail.com>
@thxCode
thxCode merged commit 9cd6b2f into main Nov 21, 2026
14 of 15 checks passed
@thxCode
thxCode deleted the decouple-taskpack-and-blob-pointers branch November 21, 2026 03:25
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