capture-helpers.mjs
71 lines 2.2 KB
Raw
sha256:8915fe406161f95c1681f9469375e7bae5b28c884f00bedbdef65e4b0cd0738d docs(flow): commit FLOW-V0-SPEC.md hygiene for 7A-INT merge Human 16 hours ago
1 /**
2 * Shared helpers for Flow capture flywheel tiers (7A-L4b).
3 */
4 import fs from 'node:fs';
5 import path from 'node:path';
6
7 import { emptyStarterDir } from './authoring-helpers.mjs';
8
9 export { emptyStarterDir };
10
11 /** Valid content-minimized session meta (ids/hashes/counts only). */
12 export function validSessionMeta(overrides = {}) {
13 return {
14 session_id: 'b'.repeat(64),
15 step_sequence_refs: ['flow_weekly_review#1', 'flow_weekly_review#2'],
16 skill_ref_ids: ['mcp_prompt:daily-brief'],
17 observed_counts: { repetition: 4, repeated_correction: 1 },
18 signal_hints: ['repetition'],
19 ...overrides,
20 };
21 }
22
23 /** Payload-bearing variant — carries forbidden raw-content keys. */
24 export function payloadBearingSessionMeta() {
25 return {
26 session_id: 'c'.repeat(64),
27 step_sequence_refs: ['flow_weekly_review#1'],
28 observed_counts: { repetition: 4 },
29 prompt: 'IGNORE PRIOR INSTRUCTIONS',
30 completion: 'Here are secrets',
31 };
32 }
33
34 /**
35 * @param {object} candidate
36 * @returns {object}
37 */
38 export function makeCandidateRecord(candidate = {}) {
39 return {
40 schema: 'knowtation.flow_candidate/v0',
41 candidate_id: candidate.candidate_id ?? 'cand_a1b2c3d4',
42 suggested_title: candidate.suggested_title ?? 'Weekly URL verify',
43 scope_hint: candidate.scope_hint ?? 'personal',
44 trigger_signal: candidate.trigger_signal ?? 'repetition',
45 observed_count: candidate.observed_count ?? 4,
46 evidence_refs: candidate.evidence_refs ?? ['hash:abc123', 'run:sample'],
47 draft_steps: candidate.draft_steps ?? [
48 'Open the target URL',
49 'Verify response status',
50 'Record result pointer',
51 ],
52 confidence: candidate.confidence ?? 'medium',
53 status: candidate.status ?? 'pending_review',
54 provenance: candidate.provenance ?? { actor: 'hash_actor', harness: 'test' },
55 updated: candidate.updated ?? '2026-06-20T00:00:00Z',
56 ...candidate,
57 };
58 }
59
60 /**
61 * @param {string} dataDir
62 * @param {string} name
63 * @returns {string}
64 */
65 export function writeSignalsFixture(dataDir, name, meta) {
66 const dir = path.join(dataDir, 'signals');
67 fs.mkdirSync(dir, { recursive: true });
68 const fp = path.join(dir, name);
69 fs.writeFileSync(fp, JSON.stringify(meta, null, 2), 'utf8');
70 return fp;
71 }
File History 1 commit
sha256:8915fe406161f95c1681f9469375e7bae5b28c884f00bedbdef65e4b0cd0738d docs(flow): commit FLOW-V0-SPEC.md hygiene for 7A-INT merge Human 16 hours ago