Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
02c1c54
feat: preserve strict task context provenance records
BunsDev Nov 13, 2026
8875561
feat: add bounded scoped task context selection engines
BunsDev Nov 13, 2026
6e2ca4d
feat: wire local task context draft commands
BunsDev Nov 13, 2026
505baf0
Merge remote-tracking branch 'origin/main' into cf7-context-complete
BunsDev Nov 13, 2026
134574a
feat: admit task context with ordinary user sends
BunsDev Nov 13, 2026
4e70175
Preserve selected task context through native pending admission
BunsDev Nov 13, 2026
575fce4
List scoped task context candidates without selecting references
BunsDev Nov 13, 2026
ce4c76f
Recover unsent task context across reload and interrupted admission
BunsDev Nov 13, 2026
9ae879f
Refuse impossible task selections before capture
BunsDev Nov 13, 2026
f86417c
Capture exact scoped Notes read receipts per attempt lease
BunsDev Nov 13, 2026
72d806e
Persist attempt-bound native and Notes context observations
BunsDev Nov 13, 2026
5fa1684
Preserve native context targets before preview truncation
BunsDev Nov 13, 2026
4e56aea
Record scoped independent task context proposals
BunsDev Nov 13, 2026
6233f76
Protect private context connections across attempt publication
BunsDev Nov 13, 2026
f501ed3
Preserve unavailable native input identities through redaction
BunsDev Nov 13, 2026
a921783
Refuse credential-altered native identities and requests
BunsDev Nov 13, 2026
6b4eac9
Record scoped proposal capability for each task attempt
BunsDev Nov 13, 2026
178d0a3
Contain task metadata failures and protect independent channels
BunsDev Nov 13, 2026
e21398d
Wire task context proposals into desktop lifecycle
BunsDev Nov 13, 2026
0a6583d
Record scoped native check provenance and timed snapshots
BunsDev Nov 13, 2026
9b3600c
Add explicit task context selection and confirmation controls
BunsDev Nov 13, 2026
5c5bf52
Preserve portable task context and frozen saved records
BunsDev Nov 14, 2026
d036dda
test: wait for authoritative task context confirmation
BunsDev Nov 14, 2026
398f523
chore: remove unused context draft helper
BunsDev Nov 14, 2026
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: 2 additions & 2 deletions apps/desktop/e2e/pages-agents.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ try {
const url = fs.readFileSync(path.join(home, "pages-url"), "utf8");
await expect.poll(async () => {
const r = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json", Accept: "application/json, text/event-stream" }, body: JSON.stringify({ jsonrpc: "2.0", id: 99, method: "tools/call", params: { name: "search", arguments: { query: "" } } }) });
return (await r.json()).result?.isError;
}).toBe(true);
return r.status;
}).toBe(404);
await app.close(); ({ app, page } = await launch(home));
await expect(page.getByRole("button", { name: "Open note CLI note", exact: true }).last()).toBeVisible();
await page.getByRole("button", { name: "Open note CLI note", exact: true }).last().click();
Expand Down
5 changes: 5 additions & 0 deletions apps/desktop/e2e/release.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ test("minimum window keeps composer controls inside the main pane with Changes o
for (const id of ["context-project", "context-kind", "context-branch"]) {
expect(await tid(page, id).evaluate((el) => el.scrollWidth <= el.clientWidth + 1), `${id} text overflows its label`).toBe(true);
}
const selector = page.getByRole("button", { name: "Context for next request", exact: true });
await expect(selector).toBeVisible();
const selectorBox = (await selector.boundingBox())!, composerBox = (await tid(page, "composer-box").boundingBox())!;
expect(selectorBox.x).toBeGreaterThanOrEqual(composerBox.x);
expect(selectorBox.x + selectorBox.width).toBeLessThanOrEqual(composerBox.x + composerBox.width);
await page.screenshot({ path: test.info().outputPath("minimum-window.png") });
});

