Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .changeset/compiler-transport-trust.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ All notable changes to this project will be documented in this file.

### Security

Require Go 1.27.4 for repository builds, tooling, and owned workflow runtimes to
fix [GO-2026-6859 (CVE-2026-97054)](https://pkg.go.dev/vuln/GO-2026-6859), an
HTTP/1 server crash caused by a `net/http` header race. Release builds reject
older toolchains. Rebuild binaries and devcontainers with Go 1.27.4 or newer.

Allow explicitly `on.bots`-listed Apps to check out same-repository PRs on
`edited` events only when the webhook reports a non-null object-valued `body`
change and no other changed fields. Missing change metadata, title/base changes,
Expand Down Expand Up @@ -86,7 +91,7 @@ manifest digests through an independently trusted channel and update/recompile
workflows to consume the new setup action. Explicit Copilot pins bypass
toolcache selection; without a supplied pin, trusted toolcache behavior is
unchanged. Repository Go tooling, module requirements and generated runtime
defaults now use Go 1.27.3; release builds reject older toolchains. Go root
defaults now use Go 1.27.4; release builds reject older toolchains. Go root
capture and Serena setup clear stale GOROOT values before discovering the
selected toolchain, preventing mixed-version compiler/standard-library failures.

Expand Down
73 changes: 53 additions & 20 deletions actions/setup/js/finish_work_queue_claim.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -157,34 +157,40 @@ function trustedClaimFooterLinks(handle, configured) {
}
}

