dsh-super-code 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +162 -0
  3. package/client/index.js +920 -0
  4. package/cordis.patch.yml +21 -0
  5. package/lib/core/delegation.d.ts +59 -0
  6. package/lib/core/delegation.d.ts.map +1 -0
  7. package/lib/core/delegation.js +41 -0
  8. package/lib/core/delegation.js.map +1 -0
  9. package/lib/core/evaluation.d.ts +123 -0
  10. package/lib/core/evaluation.d.ts.map +1 -0
  11. package/lib/core/evaluation.js +180 -0
  12. package/lib/core/evaluation.js.map +1 -0
  13. package/lib/core/experiment-recipes.d.ts +5 -0
  14. package/lib/core/experiment-recipes.d.ts.map +1 -0
  15. package/lib/core/experiment-recipes.js +67 -0
  16. package/lib/core/experiment-recipes.js.map +1 -0
  17. package/lib/core/guidance.d.ts +10 -0
  18. package/lib/core/guidance.d.ts.map +1 -0
  19. package/lib/core/guidance.js +16 -0
  20. package/lib/core/guidance.js.map +1 -0
  21. package/lib/core/session-scan.d.ts +8 -0
  22. package/lib/core/session-scan.d.ts.map +1 -0
  23. package/lib/core/session-scan.js +21 -0
  24. package/lib/core/session-scan.js.map +1 -0
  25. package/lib/core/task-memory.d.ts +81 -0
  26. package/lib/core/task-memory.d.ts.map +1 -0
  27. package/lib/core/task-memory.js +158 -0
  28. package/lib/core/task-memory.js.map +1 -0
  29. package/lib/core/teams.d.ts +19 -0
  30. package/lib/core/teams.d.ts.map +1 -0
  31. package/lib/core/teams.js +40 -0
  32. package/lib/core/teams.js.map +1 -0
  33. package/lib/core/tool-evidence.d.ts +57 -0
  34. package/lib/core/tool-evidence.d.ts.map +1 -0
  35. package/lib/core/tool-evidence.js +97 -0
  36. package/lib/core/tool-evidence.js.map +1 -0
  37. package/lib/dsh/index.d.ts +6 -0
  38. package/lib/dsh/index.d.ts.map +1 -0
  39. package/lib/dsh/index.js +11 -0
  40. package/lib/dsh/index.js.map +1 -0
  41. package/lib/dsh/super-code.d.ts +22 -0
  42. package/lib/dsh/super-code.d.ts.map +1 -0
  43. package/lib/dsh/super-code.js +247 -0
  44. package/lib/dsh/super-code.js.map +1 -0
  45. package/lib/evaluate.d.ts +3 -0
  46. package/lib/evaluate.d.ts.map +1 -0
  47. package/lib/evaluate.js +40 -0
  48. package/lib/evaluate.js.map +1 -0
  49. package/lib/experiments.d.ts +77 -0
  50. package/lib/experiments.d.ts.map +1 -0
  51. package/lib/experiments.js +196 -0
  52. package/lib/experiments.js.map +1 -0
  53. package/lib/index.d.ts +13 -0
  54. package/lib/index.d.ts.map +1 -0
  55. package/lib/index.js +14 -0
  56. package/lib/index.js.map +1 -0
  57. package/lib/super-agent-usage.d.ts +44 -0
  58. package/lib/super-agent-usage.d.ts.map +1 -0
  59. package/lib/super-agent-usage.js +203 -0
  60. package/lib/super-agent-usage.js.map +1 -0
  61. package/lib/task-memory-projection.d.ts +43 -0
  62. package/lib/task-memory-projection.d.ts.map +1 -0
  63. package/lib/task-memory-projection.js +48 -0
  64. package/lib/task-memory-projection.js.map +1 -0
  65. package/lib/task-memory-store.d.ts +35 -0
  66. package/lib/task-memory-store.d.ts.map +1 -0
  67. package/lib/task-memory-store.js +69 -0
  68. package/lib/task-memory-store.js.map +1 -0
  69. package/package.json +123 -0
  70. package/presets/super-code/agent.cordis.yml +50 -0
  71. package/presets/super-code/preset.yml +3 -0