Expand Down
77 changes: 77 additions & 0 deletions apps/desktop/e2e/task-context-proposals.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { test, expect, type ElectronApplication } from "@playwright/test";
import fs from "node:fs";
import path from "node:path";
import { launch, seedHome, tid, items } from "./support";

// Main-process integration with a synthetic Claude executable. No provider turn or native-model qualification.
function fixture(home: string): string {
const cli = path.join(home, "proposal-cli.cjs");
fs.writeFileSync(cli, `#!${process.execPath}
const fs = require('node:fs');
const path = require('node:path');
if (process.argv.includes('--version')) { console.log('2.1.316 (Claude Code)'); process.exit(0); }
if (process.argv.includes('auth')) { console.log(JSON.stringify({ loggedIn: true })); process.exit(0); }
if (path.basename(process.cwd()).startsWith('modex-title-')) process.exit(1);
const emit = value => process.stdout.write(JSON.stringify(value) + '\\n');
const prior = ${JSON.stringify(path.join(home, "fixture-private-route"))};
const reports = ${JSON.stringify(path.join(home, "fixture-proposals.jsonl"))};
let running = false;
require('node:readline').createInterface({ input: process.stdin }).on('line', async line => {
const input = JSON.parse(line); if (input.type !== 'user' || running) return; running = true;
try {
const index = process.argv.indexOf('--mcp-config');
const connection = index < 0 ? undefined : JSON.parse(process.argv[index + 1]).mcpServers.modex_task_context;
if (!connection) { fs.appendFileSync(reports, JSON.stringify({ missing: true }) + '\\n'); emit({ type: 'assistant', message: { id: 'a', content: [{ type: 'text', text: 'Proposal connection missing' }] } }); return; }
const previous = fs.existsSync(prior) ? fs.readFileSync(prior, 'utf8') : null;
let oldStatus = null;
if (previous) oldStatus = await fetch(previous, { method: 'POST', redirect: 'error', headers: { 'Content-Type': 'application/json', Accept: 'application/json, text/event-stream' }, body: JSON.stringify({ jsonrpc: '2.0', id: 'old', method: 'tools/call', params: { name: 'propose_refs', arguments: { refs: [] } } }) }).then(r => r.status, () => 'closed');
fs.writeFileSync(prior, connection.url, { mode: 0o600 });
emit({ type: 'system', subtype: 'init', session_id: 'proposal-session', mcp_servers: [{ name: 'modex_task_context', status: 'connected' }] });
const noteId = JSON.parse(fs.readFileSync(${JSON.stringify(path.join(home, "fixture-note.json"))}, 'utf8')).id;
const response = await fetch(connection.url, { method: 'POST', redirect: 'error', headers: { 'Content-Type': 'application/json', Accept: 'application/json, text/event-stream' }, body: JSON.stringify({ jsonrpc: '2.0', id: 'proposal', method: 'tools/call', params: { name: 'propose_refs', arguments: { refs: [{ target: { kind: 'file', path: 'README.md' }, role: 'file' }, { target: { kind: 'note', pageId: noteId }, role: 'note' }] } } }) });
const result = await response.json();
fs.appendFileSync(reports, JSON.stringify({ missing: false, oldStatus, fresh: previous !== connection.url, status: response.status, error: result.result?.isError === true, detail: result.result?.isError ? result.result.content : undefined }) + '\\n');
emit({ type: 'assistant', message: { id: 'a', content: [{ type: 'text', text: 'Proposal fixture finished' }] } });
} catch (error) { emit({ type: 'assistant', message: { id: 'a', content: [{ type: 'text', text: 'Proposal fixture failed: ' + error.message }] } }); }
finally { emit({ type: 'result', subtype: 'success', result: 'Proposal fixture finished' }); process.stdin.destroy(); setTimeout(() => process.exit(0), 10); }
});
`, { mode: 0o755 });
return cli;
}