async function authorizeWorkerClaim(options = {}) {
log.debug("claim.authorize.start");
async function loadClaimAuthorization(options, { role, allowReleased }) {
const configured = runtimeOptions(options);
const assignment = normalizeAssignment(options.assignment);
const normalized = normalizeClaimScope(Object.hasOwn(options, "message") ? options.message : Object.hasOwn(options, "claim_handle") ? { claim_handle: options.claim_handle } : {}, assignment);
if (Object.hasOwn(options, "claim_handle") && normalized.claim_handle !== options.claim_handle) throw new Error("work_queue_claim_scope_invalid");
const member = assignment.claims.find(claim => claim.handle === normalized.claim_handle);
const latest = await loadQueue(configured);
const { dispatch, profile } = validateStoredAssignment(latest.projection, assignment);
const trustedContext = await authenticatePublisher({ ...configured, role: "worker", dispatch_id: assignment.dispatch_id, claim_handle: member.handle });
const { dispatch, profile } = validateStoredAssignment(latest.projection, assignment, { allowReleased });
const trustedContext = await authenticatePublisher({ ...configured, role, dispatch_id: assignment.dispatch_id, claim_handle: member.handle });
const claim = latest.projection.claims.get(member.claim_id);
const work = latest.projection.works.get(member.work_id);
return { configured, assignment, normalized, member, latest, dispatch, profile, trustedContext, claim, work };
}

function claimEffectTarget(normalized, resource, effectScope) {
const targets = [normalized.repository, normalized.repo, normalized.target_repo, normalized["target-repo"]].filter(value => value !== undefined);
if (targets.some(target => typeof target !== "string" || target !== effectScope)) throw Object.assign(new Error("work_queue_effect_scope_denied"), { code: "E004" });
if (resource === undefined) return undefined;
if (!resource || typeof resource !== "object" || Array.isArray(resource)) throw new Error("work_queue_effect_scope_denied");
const resourceTargets = [resource.repository, resource.repo].filter(value => value !== undefined);
if (!resourceTargets.length || resourceTargets.some(target => typeof target !== "string" || target !== effectScope)) throw Object.assign(new Error("work_queue_effect_scope_denied"), { code: "E004" });
const canonicalResource = { ...resource, repository: resourceTargets[0] };
delete canonicalResource.repo;
return canonicalResource;
}

async function authorizeWorkerClaim(options = {}) {
log.debug("claim.authorize.start");
const { configured, assignment, normalized, member, latest, dispatch, profile, trustedContext, claim, work } = await loadClaimAuthorization(options, { role: "worker", allowReleased: false });
const expected = expectedWorkerRun(assignment, profile, configured.context, trustedContext.repository, dispatchPrincipal(dispatch));
const native = validateNativeRun(trustedContext.native_run, { ...expected, run_id: trustedContext.run_id });
if (!dispatch.run || dispatch.state !== "bound" || canonical(dispatch.run) !== canonical(bindingForRun(native, expected))) throw new Error("work_queue_binding_not_durable");
const targets = [normalized.repository, normalized.repo, normalized.target_repo, normalized["target-repo"]].filter(value => value !== undefined);
const allowedRepos = [profile.effect_scope];
if (targets.some(target => typeof target !== "string" || !allowedRepos.includes(target))) throw Object.assign(new Error("work_queue_effect_scope_denied"), { code: "E004" });
const claim = latest.projection.claims.get(member.claim_id);
const work = latest.projection.works.get(member.work_id);
const resource = claimEffectTarget(normalized, options.resource, profile.effect_scope);
const base = { claim_handle: member.handle, claim_id: member.claim_id, work_id: member.work_id, run_id: native.run_id, run_attempt: 1, effect_scope: profile.effect_scope };
let resource;
if (options.resource !== undefined) {
const suppliedResource = options.resource;
if (!suppliedResource || typeof suppliedResource !== "object" || Array.isArray(suppliedResource)) throw new Error("work_queue_effect_scope_denied");
const resourceTargets = [suppliedResource.repository, suppliedResource.repo].filter(value => value !== undefined);
if (!resourceTargets.length || resourceTargets.some(target => typeof target !== "string" || !allowedRepos.includes(target))) throw Object.assign(new Error("work_queue_effect_scope_denied"), { code: "E004" });
resource = { ...suppliedResource, repository: resourceTargets[0] };
delete resource.repo;
}
if (claim?.state === "cancelled") return { ...base, authorized: false, suppressed: true, state: "cancelled" };
if (options.requireCompletion !== false && claim?.state !== "completed") return { ...base, authorized: false, state: "open" };
if (options.requireCompletion !== false && claim?.keep_open && claim.barrier !== "pending")
Expand All @@ -209,6 +215,27 @@ async function authorizeWorkerClaim(options = {}) {
return { ...base, authorized: true, state: options.requireCompletion === false ? "open" : "completed", ...(footer_links ? { footer_links } : {}) };
}

async function authorizeReconcilerClaimReadback(options = {}) {
const { configured, normalized, member, latest, dispatch, profile, claim, work } = await loadClaimAuthorization(options, { role: "reconciler", allowReleased: true });
const evidence = latest.projection.deliveryEvidence.get(member.claim_id);
const pending = claim?.keep_open ? claim.barrier === "pending" : work?.barrier === "pending";
if (!dispatch.run || claim?.state !== "completed" || work?.claim_id !== member.claim_id || !pending || evidence?.completion_id !== work?.completion_id || evidence?.run_id !== dispatch.run.run_id)
throw new Error("work_queue_claim_ineffective");
const resource = claimEffectTarget(normalized, options.resource, profile.effect_scope);
if (resource !== undefined) require("./work_queue_resource_scope.cjs").validateEffectResourceAuthority(latest.projection, { claim, work, dispatch }, resource);
return {
claim_handle: member.handle,
claim_id: member.claim_id,
work_id: member.work_id,
run_id: dispatch.run.run_id,
run_attempt: 1,
effect_scope: profile.effect_scope,
authorized: true,
state: "completed",
footer_links: trustedClaimFooterLinks(member.handle, configured),
};
}

async function reconcileWorkerClaim(options = {}) {
log.debug("claims.reconcile.start");
const configured = runtimeOptions(options);
Expand Down Expand Up @@ -381,6 +408,10 @@ async function finalizeWorkerResults(options = {}) {
const verificationStarted = Date.now();
integer(work.completion_at, 0, Number.MAX_SAFE_INTEGER, "Completion timestamp");
const remainingDeadline = policy.deadline_ms - Math.max(0, (options.now ?? verificationStarted) - work.completion_at);
// Maintenance can first observe a terminal worker after the deadline.
// Give its persisted receipts one bounded readback before expiring them;
// this does not replay effects or reopen the normal retry budget.
const finalEvidenceReadback = options.expireUnverified === true && latest.projection.deliveryEvidence.has(member.claim_id);
log.debug("delivery.verifier.budget", {
max_attempts: policy.max_attempts,
remaining_ms: Math.max(0, remainingDeadline),
Expand All @@ -394,10 +425,11 @@ async function finalizeWorkerResults(options = {}) {
results[member.handle] = { state: "pending", effects: "unknown", reason: "verification_unavailable" };
continue;
}
for (; attempts < policy.max_attempts && Date.now() - verificationStarted < remainingDeadline; attempts++) {
for (; attempts < policy.max_attempts && ((attempts === 0 && finalEvidenceReadback) || Date.now() - verificationStarted < remainingDeadline); attempts++) {
log.debug("delivery.verifier.attempt", { attempt: attempts + 1 });
try {
verification = await verifyWithinBudget(options.verifyEffects, member, { assignment, contract, attempt: attempts + 1, run: dispatch.run }, remainingDeadline - (Date.now() - verificationStarted));
const remaining = remainingDeadline - (Date.now() - verificationStarted);
verification = await verifyWithinBudget(options.verifyEffects, member, { assignment, contract, attempt: attempts + 1, run: dispatch.run }, attempts === 0 && finalEvidenceReadback && remaining <= 0 ? 15000 : remaining);
} catch (error) {
log.failure("delivery.verifier.failed", error);
verification = null;
Expand Down Expand Up @@ -570,6 +602,7 @@ module.exports = {
readWorkerSnapshot,
reconcileWorkerClaim,
authorizeWorkerClaim,
authorizeReconcilerClaimReadback,
verifyWithinBudget,
finalizeWorkerResults,
renderSummary,
Expand Down
10 changes: 8 additions & 2 deletions actions/setup/js/reconcile_work_queue_run.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
const log = require("./work_queue_logging.cjs").createWorkQueueLogger("run");
const { ERR_VALIDATION } = require("./error_codes.cjs");
const { digest } = require("./work_queue_codec.cjs");
const { createDurableDeliveryVerifier } = require("./work_queue_delivery_recovery.cjs");
const { API_VERSION, nativeId, authenticatePublisher, fetchNativeRunAttempt, validateNativeRun } = require("./work_queue_native.cjs");
const { loadQueue, validateStoredAssignment, expectedWorkerRun } = require("./work_queue_binding.cjs");
const { dispatchPrincipal } = require("./work_queue_policy.cjs");
Expand Down Expand Up @@ -124,10 +125,15 @@ async function maintenance(options = {}) {
log.failure("maintenance.obsolete.failed", error, true);
configured.core?.warning("Work queue obsolete-work reconciliation failed; core recovery will continue. Inspect safe API diagnostics and the checked ledger before retrying maintenance.");
}
const result = await reconcileQueue({ ...configured, requestCancellation: false, expireUnverified: true });
const result = await reconcileQueue({ ...configured, requestCancellation: false, expireUnverified: true, verifyEffectsFor: options.verifyEffectsFor || (assignment => createDurableDeliveryVerifier({ ...configured, assignment })) });
const released = result.results.filter(entry => entry.released).length;
const unresolved = result.results.filter(entry => ["launch_unresolved", "run_binding_conflict"].includes(entry.state) || Object.values(entry.delivery?.claims || {}).some(claim => claim.reason === "verification_unresolved")).length;
log.diagnostic("maintenance.reconcile.complete", { reconciled: result.reconciled, released, unresolved });
log.diagnostic("maintenance.reconcile.complete", {
reconciled: result.reconciled,
released,
unresolved,
durable_verified: result.results.filter(entry => Object.values(entry.delivery?.claims || {}).some(claim => claim.state === "result")).length,
});
const pending = [];
if (options.projectIssues === true) {
try {
Expand Down
10 changes: 10 additions & 0 deletions actions/setup/js/safe_output_handler_manager.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const { withClaimEffectClients, wrapClaimEffectClient } = require("./work_queue_
const { readClaimControlMessages } = require("./work_queue_control_delivery.cjs");
const { readDeliveryControlInventory, inspectClaimDelivery, createClaimDeliveryVerifier, verifyBuiltinDeliveryOutput, validateDeliveryContract, NO_WRITE_TYPES } = require("./work_queue_delivery.cjs");
const { normalizeSafeOutputName } = require("./safe_output_names.cjs");
const { collectDeliveryEvidence, publishDeliveryEvidence } = require("./work_queue_delivery_evidence.cjs");
const { createClaimAdapterHandler, verifyClaimAdapterOutput, preparedAdapterPath, createDeclaredAdapterVerifier, wrapDeclaredBuiltinHandler } = require("./work_queue_claim_adapters.cjs");
const GITHUB_TOKEN_CONFIG_KEY = "github-token";

Expand Down Expand Up @@ -2055,6 +2056,15 @@ async function settleClaimDelivery(scope, messages, results, options = {}) {
for (const result of results) result.claim_handle = handle;
if (options.registerVerification) options.registerVerification(messages, results);
const controls = options.controlMessages || [];
if (options.registerVerification !== undefined && !isStagedMode()) {
try {
const evidence = collectDeliveryEvidence({ assignment: scope.assignment, claim_handle: handle, messages, results, effects: options.effects || [], controls, config: loadConfig(), context: verificationContext });
if (evidence.unsupported) core.info(`Claim ${handle}: durable delivery evidence not published (${evidence.unsupported})`);
else await publishDeliveryEvidence({ assignment: scope.assignment, claim_handle: handle, ...evidence, github: options.queueClient || github, context: verificationContext, core });
Comment on lines +2059 to +2063
} catch (error) {
core.error(`Claim ${handle}: durable delivery evidence publication failed: ${getErrorMessage(error)}`);
}
}
const controlProofs = new Map();
const outcomes = [...results, ...controls.map((message, index) => ({ messageIndex: messages.length + index, success: true, claim_handle: handle, result: null }))];
const queueControls = require("./work_queue_control_receipts.cjs");
Expand Down
31 changes: 28 additions & 3 deletions actions/setup/js/upload_artifact.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ const {
claimIdentity,
assertClaimIdentity,
receiptMatchesClaim,
claimDeliveryReceipt,
durableReceipt,
} = require("./work_queue_claim_scope.cjs");
const { expectedGitHubHost } = require("./work_queue_host.cjs");
const privateDeliveryReceipts = new WeakMap();
Expand Down Expand Up @@ -820,9 +822,32 @@ async function main(config = {}) {
};
}

async function verifyArtifactDelivery({ claim, result, github }) {
async function verifyArtifactDelivery(options) {
const receipt = claimDeliveryReceipt(options, "artifact", privateDeliveryReceipts);
return verifyArtifactReceipt(options, receipt);
}

function validArtifactReceipt(receipt, claim) {
return (
receiptMatchesClaim(receipt, claim) &&
["repository", "run_id", "name", "url"].every(key => typeof receipt[key] === "string" && receipt[key].length > 0) &&
/^[A-Za-z0-9_-]+\/[A-Za-z0-9._-]+$/.test(receipt.repository) &&
/^[1-9][0-9]*$/.test(receipt.run_id) &&
Number.isSafeInteger(receipt.id) &&
receipt.id > 0 &&
/^[a-f0-9]{64}$/.test(receipt.digest) &&
(receipt.size === undefined || (Number.isSafeInteger(receipt.size) && receipt.size >= 0))
);
}

function durableArtifactReceipt(result, claim) {
const receipt = result && privateDeliveryReceipts.get(result);
if (!receiptMatchesClaim(receipt, claim) || !receipt.run_id) return { verified: false };
if (!validArtifactReceipt(receipt, claim)) return null;
return durableReceipt(receipt);
}

async function verifyArtifactReceipt({ claim, github }, receipt) {
if (!validArtifactReceipt(receipt, claim)) return { verified: false };
Comment on lines +849 to +850
const [owner, repo] = receipt.repository.split("/");
const { data } = await github.rest.actions.getArtifact({ owner, repo, artifact_id: receipt.id });
if (
Expand All @@ -842,4 +867,4 @@ async function verifyArtifactDelivery({ claim, result, github }) {
};
}

module.exports = { main, verifyArtifactDelivery };
module.exports = { main, verifyArtifactDelivery, durableArtifactReceipt };
Loading
Loading