@@ -0,0 +1,247 @@
1
+ import z from '@deepseek-ai/schemastery';
2
+ import { defineTool } from '@deepseek-ai/dsh-tools';
3
+ import { SessionSeq } from '@deepseek-ai/dsh-session';
4
+ import { PERSONA_PREFIX_SECTION } from '@deepseek-ai/dsh-system-prompt';
5
+ import { TEAM_NAMES, METHODS, SUPER_CODE_INSTRUCTIONS, readTeamMethod } from '../core/teams.js';
6
+ import { EXPERIMENT_RECIPES, readExperimentRecipe } from '../core/experiment-recipes.js';
7
+ import { taskMemoryProjection, taskMemoryEventOf } from '../task-memory-projection.js';
8
+ import { requireTaskMemory, reviseTaskMemory, taskMemoryContext, taskMemoryRead, taskMemoryCreateSchema, taskMemoryPatchSchema, taskMemorySchema, sourceSchema } from '../core/task-memory.js';
9
+ import { createMemberBrief, validateMemberResult } from '../core/delegation.js';
10
+ import { z as json } from 'zod';
11
+ import { createGuidanceSelector, GUIDED_INSTRUCTIONS } from '../core/guidance.js';
12
+ import { listToolEvidence, readToolEvidence, toolEvidenceRef } from '../core/tool-evidence.js';
13
+ import { scanSessionPage } from '../core/session-scan.js';
14
+ import { TaskMemoryStore } from '../task-memory-store.js';
15
+ export const name = 'super-code';
16
+ export const inject = ['tools', 'systemPrompt', 'sessions', 'sessionProjections'];
17
+ export const Config = z.object({
18
+ maxTasks: z.number().step(1).min(1).max(128).default(32),
19
+ maxContextBytes: z.number().step(1).min(1024).max(262144).default(32768),
20
+ guidedRoutes: z.array(z.object({ provider: z.string().required(), model: z.string().required() })),
21
+ });
22
+ function assertSource(session, source) {
23
+ const event = session.eventAt(SessionSeq(source.seq));
24
+ if (event?.type !== 'user/message' || event.data.source.kind !== 'user')
25
+ throw new Error('Requirement source must reference a direct user message in this session');
26
+ const original = event.data.content.filter(block => block.type === 'text').map(block => block.text).join('\n');
27
+ if (!original.includes(source.quote))
28
+ throw new Error('Requirement quote is not present in its original user message');
29
+ }
30
+ /** Schema-owned expectations only; never echo submitted values or arbitrary error messages. */
31
+ function inputIssue(issue) {
32
+ let hint = issue.code;
33
+ if (issue.code === 'invalid_type')
34
+ hint += `; expected ${issue.expected}`;
35
+ if (issue.code === 'too_small')
36
+ hint += `; ${issue.origin} ${issue.inclusive ? 'min' : 'greater than'} ${issue.minimum}`;
37
+ if (issue.code === 'too_big')
38
+ hint += `; ${issue.origin} ${issue.inclusive ? 'max' : 'less than'} ${issue.maximum}`;
39
+ return `${issue.path.map(String).join('.').slice(0, 120) || 'record'} (${hint})`;
40
+ }
41
+ // Runtime-only contracts keep the model-facing schema compact without silently ignoring fields.
42
+ const actionFields = {
43
+ list: { required: [] }, read: { required: ['taskId'], optional: ['view'] },
44
+ source: { required: ['eventSeq'] }, history: { required: ['eventSeq'] },
45
+ create: { required: ['record'] }, update: { required: ['taskId', 'expectedRevision', 'record'] },
46
+ focus: { required: ['taskId'] }, archive: { required: ['taskId', 'expectedRevision'] },
47
+ archives: { required: [], optional: ['taskId', 'eventSeq'] }, restore: { required: ['eventSeq', 'record'] },
48
+ delegate: { required: ['taskId', 'record'] }, validate_member: { required: ['taskId', 'record'] },
49
+ evidence: { required: [], optional: ['eventSeq', 'record'] },
50
+ };
51
+ function assertActionFields(args) {
52
+ if (!Object.hasOwn(actionFields, args.action))
53
+ throw new Error('Unsupported task action');
54
+ const rule = actionFields[args.action];
55
+ for (const field of rule.required)
56
+ if (args[field] === undefined)
57
+ throw new Error(`${args.action} requires ${field}; no task snapshot was appended.`);
58
+ for (const field of ['taskId', 'expectedRevision', 'eventSeq', 'record', 'view']) {
59
+ if (args[field] !== undefined && !rule.required.includes(field) && !rule.optional?.includes(field))
60
+ throw new Error(`${field} is not supported by ${args.action}`);
61
+ }
62
+ if (args.action === 'evidence' && args.record !== undefined && args.eventSeq !== undefined)
63
+ throw new Error('evidence accepts either a record or an eventSeq cursor');
64
+ }
65
+ /** Installs no agent loop and starts no model calls. */
66
+ export function apply(ctx, config = {}) {
67
+ const maxTasks = config.maxTasks ?? 32;
68
+ const maxContextBytes = config.maxContextBytes ?? 32768;
69
+ const selectGuidance = createGuidanceSelector(config.guidedRoutes);
70
+ if (!Number.isSafeInteger(maxTasks) || maxTasks < 1 || maxTasks > 128 || !Number.isSafeInteger(maxContextBytes) || maxContextBytes < 1024 || maxContextBytes > 262144)
71
+ throw new Error('Invalid super-code capacity');
72
+ ctx.sessionProjections.register(taskMemoryProjection);
73
+ const memory = new TaskMemoryStore(ctx, maxContextBytes);
74
+ ctx.systemPrompt.section({ name: PERSONA_PREFIX_SECTION, order: ctx.systemPrompt.getSectionOrder('DEPLOYMENT_PERSONA_PREFIX'), text: SUPER_CODE_INSTRUCTIONS });
75
+ // Wrap the host selection waterfall: providers run before its model snapshot is resolved.
76
+ ctx.on('system-prompt/assemble', async (_assembly, _context, next) => {
77
+ const assembled = await next();
78
+ if (selectGuidance(assembled.variables.provider, assembled.variables.model) === 'standard')
79
+ return assembled;
80
+ return { ...assembled, sections: assembled.sections.map(section => section.name === PERSONA_PREFIX_SECTION && section.text === SUPER_CODE_INSTRUCTIONS
81
+ ? { ...section, text: `${section.text}\n${GUIDED_INSTRUCTIONS}` } : section) };
82
+ }, { prepend: true });
83
+ ctx.systemPrompt.context({ name: 'super-code:tasks', order: 80, text: ({ agent }) => {
84
+ if (agent === undefined)
85
+ return '';
86
+ if (memory.isPending(agent.session))
87
+ return 'The last task-memory checkpoint is unconfirmed. Use super_code_task read to retry persistence before relying on it.';
88
+ return taskMemoryContext(memory.current(agent.session), maxContextBytes);
89
+ } });
90
+ ctx.tools.register(defineTool({
91
+ name: 'super_code_method',
92
+ description: 'Read missing expertise, not a routine prerequisite. Select a known method directly; omit method only to inspect a team. Reuse guidance in context; batch with independent reads when useful.',
93
+ parameters: { team: { type: 'string', enum: TEAM_NAMES, required: true }, method: { type: 'string', enum: Object.keys(METHODS) },
94
+ recipe: { type: 'string', enum: EXPERIMENT_RECIPES, description: 'Optional runnable Shell example for a hard problem: failure reduction, differential oracle, controlled async interleavings or contract relation. Omit when unnecessary.' } },
95
+ output: { schema: { type: 'string' }, render: (_args, value) => [{ type: 'text', text: value }] },
96
+ isConcurrencySafe: () => true,
97
+ execute: async (args) => {
98
+ const method = readTeamMethod(args.team, args.method);
99
+ return args.recipe === undefined ? method : `${method}\n\n${readExperimentRecipe(args.recipe)}`;
100
+ },
101
+ }));
102
+ ctx.tools.register(defineTool({
103
+ name: 'super_code_task',
104
+ description: `Task memory; never grants permission or executes work. Simple tasks need no record. Actions: list; read(taskId,view?); source(eventSeq); create(record); update(taskId,expectedRevision,record patch); focus(taskId); archive(taskId,expectedRevision); history(eventSeq). Create fields: id,title,team,depth,workspace,sourceVersion,goal,source:{seq,quote},requirements:[{id,text,source:{seq,quote}}],acceptance:[string]. Source seqs appear in runtime context. Update preserves omitted fields; requirement entries replace matching ids, removeRequirements explicitly removes ids. Goal/requirements/workspace/acceptance changes need a user source. Old evidence becomes stale on requirements/source revision changes. Optional updates: decisions:[string], evidence:[{summary,ref,sourceVersion,requirementsRevision,kind:observed|assumption|test|decision}], next:string, status:active|paused|completed|cancelled. Archive only finished tasks; keep eventSeq to read history. Focus does not stop work. delegate(taskId,record:{owner,attemptId,objective,ownedPaths:[string],acceptance:[string],maxTokens}) returns a compact brief to pass to host subagent. validate_member(taskId,record:{assignment:original assignment,result:{binding,owner,attemptId,outcome:completed|failed|cancelled|stop_unknown,summary,artifacts:[string],checks:[string],unknowns:[string]}}) rejects stale returns; reviewable still needs lead review. Accounting is separate; never guess costs or treat model-reported usage as a verified budget.`,
105
+ // Pagination never scans or returns an unbounded archive in one tool call.
106
+ parameters: {
107
+ action: { type: 'string', enum: ['list', 'read', 'source', 'create', 'update', 'focus', 'archive', 'archives', 'restore', 'history', 'delegate', 'validate_member', 'evidence'], required: true,
108
+ description: 'evidence: record:{callSeq,resultSeq} or {ref} reads a pair, not acceptance/current-code proof. Long output returns a head/tail excerpt and readMore; optional record.offset reads original text pages (UTF-16 offsets). Without record, list identities; match callId/turn/step and inspect arguments. Directory/archives use exclusive eventSeq/nextBeforeSeq; done=false means more. archives optionally filters taskId. restore: archived eventSeq plus record:{source:{seq,quote},sourceVersion}, after user asks to resume and you inspect the workspace. sourceVersion must distinguish relevant working-tree edits, not just HEAD. Recorded versions do not verify current files. Restore retains requirements and invalidates old evidence; starts no workers.' },
109
+ taskId: { type: 'string' }, expectedRevision: { type: 'integer' }, eventSeq: { type: 'integer', description: 'Use visible runtime source identities; if the newest user source is absent, list returns recentUserEventSeqs. Never guess an event sequence.' }, record: { type: 'json' },
110
+ view: { type: 'string', enum: ['resume', 'full'], description: 'Only for read: default resume returns {current} with all constraints and bounded current evidence. full retrieves omitted details: source quotes, all evidence and versions. Stale evidence is historical, not current proof.' },
111
+ },
112
+ output: { schema: { type: 'string' }, render: (_args, value) => [{ type: 'text', text: value }] },
113
+ execute: async (args, exec) => {
114
+ try {
115
+ if (exec.agent === undefined)
116
+ throw new Error('super-code requires an agent-owned session');
117
+ assertActionFields(args);
118
+ const session = exec.agent.session;
119
+ if (args.action === 'evidence') {
120
+ exec.signal.throwIfAborted();
121
+ if (args.record === undefined)
122
+ return JSON.stringify(await listToolEvidence(session.seq, args.eventSeq ?? session.seq, seq => session.eventAt(SessionSeq(seq)), exec.signal));
123
+ const input = json.union([
124
+ json.object({ ref: json.string().min(1).max(4000), offset: json.number().int().nonnegative().safe().optional() }).strict(),
125
+ json.object({ callSeq: json.number().int().nonnegative(), resultSeq: json.number().int().nonnegative(), offset: json.number().int().nonnegative().safe().optional() }).strict(),
126
+ ]).parse(args.record);
127
+ const ref = 'ref' in input ? input.ref : toolEvidenceRef({ ...input, sessionId: session.id });
128
+ return JSON.stringify(readToolEvidence(session.id, ref, seq => session.eventAt(SessionSeq(seq)), input.offset));
129
+ }
130
+ const mutating = ['create', 'update', 'focus', 'archive', 'restore'].includes(args.action);
131
+ if (!mutating) {
132
+ const { state, end } = await memory.read(session, exec.signal);
133
+ if (args.action === 'archives') {
134
+ const records = [];
135
+ const page = await scanSessionPage(end, args.eventSeq ?? end, seq => session.eventAt(SessionSeq(seq)), event => {
136
+ const item = taskMemoryEventOf(event);
137
+ if (item.kind === 'record' && item.record.kind === 'archive' && (args.taskId === undefined || item.record.task.id === args.taskId)) {
138
+ const { id, title, status } = item.record.task;
139
+ records.push({ eventSeq: event.seq, id, title, status });
140
+ }
141
+ return records.length >= 10;
142
+ }, exec.signal);
143
+ return JSON.stringify({ records, ...page });
144
+ }
145
+ if (args.action === 'list')
146
+ return JSON.stringify({ tasks: Object.values(state.tasks).map(({ id, title, status, revision }) => ({ id, title, status, revision })), focus: state.focus, recentUserEventSeqs: state.recentSources });
147
+ if (args.action === 'source' || args.action === 'history') {
148
+ if (args.eventSeq === undefined)
149
+ throw new Error('eventSeq is required');
150
+ const event = session.eventAt(SessionSeq(args.eventSeq));
151
+ if (args.action === 'source' && event?.type === 'user/message' && event.data.source.kind === 'user')
152
+ return JSON.stringify(event);
153
+ if (args.action === 'history' && event !== undefined && taskMemoryEventOf(event).kind === 'record')
154
+ return JSON.stringify(event);
155
+ throw new Error('The event is not a matching source or task record');
156
+ }
157
+ if (args.action === 'read') {
158
+ const task = requireTaskMemory(state, args.taskId ?? '');
159
+ return args.view === 'full' ? JSON.stringify(task) : taskMemoryRead(task, maxContextBytes);
160
+ }
161
+ if (args.action === 'delegate' || args.action === 'validate_member') {
162
+ const task = requireTaskMemory(state, args.taskId ?? '');
163
+ if (args.action === 'delegate')
164
+ return JSON.stringify(createMemberBrief(task, session.id, args.record));
165
+ const envelope = json.object({ assignment: json.unknown(), result: json.unknown() }).strict().parse(args.record);
166
+ return JSON.stringify(validateMemberResult(task, session.id, envelope.assignment, envelope.result));
167
+ }
168
+ throw new Error('Unsupported task action');
169
+ }
170
+ const receipt = await memory.write(session, exec.signal, state => {
171
+ let change;
172
+ if (args.action === 'restore') {
173
+ if (!Number.isSafeInteger(args.eventSeq) || args.eventSeq < 0)
174
+ throw new Error('An archived eventSeq is required');
175
+ const event = session.eventAt(SessionSeq(args.eventSeq));
176
+ if (event === undefined)
177
+ throw new Error('Unknown archive event');
178
+ const archived = taskMemoryEventOf(event);
179
+ if (archived.kind !== 'record' || archived.record.kind !== 'archive')
180
+ throw new Error('Only archived tasks can be restored');
181
+ const record = json.object({ source: sourceSchema, sourceVersion: json.string().trim().min(1).max(4000) }).strict().parse(args.record);
182
+ assertSource(session, record.source);
183
+ if (record.source.seq <= event.seq)
184
+ throw new Error('Restoration requires a user message after the archive');
185
+ const task = archived.record.task;
186
+ if (Object.hasOwn(state.tasks, task.id))
187
+ throw new Error(`Task ${task.id} already exists`);
188
+ if (Object.keys(state.tasks).length >= maxTasks)
189
+ throw new Error('Working set is full; archive a completed task first');
190
+ change = { kind: 'save', task: taskMemorySchema.parse({ ...task, ...record, createdAtSeq: session.seq, revision: 1, requirementsRevision: task.requirementsRevision + 1, delegationRevision: 1, status: 'active', decisions: [], next: '' }) };
191
+ }
192
+ else if (args.action === 'create') {
193
+ const record = taskMemoryCreateSchema.parse(args.record);
194
+ if (Object.hasOwn(state.tasks, record.id))
195
+ throw new Error(`Task ${record.id} already exists`);
196
+ if (Object.keys(state.tasks).length >= maxTasks)
197
+ throw new Error('Working set is full; archive a completed task first');
198
+ if (new Set(record.requirements.map(item => item.id)).size !== record.requirements.length)
199
+ throw new Error('Duplicate requirement ids');
200
+ assertSource(session, record.source);
201
+ record.requirements.forEach(item => assertSource(session, item.source));
202
+ change = { kind: 'save', task: taskMemorySchema.parse({ ...record, createdAtSeq: session.seq, revision: 1, requirementsRevision: 1, delegationRevision: 1, status: 'active', decisions: [], evidence: [], next: '' }) };
203
+ }
204
+ else {
205
+ const task = requireTaskMemory(state, args.taskId ?? '');
206
+ if (args.action === 'focus') {
207
+ if (state.focus.kind === 'task' && state.focus.id === task.id)
208
+ return { kind: 'unchanged', id: task.id, revision: task.revision };
209
+ change = { kind: 'focus', id: task.id };
210
+ }
211
+ else {
212
+ if (args.expectedRevision === undefined)
213
+ throw new Error(`${args.action} requires expectedRevision; use the current task view. No task snapshot was appended.`);
214
+ if (args.expectedRevision !== task.revision)
215
+ throw new Error(`Stale task ${task.id}; read revision ${task.revision} first`);
216
+ if (args.action === 'archive') {
217
+ if (task.status !== 'completed' && task.status !== 'cancelled')
218
+ throw new Error('Only completed or cancelled memory can be archived; stop workers separately');
219
+ change = { kind: 'archive', task };
220
+ }
221
+ else {
222
+ const patch = taskMemoryPatchSchema.parse(args.record);
223
+ if (patch.source !== undefined)
224
+ assertSource(session, patch.source);
225
+ patch.requirements?.forEach(item => assertSource(session, item.source));
226
+ const revised = reviseTaskMemory(task, patch, args.expectedRevision);
227
+ if (revised === task)
228
+ return { kind: 'unchanged', id: task.id, revision: task.revision };
229
+ change = { kind: 'save', task: revised };
230
+ }
231
+ }
232
+ }
233
+ return change;
234
+ });
235
+ return JSON.stringify({ action: args.action, ...receipt });
236
+ }
237
+ catch (error) {
238
+ if (error instanceof json.ZodError)
239
+ throw new Error(`Invalid ${args.action} input: ${error.issues.slice(0, 4).map(inputIssue).join('; ')}${error.issues.length > 4 ? '; additional invalid fields omitted' : ''}. Check the action fields; no automatic correction was applied.`);
240
+ throw error;
241
+ }
242
+ },
243
+ }));
244
+ }
245
+ const plugin = { name, inject, Config, apply };
246
+ export default plugin;
247
+ //# sourceMappingURL=super-code.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"super-code.js","sourceRoot":"","sources":["../../src/dsh/super-code.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,0BAA0B,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAGrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AACvE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAE/F,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AACxF,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AACtF,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,cAAc,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAE9L,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAC/E,OAAO,EAAE,CAAC,IAAI,IAAI,EAAE,MAAM,KAAK,CAAA;AAE/B,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAA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E,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAA;gCACxF,MAAM,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;4BAC1C,CAAC;wBACH,CAAC;oBACH,CAAC;oBACD,OAAO,MAAM,CAAA;gBACf,CAAC,CAAC,CAAA;gBACF,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC,CAAA;YAC5D,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,KAAK,YAAY,IAAI,CAAC,QAAQ;oBAAE,MAAM,IAAI,KAAK,CAAC,WAAW,IAAI,CAAC,MAAM,WAAW,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,qCAAqC,CAAC,CAAC,CAAC,EAAE,iEAAiE,CAAC,CAAA;gBACjR,MAAM,KAAK,CAAA;YACb,CAAC;QACH,CAAC;KACF,CAAC,CAAC,CAAA;AACL,CAAC;AAED,MAAM,MAAM,GAA4H,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAA;AACvK,eAAe,MAAM,CAAA"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=evaluate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../src/evaluate.ts"],"names":[],"mappings":""}
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env node
2
+ import { readFile } from 'node:fs/promises';
3
+ import { createReadStream } from 'node:fs';
4
+ import { createInterface } from 'node:readline';
5
+ import { evaluateSuperCodeBatch } from './core/evaluation.js';
6
+ /** Offline acceptance only: this command never starts a model or rewrites evidence. */
7
+ async function main() {
8
+ const [manifestPath, measurementsPath, ...extra] = process.argv.slice(2);
9
+ if (!manifestPath || !measurementsPath || extra.length > 0)
10
+ throw new Error('Usage: super-code-eval manifest.json measurements.jsonl');
11
+ const manifest = JSON.parse(await readFile(manifestPath, 'utf8'));
12
+ evaluateSuperCodeBatch(manifest, []); // Validate the manifest before reading measurements.
13
+ const rows = [];
14
+ const input = createReadStream(measurementsPath, { encoding: 'utf8' });
15
+ const lines = createInterface({ input, crlfDelay: Infinity });
16
+ try {
17
+ for await (const line of lines) {
18
+ if (line.trim() === '')
19
+ continue;
20
+ rows.push(JSON.parse(line));
21
+ if (rows.length > manifest.cases.length * 2)
22
+ throw new Error('Too many measurements: one baseline and one candidate per case are allowed');
23
+ }
24
+ }
25
+ finally {
26
+ lines.close();
27
+ input.destroy();
28
+ }
29
+ const result = evaluateSuperCodeBatch(manifest, rows);
30
+ process.stdout.write(JSON.stringify(result, null, 2) + '\n');
31
+ process.exitCode = result.accepted ? 0 : 1;
32
+ }
33
+ try {
34
+ await main();
35
+ }
36
+ catch (error) {
37
+ process.stderr.write(JSON.stringify({ status: 'invalid', accepted: false, error: error instanceof Error ? error.message : 'Evaluation failed' }) + '\n');
38
+ process.exitCode = 2;
39
+ }
40
+ //# sourceMappingURL=evaluate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluate.js","sourceRoot":"","sources":["../src/evaluate.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAG7D,uFAAuF;AACvF,KAAK,UAAU,IAAI;IACjB,MAAM,CAAC,YAAY,EAAE,gBAAgB,EAAE,GAAG,KAAK,CAA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CAAC,GAAG,IAAI,CAAC,CAAA;IAC5D,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC5C,CAAC;AAED,IAAI,CAAC;IAAC,MAAM,IAAI,EAAE,CAAA;AAAC,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,mBAAmB,EAAE,CAAC,GAAG,IAAI,CAAC,CAAA;IACxJ,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;AACtB,CAAC"}
@@ -0,0 +1,77 @@
1
+ export type Verdict = {
2
+ kind: 'pass';
3
+ } | {
4
+ kind: 'fail';
5
+ signature: string;
6
+ detail?: unknown;
7
+ } | {
8
+ kind: 'unknown';
9
+ reason: string;
10
+ };
11
+ export type Probe<T> = (input: T, signal?: AbortSignal) => Verdict | Promise<Verdict>;
12
+ export interface ExperimentLimits {
13
+ maxChecks: number;
14
+ timeoutMs: number;
15
+ signal?: AbortSignal;
16
+ }
17
+ export interface ExperimentStats {
18
+ checks: number;
19
+ maxChecks: number;
20
+ elapsedMs: number;
21
+ timeoutMs: number;
22
+ }
23
+ /** Shared callback budget; hard interruption belongs to the outer shell timeout. */
24
+ export declare class ExperimentBudget {
25
+ private checks;
26
+ private readonly started;
27
+ private readonly maxChecks;
28
+ private readonly timeoutMs;
29
+ private readonly signal?;
30
+ constructor(limits: ExperimentLimits);
31
+ private checkTime;
32
+ check<T>(probe: Probe<T>, input: T): Promise<Verdict>;
33
+ stats(): ExperimentStats;
34
+ }
35
+ export interface Reduction<T> {
36
+ status: 'reduced' | 'not-reproduced' | 'inconclusive' | 'stopped';
37
+ input: T[];
38
+ reproduced: boolean;
39
+ minimality: 'one-removal' | 'not-established';
40
+ reason: string;
41
+ stats: ExperimentStats;
42
+ }
43
+ /** Chunk deletion followed by single deletion; no global-minimum claim. */
44
+ export declare function reduceFailure<T>(input: readonly T[], signature: string, probe: Probe<T[]>, budget: ExperimentBudget): Promise<Reduction<T>>;
45
+ export type SearchResult<T> = {
46
+ status: 'counterexample';
47
+ index: number;
48
+ input: T;
49
+ verdict: Extract<Verdict, {
50
+ kind: 'fail';
51
+ }>;
52
+ stats: ExperimentStats;
53
+ } | {
54
+ status: 'checked' | 'inconclusive' | 'stopped';
55
+ checkedCases: number;
56
+ unknownCases: number;
57
+ reason: string;
58
+ stats: ExperimentStats;
59
+ };
60
+ /** Consumes cases lazily and stops at the first explicit counterexample. */
61
+ export declare function findCounterexample<T>(cases: Iterable<T>, probe: Probe<T>, budget: ExperimentBudget): Promise<SearchResult<T>>;
62
+ export type Observation<T, O> = (input: T, signal?: AbortSignal) => O | Promise<O>;
63
+ /** Exceptions propagate; behavior-difference identifies any mismatch, not a specific fault. */
64
+ export declare function differential<T, O>(reference: Observation<T, O>, candidate: Observation<T, O>, equal?: (left: O, right: O) => boolean): Probe<T>;
65
+ /** The caller supplies a contract-backed transform and relation, not a guessed oracle. */
66
+ export declare function metamorphic<T, O>(contract: string, observe: Observation<T, O>, transform: (input: T) => T, holds: (original: O, transformed: O) => boolean): Probe<T>;
67
+ export interface ScheduleStep {
68
+ lane: 0 | 1;
69
+ index: number;
70
+ }
71
+ export interface ScheduleSet extends Iterable<ScheduleStep[]> {
72
+ readonly coverage: 'complete' | 'limited';
73
+ readonly count: number;
74
+ }
75
+ /** Enumerate two ordered lanes, bounded before allocation; not a runtime scheduler. */
76
+ export declare function interleavings(leftLength: number, rightLength: number, maxSchedules: number): ScheduleSet;
77
+ //# sourceMappingURL=experiments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"experiments.d.ts","sourceRoot":"","sources":["../src/experiments.ts"],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AAG,OAAO,CAAC,CAAC,CAAC,CAAA;AAElF,+FAA+F;AAC/F,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,GAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,OAA2B,GAAG,KAAK,CAAC,CAAC,CAAC,CASlK;AAED,0FAA0F;AAC1F,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,EACxG,KAAK,EAAE,CAAC,QAAQ,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,KAAK,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAW3D;AAED,MAAM,WAAW,YAAY;IAAG,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AAC5D,MAAM,WAAW,WAAY,SAAQ,QAAQ,CAAC,YAAY,EAAE,CAAC;IAC3D,QAAQ,CAAC,QAAQ,EAAE,UAAU,GAAG,SAAS,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAClE;AAED,uFAAuF;AACvF,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,WAAW,CA2BxG"}
@@ -0,0 +1,196 @@
1
+ /** Pure experiment helpers, imported only by task-owned scripts under the host shell. */
2
+ import { isDeepStrictEqual } from 'node:util';
3
+ import { performance } from 'node:perf_hooks';
4
+ class ExperimentStopped extends Error {
5
+ reason;
6
+ constructor(reason) {
7
+ super(`Experiment stopped: ${reason}`);
8
+ this.reason = reason;
9
+ }
10
+ }
11
+ /** Shared callback budget; hard interruption belongs to the outer shell timeout. */
12
+ export class ExperimentBudget {
13
+ checks = 0;
14
+ started = performance.now();
15
+ maxChecks;
16
+ timeoutMs;
17
+ signal;
18
+ constructor(limits) {
19
+ if (!Number.isSafeInteger(limits.maxChecks) || limits.maxChecks < 1 || !Number.isFinite(limits.timeoutMs) || limits.timeoutMs <= 0) {
20
+ throw new Error('maxChecks must be a positive safe integer; timeoutMs must be positive and finite');
21
+ }
22
+ this.maxChecks = limits.maxChecks;
23
+ this.timeoutMs = limits.timeoutMs;
24
+ this.signal = limits.signal;
25
+ }
26
+ checkTime() {
27
+ if (this.signal?.aborted)
28
+ throw new ExperimentStopped('cancelled');
29
+ if (performance.now() - this.started >= this.timeoutMs)
30
+ throw new ExperimentStopped('deadline');
31
+ }
32
+ async check(probe, input) {
33
+ this.checkTime();
34
+ if (this.checks >= this.maxChecks)
35
+ throw new ExperimentStopped('checks');
36
+ this.checks++;
37
+ // Inputs must be structured-cloneable; a probe cannot mutate later trials.
38
+ let result;
39
+ try {
40
+ result = await probe(structuredClone(input), this.signal);
41
+ }
42
+ catch (error) {
43
+ if (this.signal?.aborted)
44
+ throw new ExperimentStopped('cancelled');
45
+ throw error;
46
+ }
47
+ this.checkTime();
48
+ if (!result || !['pass', 'fail', 'unknown'].includes(result.kind)
49
+ || (result.kind === 'fail' && (typeof result.signature !== 'string' || !result.signature.trim()))
50
+ || (result.kind === 'unknown' && (typeof result.reason !== 'string' || !result.reason.trim()))) {
51
+ throw new Error('Probe must return pass, fail with a signature, or unknown with a reason');
52
+ }
53
+ return result;
54
+ }
55
+ stats() {
56
+ return { checks: this.checks, maxChecks: this.maxChecks, elapsedMs: performance.now() - this.started, timeoutMs: this.timeoutMs };
57
+ }
58
+ }
59
+ /** Chunk deletion followed by single deletion; no global-minimum claim. */
60
+ export async function reduceFailure(input, signature, probe, budget) {
61
+ if (typeof signature !== 'string' || !signature.trim())
62
+ throw new Error('A nonempty target failure signature is required');
63
+ let current = structuredClone([...input]), reproduced = false, uncertain = false;
64
+ const result = (status, reason, minimality = 'not-established') => ({ status, input: current, reproduced, minimality, reason, stats: budget.stats() });
65
+ const matches = async (candidate) => {
66
+ const first = await budget.check(probe, candidate);
67
+ if (first.kind === 'unknown') {
68
+ uncertain = true;
69
+ return false;
70
+ }
71
+ if (first.kind !== 'fail' || first.signature !== signature)
72
+ return false;
73
+ const second = await budget.check(probe, candidate);
74
+ if (second.kind !== 'fail' || second.signature !== signature) {
75
+ uncertain = true;
76
+ return false;
77
+ }
78
+ return true;
79
+ };
80
+ try {
81
+ if (!await matches(current))
82
+ return result(uncertain ? 'inconclusive' : 'not-reproduced', 'Initial input did not reproduce the target failure twice');
83
+ reproduced = true;
84
+ if (current.length && await matches([]))
85
+ current = [];
86
+ let partitions = 2;
87
+ while (current.length > 0) {
88
+ const width = Math.ceil(current.length / partitions);
89
+ let changed = false;
90
+ for (let start = 0; start < current.length; start += width) {
91
+ const candidate = [...current.slice(0, start), ...current.slice(start + width)];
92
+ if (await matches(candidate)) {
93
+ current = candidate;
94
+ partitions = Math.max(2, partitions - 1);
95
+ changed = true;
96
+ break;
97
+ }
98
+ }
99
+ if (changed)
100
+ continue;
101
+ if (width === 1)
102
+ break;
103
+ partitions = Math.min(current.length, partitions * 2);
104
+ }
105
+ return result(uncertain ? 'inconclusive' : 'reduced', uncertain ? 'Some probes were unknown or inconsistent' : 'Target failure confirmed; no single deletion retained it', uncertain ? 'not-established' : 'one-removal');
106
+ }
107
+ catch (error) {
108
+ if (!(error instanceof ExperimentStopped))
109
+ throw error;
110
+ return result('stopped', error.reason);
111
+ }
112
+ }
113
+ /** Consumes cases lazily and stops at the first explicit counterexample. */
114
+ export async function findCounterexample(cases, probe, budget) {
115
+ let checkedCases = 0, unknownCases = 0;
116
+ try {
117
+ for (const input of cases) {
118
+ const saved = structuredClone(input);
119
+ const verdict = await budget.check(probe, saved);
120
+ if (verdict.kind === 'fail')
121
+ return { status: 'counterexample', index: checkedCases, input: saved, verdict, stats: budget.stats() };
122
+ checkedCases++;
123
+ if (verdict.kind === 'unknown')
124
+ unknownCases++;
125
+ }
126
+ return { status: unknownCases || !checkedCases ? 'inconclusive' : 'checked', checkedCases, unknownCases,
127
+ reason: unknownCases ? 'Some cases were unknown' : checkedCases ? 'Only the supplied cases were checked' : 'No cases supplied', stats: budget.stats() };
128
+ }
129
+ catch (error) {
130
+ if (!(error instanceof ExperimentStopped))
131
+ throw error;
132
+ return { status: 'stopped', checkedCases, unknownCases, reason: error.reason, stats: budget.stats() };
133
+ }
134
+ }
135
+ /** Exceptions propagate; behavior-difference identifies any mismatch, not a specific fault. */
136
+ export function differential(reference, candidate, equal = isDeepStrictEqual) {
137
+ return async (input, signal) => {
138
+ const expected = structuredClone(await reference(structuredClone(input), signal));
139
+ signal?.throwIfAborted();
140
+ const actual = structuredClone(await candidate(structuredClone(input), signal));
141
+ const same = equal(expected, actual);
142
+ if (typeof same !== 'boolean')
143
+ throw new Error('Differential equality must return a boolean');
144
+ return same ? { kind: 'pass' } : { kind: 'fail', signature: 'behavior-difference', detail: { expected, actual } };
145
+ };
146
+ }
147
+ /** The caller supplies a contract-backed transform and relation, not a guessed oracle. */
148
+ export function metamorphic(contract, observe, transform, holds) {
149
+ if (typeof contract !== 'string' || !contract.trim())
150
+ throw new Error('A relation contract is required');
151
+ return async (input, signal) => {
152
+ const transformedInput = transform(structuredClone(input));
153
+ const original = structuredClone(await observe(structuredClone(input), signal));
154
+ signal?.throwIfAborted();
155
+ const transformed = structuredClone(await observe(structuredClone(transformedInput), signal));
156
+ const valid = holds(original, transformed);
157
+ if (typeof valid !== 'boolean')
158
+ throw new Error('Relation must return a boolean');
159
+ return valid ? { kind: 'pass' } : { kind: 'fail', signature: contract, detail: { transformedInput, original, transformed } };
160
+ };
161
+ }
162
+ /** Enumerate two ordered lanes, bounded before allocation; not a runtime scheduler. */
163
+ export function interleavings(leftLength, rightLength, maxSchedules) {
164
+ if (![leftLength, rightLength].every(n => Number.isSafeInteger(n) && n >= 0) || leftLength + rightLength > 256
165
+ || !Number.isSafeInteger(maxSchedules) || maxSchedules < 1)
166
+ throw new Error('Use nonnegative lane lengths totaling at most 256 and a positive maxSchedules');
167
+ const length = leftLength + rightLength;
168
+ let count = 1n;
169
+ for (let i = 1; i <= Math.min(leftLength, rightLength); i++) {
170
+ count = count * BigInt(length - i + 1) / BigInt(i);
171
+ if (count > BigInt(maxSchedules))
172
+ break;
173
+ }
174
+ const coverage = count > BigInt(maxSchedules) ? 'limited' : 'complete';
175
+ return {
176
+ coverage, count: Math.min(Number(count), maxSchedules),
177
+ *[Symbol.iterator]() {
178
+ // Lexicographic combinations of left-lane positions; O(sequence length) memory.
179
+ const positions = Array.from({ length: leftLength }, (_, index) => index);
180
+ for (let emitted = 0; emitted < maxSchedules; emitted++) {
181
+ let left = 0, right = 0;
182
+ yield Array.from({ length }, (_, position) => position === positions[left]
183
+ ? { lane: 0, index: left++ } : { lane: 1, index: right++ });
184
+ let index = positions.length - 1;
185
+ while (index >= 0 && positions[index] === length - positions.length + index)
186
+ index--;
187
+ if (index < 0)
188
+ return;
189
+ positions[index]++;
190
+ for (let next = index + 1; next < positions.length; next++)
191
+ positions[next] = positions[next - 1] + 1;
192
+ }
193
+ },
194
+ };
195
+ }
196
+ //# sourceMappingURL=experiments.js.map