test("main owns a proposal service across fresh/resumed turns and revokes each private lease", async () => {
const seeded = seedHome({ default_backend: "claude", default_mode: "chat" });
const home = fs.realpathSync(seeded.home), repo = fs.realpathSync(seeded.repo);
const stateFile = path.join(home, "app/state.json"), state = JSON.parse(fs.readFileSync(stateFile, "utf8"));
state.settings.claude_bin = fixture(home); state.projects[0].path = repo;
const at = new Date().toISOString();
state.threads = [{ id: "proposal-thread", projectId: "p1", title: "Proposal fixture", titleSource: "manual", createdAt: at, updatedAt: at, cwd: repo, backend: "claude", mode: "chat", plan: false, auto: false, model: "", status: "idle" }];
fs.writeFileSync(stateFile, JSON.stringify(state)); fs.writeFileSync(path.join(home, "app/threads/proposal-thread.json"), "[]");
let app: ElectronApplication | undefined;
try {
const opened = await launch(home); app = opened.app; const page = opened.page;
const note = await page.evaluate(async () => { const project = await window.modex!.invoke("project:notes", { projectId: "p1" }); return window.modex!.invoke("space:create", { containerId: project.id, title: "Uninspected proposal", markdown: "private-note-body-not-inspected" }); });
fs.writeFileSync(path.join(home, "fixture-note.json"), JSON.stringify({ id: note.id }));
const row = page.locator('[data-testid="thread-row"][data-thread-id="proposal-thread"]'); await row.click();
for (const index of [0, 1]) {
await tid(page, "composer-input").fill(`Propose references ${index}`); await tid(page, "send").click();
await expect(items(page, "assistant")).toHaveCount(index + 1); await expect(row).toHaveAttribute("data-status", "idle");
const stored = await page.evaluate(() => window.modex!.invoke("thread:items", { threadId: "proposal-thread" }));
await test.info().attach(`proposal-fixture-${index}`, { body: fs.readFileSync(path.join(home, "fixture-proposals.jsonl")), contentType: "application/json" });
const user = stored.filter(item => item.kind === "user")[index]!; expect(user.kind).toBe("user"); if (user.kind !== "user") throw new Error("Missing request");
expect(user.contextEvidence?.refs.map(ref => ref.target)).toEqual([{ kind: "file", path: "README.md" }, { kind: "note", pageId: note.id }]);
expect(user.contextEvidence?.refs.every(ref => ref.relations.every(relation => relation.provenance === "model-proposed"))).toBe(true);
expect(user.contextEvidence?.captures).toEqual([]); expect(user.contextEvidence?.checks).toEqual([]);
expect(JSON.stringify(user.contextEvidence)).not.toContain("private-note-body-not-inspected");
expect(user.contextEvidence?.capabilities?.map(receipt => receipt.capability)).toEqual([{ state: "available" }]);
expect(await page.evaluate(turnId => window.modex!.invoke("task:context", { threadId: "proposal-thread", turnId }), user.id)).toEqual(user.contextEvidence);
await expect(page.evaluate(({ turnId, revision, refId }) => window.modex!.invoke("task:check-confirm", { threadId: "proposal-thread", turnId, expectedRevision: revision, itemId: "foreign-check", refIds: [refId] }), { turnId: user.id, revision: user.contextEvidence!.revision, refId: user.contextEvidence!.refs[0]!.id })).rejects.toThrow(/does not belong/);
}
const reports = fs.readFileSync(path.join(home, "fixture-proposals.jsonl"), "utf8").trim().split("\n").map(line => JSON.parse(line));
expect(reports).toEqual([{ missing: false, oldStatus: null, fresh: true, status: 200, error: false }, { missing: false, oldStatus: 404, fresh: true, status: 200, error: false }]);
const lastURL = fs.readFileSync(path.join(home, "fixture-private-route"), "utf8");
expect(await fetch(lastURL).then(response => response.status)).toBe(404);
await app.close(); app = undefined;
expect(await fetch(lastURL).then(() => false, () => true)).toBe(true);
} finally { await app?.close(); }
});
Loading
Loading