feat(finance): build simulated approval requests - #4357
Conversation
1ef89ad to
f65f600
Compare
huangruiteng
left a comment
There was a problem hiding this comment.
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
Exact head reviewed: f65f60020adc5cbc3100e890384e056016c239c8
动机
主干已经具备通用 operation card、Dashboard operation_review_frame_v0、Lark 回调/恢复以及本地模拟执行器,但 Finance 仍缺少一个受约束的生产者来把投研候选转换为规范 loopx_operation_request_v0。关闭本 PR 会迫使赚钱 Agent 手工拼装权限、经济性、证据、过期与 no-trade 字段;原 PR 直接堆叠旧卡片实现又会制造第二套真相源。本次因此保留 Finance producer,删除已被主干吸收的堆叠历史。
改动思路
Finance 扩展只负责金融语义验证与请求构建:要求模拟模式、受支持订单类型、正数价格/数量/费用、成本覆盖、可公开引用的证据、已观测时间、未来到期时间和 no-trade 条件;随后复用 Core 的 canonical operation envelope、权限与幂等契约。卡片展示、确认回调、恢复、Todo/receipt 与 executor effects 继续由现有 Core/Dashboard/Lark 链路拥有。
具体改动
- 将原 57 文件堆叠差异收敛为 7 个 Finance 包文件,不修改 Core、Dashboard 或 Lark 实现。
- 新增
finance.transaction_approval_input_v0构建器及 managed source/direct CLI 两条等价入口。 - 将包版本提升为
0.7.0,补齐双语 README、入口点及 manifest。 - 加入
evidence_observed_atUTC 规范化与未来时间拒绝;拒绝私网/本机/带凭据查询参数的证据 URL。 - 固定集成测试时钟,避免原测试只在作者当天有效;验证 canonical request 可被现有真实 TypeScript review frame 和模拟执行器消费。
关键代码讲解
build_finance_transaction_approval_packet 是唯一领域 reducer:它不发送 Lark、不创建第二份状态,也不授予真实交易权限。它输出 finance.order.simulate、simulation=true 和 Core 所需 principals/executor revision;调用者只能传入来自当前 Goal Channel operator authority 的 provider-qualified principals,Core 在 preflight/callback 时继续复核。CLI 的 managed source path 与 direct command 共用同一函数,避免 Turn 与手工调用产生不同语义。
对主干的风险
风险可控且默认隔离:新增能力位于可选 Finance provider,主干通用 reducer 的基线夹具在 base/head 上字节一致;无网络写入、无券商调用、无真实下单能力。主要剩余风险是调用者错误提供 principal/executor revision provenance,README 已明确约束,Core 仍会二次校验。此次 exact head 未重新发送真实 Lark 卡片,因为传输与回调代码没有变化;同一 canonical frame 的集成测试已覆盖。
我的整体评价
本 PR 经重构后仍有明确且不可由主干现有卡片能力替代的价值:它补的是 Finance producer,而不是 UI 或消息队列。范围已经与管家 RFC、投研目标和三层 capability 分工对齐,验证充分,无阻断发现,建议合并。
English verdict: APPROVE. The rebased change keeps only the Finance-owned, simulation-only producer for canonical operation requests and reuses the existing Core/Dashboard/Lark approval lifecycle. The obsolete stacked card history is removed; authority remains with the Goal Channel/Core, and no live trading effect is introduced.
Validation: 231 focused extension/Core/Lark tests passed; package/license tests passed; Ruff and git diff --check passed; the standard premerge canary ran 17 checks with zero failures/warnings; wheel build succeeded; structured loopx pr-review --check-result returned APPROVE with no blockers.
Signed-off-by: huangruiteng <14976749+huangruiteng@users.noreply.github.com>
f65f600 to
4e346e3
Compare
huangruiteng
left a comment
There was a problem hiding this comment.
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
Exact head reviewed: 4e346e30c2ed49890d490b4511460befe1e3aa6b
动机
主干已经具备通用 operation card、Dashboard operation_review_frame_v0、Lark 回调/恢复以及本地模拟执行器,但 Finance 仍缺少一个受约束的生产者来把投研候选转换为规范 loopx_operation_request_v0。关闭本 PR 会迫使赚钱 Agent 手工拼装权限、经济性、证据、过期与 no-trade 字段;原 PR 直接堆叠旧卡片实现又会制造第二套真相源。本次因此保留 Finance producer,删除已被主干吸收的堆叠历史。
改动思路
Finance 扩展只负责金融语义验证与请求构建:要求模拟模式、受支持订单类型、正数价格/数量/费用、成本覆盖、可公开引用的证据、已观测时间、未来到期时间和 no-trade 条件;随后复用 Core 的 canonical operation envelope、权限与幂等契约。卡片展示、确认回调、恢复、Todo/receipt 与 executor effects 继续由现有 Core/Dashboard/Lark 链路拥有。
具体改动
- 将原 57 文件堆叠差异收敛为 7 个 Finance 包文件,不修改 Core、Dashboard 或 Lark 实现。
- 新增
finance.transaction_approval_input_v0构建器及 managed source/direct CLI 两条等价入口。 - 将包版本提升为
0.7.0,补齐双语 README、入口点及 manifest。 - 加入
evidence_observed_atUTC 规范化与未来时间拒绝;拒绝私网/本机/带凭据查询参数的证据 URL。 - 固定集成测试时钟,避免原测试只在作者当天有效;验证 canonical request 可被现有真实 TypeScript review frame 和模拟执行器消费。
关键代码讲解
build_finance_transaction_approval_packet 是唯一领域 reducer:它不发送 Lark、不创建第二份状态,也不授予真实交易权限。它输出 finance.order.simulate、simulation=true 和 Core 所需 principals/executor revision;调用者只能传入来自当前 Goal Channel operator authority 的 provider-qualified principals,Core 在 preflight/callback 时继续复核。CLI 的 managed source path 与 direct command 共用同一函数,避免 Turn 与手工调用产生不同语义。
对主干的风险
风险可控且默认隔离:新增能力位于可选 Finance provider,主干通用 reducer 的基线夹具在 base/head 上字节一致;无网络写入、无券商调用、无真实下单能力。主要剩余风险是调用者错误提供 principal/executor revision provenance,README 已明确约束,Core 仍会二次校验。此次 exact head 未重新发送真实 Lark 卡片,因为传输与回调代码没有变化;同一 canonical frame 的集成测试已覆盖。
我的整体评价
本 PR 已重放到包含 #4404 门禁修复的最新主干;经重构后仍有明确且不可由主干现有卡片能力替代的价值:它补的是 Finance producer,而不是 UI 或消息队列。范围已经与管家 RFC、投研目标和三层 capability 分工对齐,验证充分,无阻断发现,建议合并。
English verdict: APPROVE. The rebased change keeps only the Finance-owned, simulation-only producer for canonical operation requests and reuses the existing Core/Dashboard/Lark approval lifecycle. The obsolete stacked card history is removed; authority remains with the Goal Channel/Core, and no live trading effect is introduced.
Validation: 231 focused extension/Core/Lark tests passed; package/license tests passed; Ruff and git diff --check passed; the standard premerge canary ran 13 checks with zero failures/warnings; wheel build succeeded; structured loopx pr-review --check-result returned APPROVE with no blockers.
Motivation / 动机
The merged Goal Channel operation-card lifecycle and simulation executor own generic confirmation, callback, claim, recovery, and result readback. Finance still lacked a domain-owned producer that turns one already-bounded candidate action into the canonical
loopx_operation_request_v0. Without this seam, a research caller must hand-assemble order, evidence, economics, expiry, no-trade conditions, executor binding, and approval projection.已合并的 Goal Channel 操作卡与模拟 executor 已负责通用确认、callback、claim、恢复和结果读回;Finance 仍缺少领域 producer,把一个已经收敛的候选动作转换成 canonical
loopx_operation_request_v0。没有该边界,研究调用方仍需手拼订单、证据、经济性、过期时间、禁交易条件、executor binding 和审批投影。Scope decision / 范围决策
This PR was rebuilt on current
main. The obsolete #4275 stack was removed: the diff is now seven Finance package/test files rather than 57 duplicated Core, Dashboard, Lark, and generated-asset files. Core card authority is reused, not copied.本 PR 已基于当前
main重建并删除过期的 #4275 叠加历史:差异从 57 个重复的 Core、Dashboard、Lark 与生成资源文件,收敛为 7 个 Finance package/test 文件;不复制 Core 卡片权威。Changes / 改动
finance_transaction_approval_input_v0→finance_transaction_approval_packet_v0reduction.goal-channel prepare-operation.account:simulation,finance.order.simulate,finance.operation.simulate, limit orders, positive bounded economics, expiry, and explicit provider-qualified principals.build-operation-requestCLI output.中文:新增确定性的 Finance 审批 packet reducer,输出 Core 已支持的 operation request;固定为仅模拟账户、operation 与权限,要求显式审批主体、正向净经济性、过期时间和禁交易条件;在卡片中冻结证据观察时间,拒绝未来证据、私有地址和疑似凭证查询参数;保留 0.6.0 的 source-period/spot evidence,并以 0.7.0 发布新增 producer。
RFC and product entry points / RFC 与产品入口
operation_review_frame_v0consumes this canonical projection; the integration test reaches that TypeScript frame through the real Lark card builder.中文:Finance 只拥有金融语义;Core 继续独占 proposal/确认/claim/outcome,Lark 只负责认证 transport。CLI 与 managed Turn 同源输出;Dashboard 复用既有 TypeScript review frame;Lark 复用既有卡片和 callback;确认只可运行无外部效果的模拟 executor,不授权真实下单、签名、转账或持续交易权限。
Validation / 验证
231 passed: alltest_finance_*.py,test_chat_operation_actions.py, andtest_lark_goal_channel_operation.py.7 passed.git diff --check: passed.loopx_finance_value_discovery-0.7.0-py3-none-any.whlbuilt successfully.Risk / 风险
The remaining coupling is intentional: callers must supply the executor revision from enabled-extension readback and principals from current Goal Channel operator authority. Core revalidates both at preparation/callback/dispatch boundaries. The producer does not infer candidate truth or trading readiness; upstream research remains responsible for evidence quality and admission.
剩余耦合是有意保留的:调用方必须从已启用 extension 的读回取得 executor revision,并从当前 Goal Channel 操作权限取得审批主体;Core 在准备、callback 与 dispatch 边界重新校验。Producer 不推断候选真实性或交易准入,上游研究仍对证据质量和准入负责。