refactor: simplify ExtractFn to (schema, contentHash) → meta #180

Closed
opened 2026-05-11 07:45:44 +00:00 by xiaoju · 1 comment
Owner

What

Simplify ExtractFn signature from (schema, prompt, ExtractContext) to (schema, contentHash).

Why

Current extract takes the full ThreadContext + a per-role extractPrompt. This is wrong:

  • extractPrompt is redundant (covered by #174)
  • ThreadContext is unnecessary — extractor only needs the CAS content node
  • workflow-as-agent case forced extractPrompt to do DAG traversal business logic

New Design

type ExtractFn = <T>(schema: ZodType<T>, contentHash: string) => Promise<ExtractResult<T>>;
function createExtract(cas: CasStore): ExtractFn;

Behavior:

  1. Read content node from CAS by hash
  2. Try to extract meta matching schema from the node's payload
  3. If info insufficient, ReAct via cas_get to traverse child refs
  4. Return structured meta

Schema as first param for partial application friendliness.

Changes

  1. workflow-protocol — update ExtractFn type, remove ExtractContext
  2. workflow-execute/extract — rewrite createExtract, remove buildExtractUserContent
  3. workflow-runtime/create-workflow — call extract(schema, contentHash) instead of extract(schema, prompt, ctx)
  4. workflow-template-solve-issue/developer.ts — remove DEVELOPER_EXTRACT_PROMPT, workflow-as-agent should output readable content
  5. workflow-execute/workflow-as-agent — output readable summary instead of raw root hash

Subsumes #174 (extractPrompt removal).

— 小橘 🍊(NEKO Team)

## What Simplify `ExtractFn` signature from `(schema, prompt, ExtractContext)` to `(schema, contentHash)`. ## Why Current extract takes the full ThreadContext + a per-role extractPrompt. This is wrong: - extractPrompt is redundant (covered by #174) - ThreadContext is unnecessary — extractor only needs the CAS content node - workflow-as-agent case forced extractPrompt to do DAG traversal business logic ## New Design ```typescript type ExtractFn = <T>(schema: ZodType<T>, contentHash: string) => Promise<ExtractResult<T>>; function createExtract(cas: CasStore): ExtractFn; ``` Behavior: 1. Read content node from CAS by hash 2. Try to extract meta matching schema from the node's payload 3. If info insufficient, ReAct via cas_get to traverse child refs 4. Return structured meta Schema as first param for partial application friendliness. ## Changes 1. `workflow-protocol` — update ExtractFn type, remove ExtractContext 2. `workflow-execute/extract` — rewrite createExtract, remove buildExtractUserContent 3. `workflow-runtime/create-workflow` — call extract(schema, contentHash) instead of extract(schema, prompt, ctx) 4. `workflow-template-solve-issue/developer.ts` — remove DEVELOPER_EXTRACT_PROMPT, workflow-as-agent should output readable content 5. `workflow-execute/workflow-as-agent` — output readable summary instead of raw root hash Subsumes #174 (extractPrompt removal). — 小橘 🍊(NEKO Team)
Author
Owner

Phase 拆分

Phase 1: ExtractFn 签名简化 + 类型清理

  • ExtractFn → (schema, contentHash) → ExtractResult
  • createExtract 只注入 CasStore
  • 删除 ExtractContext、extractPrompt、buildExtractUserContent
  • create-workflow.ts 先 putContentNode 再调 extract(schema, hash)
  • Testing issue: Phase 1 Testing: ExtractFn 签名简化 (#180) (#181)

Phase 2: workflow-as-agent 输出可读 content

— 小橘 🍊(NEKO Team)

## Phase 拆分 ### Phase 1: ExtractFn 签名简化 + 类型清理 - ExtractFn → `(schema, contentHash) → ExtractResult` - createExtract 只注入 CasStore - 删除 ExtractContext、extractPrompt、buildExtractUserContent - create-workflow.ts 先 putContentNode 再调 extract(schema, hash) - Testing issue: #181 ### Phase 2: workflow-as-agent 输出可读 content - workflow-as-agent 完成时从 child thread 结果组装可读 summary - developer.ts 删除 DEVELOPER_EXTRACT_PROMPT - 验证 solve-issue 模板端到端正常 - Testing issue: #182 — 小橘 🍊(NEKO Team)
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#180