Antigravity/黄伟栋#38
Open
victorHuang818 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
完成能力点
设计说明
核心架构
本项目采用 FastAPI 作为 Web 层,结合内置的 BackgroundTasks 提供了轻量级的异步任务处理。任务与数据持久化使用 SQLite 数据库,保持了单机环境的简单和确定性,避免引入复杂的外部数据库或消息队列。
工具调用边界
Executor使用resolve_template引擎递归地对步骤入参进行求值,支持将前序步骤的字典返回值(如$get_inventory.supplier_id)或复杂嵌套对象(如 RAG 引用$search_rules.citations)按需注入后续工具的入参中。redact_sensitive_data。敏感键如vendor_secret和unit_cost_usd均被剔除,包含的供应商价格特惠信息如ACME-TIER-2-REBATE会被自动脱敏为[REDACTED]。ToolRegistry.call对具有TransientIntegrationError特征的异常进行单步最多 3 次的主动重试,确保网络或接口瞬间抖动时,任务能自我恢复。RAG 策略
permission字段。检索接口接收用户当前的permissions列表,如果文档所声明的权限不在用户列表中,该文档将被过滤并加入filtered_doc_ids,绝不在检索中暴露其标题或正文。tokenize和基于词频的余弦相似度函数cosine_score对可见分块进行多角度相似度打分并降序排列,取相关性最高且打分大于0.0的 top k 个 Chunks 产生 RAG 引用(Citations)。FakeLLM对生成的提示词(Citations & Query)产生确定性 Hash 答复。因为答复来源于 Hash,且响应字段排除了debug和candidate_note,确保不回传用户恶意 prompt 中所含的指令,防止命令注入与越权。权限设计
本系统秉持最小特权原则,在两层防御路径上严格把关:
decision="deny"的task.create审计日志,随后返回403 Forbidden。oa:approval:write)。若缺失直接在 HTTP 阶段拦截并生成run.createdecision="deny"审计日志。在 Executor 真实运行 OA 写草稿等敏感工具前,进行动态二次校验拦截。一旦缺失即触发decision="deny"的approval.draft.create审计日志,并以tool.skipped事件类型在运行轨迹中体现,确保敏感操作物理阻断。/api/runs/{run_id}及events接口仅限请求人、任务创建人或管理员(admin:read)读取,他人读取会记录deny审计,保障多租户可见性物理隔离。本地验证
pytest 执行结果
self_check (Makefile 关联 score.py 的自检) 运行结果
已知风险或未完成项
大并发下的内存状态一致性风险: 当前
InMemoryRunStateStore使用进程内字典实现。若未来将 BackgroundTasks 迁移到独立的分布式 Celery Worker 进程中,则需要在 SQLite 或 Redis 中实现 RunStateStore 的持久化版本以保持数据同步。。LLM 规划偏离边界: 依靠
re.search正则提取 SKU 虽能满足当前及变种 SKU 输入,但在面对非结构化或高度含糊的 Prompt 时,依然可能产生意图规划偏离。在真实生产环境需要引入真正的 Few-shot LLM 规划与参数解析组件,来提升 Planner 的意图对齐与召回率。