Skip to content
Open
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/2.0.0/),

## [Unreleased]

### Fixed

- `validate`: a top-level include path that starts with `./` or `../` and contains spaces, such as `policy: ./Carrier Policy.md` or `tasks: ./my tasks.yaml`, fails with a missing-file error when the target file does not exist, rather than becoming the policy string or failing with a schema type mismatch ([#526](https://github.com/sandtable-ai/sandtable/issues/526)).

## [1.5.0] - 2026-11-09

A minor release with no breaking changes, and a security fix in the HTML reports: upgrade if you open reports built from domains or results files you didn't write. `sandtable judge` and `run --judge` score a run on judged criteria with a model, apart from pass^k, which they never change, and `sandtable calibrate` measures a judge against human labels. Clock dates reach the policy, param defaults, fault messages and `reply_includes`, and `report --markdown` writes a summary for a CI job or a pull request comment.
Expand Down
9 changes: 6 additions & 3 deletions src/spec/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class DomainNotFoundError extends DomainError {}
/**
* Load a domain from a directory containing sandtable.yaml (or the file itself).
* Any top-level value that is a relative path to a .md/.yaml/.yml file is inlined,
* so policy, world and tasks can live in their own files. A one-token path to a missing file is an
* so policy, world and tasks can live in their own files. A relative path to a missing file is an
* error, never the value itself: a misspelled `policy: ./polcy.md` would otherwise become the policy.
*/
export async function loadDomain(target: string): Promise<Domain> {
Expand Down Expand Up @@ -524,8 +524,11 @@ export function pendingReview(d: Domain): PendingItem[] {
];
}

/** One token ending in .md, .yaml or .yml: a path, so a missing file is an error rather than inline text. */
const PATH = /^\S+\.(md|ya?ml)$/i;
/**
* A relative path ending in .md, .yaml or .yml: a single-token path, or a path starting with ./ or ../,
* so a missing file is an error rather than inline text.
*/
const PATH = /^(\S+|\.\.?[/\\][^\r\n]*)\.(md|ya?ml)$/i;

function parseYaml(text: string, file: string): unknown {
try {
Expand Down
29 changes: 28 additions & 1 deletion test/load.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,44 @@ describe("loadDomain includes", () => {
await expect(loadDomain(dir)).rejects.toThrow(/tasks: \.\/task\.yaml not found/);
});

it("keeps inline text that merely mentions a file", async () => {
it("rejects a missing include path with spaces starting with ./ or ../", async () => {
const dir = copyOfClinic();
edit(path.join(dir, "sandtable.yaml"), /^policy: \.\/policy\.md$/m, "policy: ./Carrier Policy.md");
await expect(loadDomain(dir)).rejects.toThrow(/policy: \.\/Carrier Policy\.md not found/);

const dir2 = copyOfClinic();
edit(path.join(dir2, "sandtable.yaml"), /^policy: \.\/policy\.md$/m, "policy: ../shared/Carrier Policy.md");
await expect(loadDomain(dir2)).rejects.toThrow(/policy: \.\.\/shared\/Carrier Policy\.md not found/);

const dir3 = copyOfClinic();
edit(path.join(dir3, "sandtable.yaml"), /^tasks: \.\/tasks\.yaml$/m, "tasks: ./my tasks.yaml");
await expect(loadDomain(dir3)).rejects.toThrow(/tasks: \.\/my tasks\.yaml not found/);
});

it("keeps inline text that merely mentions a file or has spaces without ./", async () => {
const dir = copyOfClinic();
edit(path.join(dir, "sandtable.yaml"), /^policy: \.\/policy\.md$/m, "policy: Follow the steps in policy.md");
expect((await loadDomain(dir)).policy).toBe("Follow the steps in policy.md");

const dir2 = copyOfClinic();
edit(path.join(dir2, "sandtable.yaml"), /^policy: \.\/policy\.md$/m, "policy: See the handbook for carrier policy.md");
expect((await loadDomain(dir2)).policy).toBe("See the handbook for carrier policy.md");

const dir3 = copyOfClinic();
edit(path.join(dir3, "sandtable.yaml"), /^policy: \.\/policy\.md$/m, "policy: Carrier Policy.md");
expect((await loadDomain(dir3)).policy).toBe("Carrier Policy.md");
});

it("inlines a file whose name has spaces", async () => {
const dir = copyOfClinic();
renameSync(path.join(dir, "policy.md"), path.join(dir, "Front Desk SOP.md"));
edit(path.join(dir, "sandtable.yaml"), /^policy: \.\/policy\.md$/m, "policy: ./Front Desk SOP.md");
expect((await loadDomain(dir)).policy).toBe(readFileSync(path.resolve("examples/clinic/policy.md"), "utf8"));

const dir2 = copyOfClinic();
renameSync(path.join(dir2, "tasks.yaml"), path.join(dir2, "clinic tasks.yaml"));
edit(path.join(dir2, "sandtable.yaml"), /^tasks: \.\/tasks\.yaml$/m, "tasks: ./clinic tasks.yaml");
expect((await loadDomain(dir2)).tasks.length).toBeGreaterThan(0);
});
});

Expand Down