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
3 changes: 2 additions & 1 deletion .github/workflows/issue-implementation.lock.yml

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

1 change: 1 addition & 0 deletions .github/workflows/issue-implementation.md
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ steps:
/AUTOMATION.md
/README.md
/.nvmrc
/.gitignore
/.github/copilot-instructions.md
/typescript/
/python/
Expand Down
4 changes: 4 additions & 0 deletions AUTOMATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,10 @@ short-lived App-access proof are frozen. An immutable spending reservation
precedes inference. The model-start guard repeats authorization and rejects App
preflight older than 15 minutes. A build command expires after 24 hours.

The sparse coding checkout includes the root [`.gitignore`](./.gitignore).
This keeps the collector's standard Git ignore checks offline in a partial clone,
instead of requiring a lazy fetch from inside the sandbox.

Detection is eligible only after successful preparation and successful, sole-`noop`
agent completion. Its inference credential is released only after the trusted
authorization and exact-patch staging step succeeds and preceding job steps
Expand Down
48 changes: 47 additions & 1 deletion tools/tests/implementation-workflow.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
// Licensed under the MIT License.

import assert from "node:assert/strict";
import { execFileSync } from "node:child_process";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import test from "node:test";
import { pathToFileURL } from "node:url";
import { runInNewContext } from "node:vm";
import { parse } from "yaml";
import { BUILD_LIMITS } from "../issue-implementation.mjs";
import { BUILD_LIMITS, blobHash, collectCandidate } from "../issue-implementation.mjs";

const workflows = new URL("../../.github/workflows/", import.meta.url);
const markdown = fs.readFileSync(new URL("issue-implementation.md", workflows), "utf8");
Expand All @@ -27,6 +31,48 @@ test("coding is inactive by default and only an owner Issue comment can activate
assert.equal(source.concurrency["job-discriminator"], "${{ github.run_id }}");
});

test("sparse coding checkouts collect complete candidates offline with ignore rules", t => {
const checkout = source.steps.find(step => step.uses?.startsWith("actions/checkout@"));
const compiledCheckout = compiled.jobs.agent.steps.find(step => step.uses?.startsWith("actions/checkout@"));
assert.equal(checkout.with["sparse-checkout-cone-mode"], false);
assert.equal(compiledCheckout.with["sparse-checkout"], checkout.with["sparse-checkout"]);

const directory = fs.mkdtempSync(path.join(os.tmpdir(), "typechat-sparse-collector-"));
t.after(() => fs.rmSync(directory, { recursive: true, force: true }));
const origin = path.join(directory, "origin");
const coding = path.join(directory, "coding");
const git = (cwd, args, options = {}) => execFileSync("git", ["-C", cwd, ...args],
{ encoding: "utf8", stdio: ["pipe", "pipe", "pipe"], ...options });
git(directory, ["init", "--quiet", origin]);
git(origin, ["config", "core.autocrlf", "false"]);
git(origin, ["config", "uploadpack.allowFilter", "true"]);
fs.writeFileSync(path.join(origin, ".gitignore"), "node_modules/\n");
fs.mkdirSync(path.join(origin, "python"), { recursive: true });
const original = "value = 1\n";
fs.writeFileSync(path.join(origin, "python", "value.py"), original);
git(origin, ["add", "--all"]);
git(origin, ["-c", "user.name=TypeChat Test", "-c", "user.email=typechat-test@example.invalid", "-c", "commit.gpgsign=false",
"commit", "--quiet", "-m", "Sparse checkout fixture", "-m", "Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>"]);
const prepared = { source: { commit: git(origin, ["rev-parse", "HEAD"]).trim() } };
git(directory, ["clone", "--quiet", "--no-checkout", "--filter=blob:none", pathToFileURL(origin).href, coding]);
assert.equal(git(coding, ["config", "--get", "remote.origin.promisor"]).trim(), "true");
git(coding, ["config", "core.autocrlf", "false"]);
git(coding, ["sparse-checkout", "set", "--no-cone", "--stdin"], { input: checkout.with["sparse-checkout"] });
git(coding, ["checkout", "--quiet", prepared.source.commit]);
git(coding, ["remote", "set-url", "origin", pathToFileURL(path.join(directory, "unavailable-origin")).href]);
fs.writeFileSync(path.join(coding, "python", "value.py"), "value = 2\n");
fs.writeFileSync(path.join(coding, "python", "added.py"), "added = True\n");
fs.mkdirSync(path.join(coding, "python", "node_modules"));
fs.writeFileSync(path.join(coding, "python", "node_modules", "ignored.py"), "not part of the candidate\n");

const candidate = collectCandidate(prepared, coding, "Collect the complete offline patch.");
assert.equal(candidate.baseSha, prepared.source.commit);
assert.deepEqual(candidate.files, [
{ path: "python/added.py", previousSha: null, content: "added = True\n" },
{ path: "python/value.py", previousSha: blobHash(original), content: "value = 2\n" },
]);
});

test("native budgets, execution limits, exact completion, and separate usage are enforced", () => {
assert.equal(source["max-ai-credits"], BUILD_LIMITS.mainCredits);
assert.equal(source["max-turns"], BUILD_LIMITS.maxTurns);
Expand Down
16 changes: 15 additions & 1 deletion typescript/tests/package.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,21 @@ const childEnv = { ...process.env, NODE_OPTIONS: "", VSCODE_INSPECTOR_OPTIONS: "
let packedFiles;

before(() => {
const options = { cwd: packageRoot, encoding: "utf8", env: childEnv, timeout: 30000 };
const packageSource = join(directory, "package-source");
cpSync(packageRoot, packageSource, {
recursive: true,
filter: source => {
const relativePath = path.relative(packageRoot, source);
return !relativePath
.split(path.sep)
.some(segment => ["node_modules", "out", ".git"].includes(segment));
},
});
const packageManifestPath = join(packageSource, "package.json");
const packageManifest = JSON.parse(readFileSync(packageManifestPath, "utf8"));
delete packageManifest.scripts.prepare;
writeFileSync(packageManifestPath, JSON.stringify(packageManifest, null, 2));
const options = { cwd: packageSource, encoding: "utf8", env: childEnv, timeout: 30000 };
const packed = process.platform === "win32"
? spawnSync(process.env.ComSpec ?? "cmd.exe", ["/d", "/s", "/c", "npm pack --ignore-scripts --dry-run --json"], options)
: spawnSync("npm", ["pack", "--ignore-scripts", "--dry-run", "--json"], options);
Expand Down
Loading