mirror of
https://gitee.com/mateos/mateclaw.git
synced 2026-09-16 04:18:17 +08:00
Verify managed approval on MySQL and PostgreSQL
This commit is contained in:
parent
993be51e72
commit
4616e08e09
@ -18,7 +18,7 @@ Prefix: `/api/v1/goals/{goalId}/json-acceptance`. An enabled account with conver
|
||||
|
||||
Publication requires an active or paused goal and a slot referenced by a current requirement. Content must be a strict JSON object: duplicate keys, trailing documents, nesting beyond 32 levels and UTF-8 content over 1 MiB are rejected. Each goal can retain at most 32 versions; the limit rejects new publication instead of overwriting history. Each version expires after 24 hours. Republishing identical bytes still creates a new version. Reload after a generation conflict rather than automatically overwriting another publication. Retries can reuse a suitable current version and refresh its check binding; reaching the quota still permits checking and completing with that version. If the version is expired or its content must change and all 32 versions are used, further publication remains unavailable.
|
||||
|
||||
Managed bodies live independently in the database. Ordinary workspace files, cache paths and hashes in text are not substitutes. No publication API edits historical bodies; bodies and pointers commit together. SHA-256 identifies content and supports integrity checks; it does not isolate an attacker with database credentials or host privileges. The database and service host are trusted foundations of this limited protocol. The JSON service contract has been exercised on H2, MySQL 8.0.46 and PostgreSQL 16.14. The MySQL run isolated an existing V192 migration failure using a test-only migration copy; PostgreSQL used the original Kingbase migration tree while skipping an unrelated bundled-skill import failure. These are protocol tests, not confirmation that an unmodified full installation succeeds. The proprietary Kingbase engine has not been tested.
|
||||
Managed bodies live independently in the database. Ordinary workspace files, cache paths and hashes in text are not substitutes. No publication API edits historical bodies; bodies and pointers commit together. SHA-256 identifies content and supports integrity checks; it does not isolate an attacker with database credentials or host privileges. The database and service host are trusted foundations of this limited protocol. The JSON service contract has been exercised on H2, MySQL 8.0.46 and PostgreSQL 16.14. On the current source, MySQL and PostgreSQL each passed 72 JSON protocol cases and 9 opt-in HTTP approval/authentication cases. The MySQL run isolated an existing V192 migration failure using a test-only migration copy; PostgreSQL used the original Kingbase migration tree while skipping an unrelated bundled-skill import failure. These are protocol tests, not confirmation that an unmodified full installation succeeds. The proprietary Kingbase engine has not been tested.
|
||||
|
||||
## Agent publication
|
||||
|
||||
@ -53,7 +53,7 @@ The host clock, database credentials and service host remain trusted. Run arbitr
|
||||
|
||||
V198 also stores absolute scheduler lease deadlines. Existing leases expire during upgrade and are recovered from their persisted checkpoints: safe work may receive a new attempt; uncertain side effects remain blocked for review. Expired owners cannot renew, checkpoint, settle or use managed JSON tools. Renewal checks both current lease records after acquiring the goal lock, so a delayed scheduler tick cannot reuse an old timestamp to revive its owner. New valid owners can continue under the existing requirements. Recovery skips a scanned attempt while its continuation lease is still live or its owner has changed, so other eligible recoveries can proceed. A passing JSON binding does not override a pause caused by an uncertain tool outcome.
|
||||
|
||||
Validation snapshot (2026-09-15): the full default backend test run passed 5,359 executed tests with 44 conditional skips; the frontend passed 391 tests. The managed contract also has real compiled ReAct/Plan graph tests for account and scheduled-owner execution. Their model choices and semantic verdicts are controlled fixtures, not online-model benchmarks. Specialized integration profiles and the proprietary Kingbase engine are outside that full-default-suite claim.
|
||||
Validation snapshot (2026-09-15): the full default backend test run passed 5,359 executed tests with 46 conditional skips; the frontend passed 391 tests. The managed contract also has real compiled ReAct/Plan graph tests for account and scheduled-owner execution. Their model choices and semantic verdicts are controlled fixtures, not online-model benchmarks. Specialized integration profiles and the proprietary Kingbase engine are outside that full-default-suite claim.
|
||||
|
||||
Built-in shell/code execution is not OS-isolated from the service host. Selecting JSON acceptance does not sandbox those tools, and the protocol cannot defend against host code that can access database credentials or files. Environment-name filtering and workspace path checks do not replace that isolation. Lease deadlines are calculated from absolute instants, including daylight-saving clock rollback; scheduling display fields remain local timestamps.
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
|
||||
仅当前要求引用的槽可发布,Goal 必须 active 或 paused。正文必须是严格 JSON 对象,拒绝重复键、尾随文档、超过 32 层的嵌套及超过 1 MiB 的 UTF-8 内容。每个 Goal 最多保存 32 个版本;达到配额拒绝继续发布,不覆盖旧版本。每版有效期 24 小时,重复发布同样正文也产生新版本。客户端遇到 generation 冲突应重新读取,不自动覆盖他人发布。重试可以复用适用的当前版本并更新检查绑定;达到配额后仍可检查当前版本并在合格时完成。如果版本已过期或正文必须修改且32个版本均已使用,则不能继续发布。
|
||||
|
||||
这些版本独立存储在数据库,不能用普通工作区文件、缓存路径或文字中的 hash 替代。发布接口不支持更新历史正文;所有版本与槽指针同事务保存。SHA-256 用于标识及完整性核对,不能隔离拥有数据库凭据或宿主权限的攻击者;数据库和服务宿主是此有限协议的可信基础。JSON 服务契约已在 H2、MySQL 8.0.46 和 PostgreSQL 16.14 上实测。MySQL 使用仅修正既有 V192 失败的临时迁移副本;PostgreSQL 使用原始 Kingbase 迁移树,跳过无关的内置技能导入失败。这是协议验证,不能代表未修改的完整安装成功;尚未实测 Kingbase 专有引擎。
|
||||
这些版本独立存储在数据库,不能用普通工作区文件、缓存路径或文字中的 hash 替代。发布接口不支持更新历史正文;所有版本与槽指针同事务保存。SHA-256 用于标识及完整性核对,不能隔离拥有数据库凭据或宿主权限的攻击者;数据库和服务宿主是此有限协议的可信基础。JSON 服务契约已在 H2、MySQL 8.0.46 和 PostgreSQL 16.14 上实测。当前源码在MySQL与PostgreSQL上各通过72项JSON协议案例及9项显式启用的HTTP审批/认证案例。MySQL 使用仅修正既有 V192 失败的临时迁移副本;PostgreSQL 使用原始 Kingbase 迁移树,跳过无关的内置技能导入失败。这是协议验证,不能代表未修改的完整安装成功;尚未实测 Kingbase 专有引擎。
|
||||
|
||||
## 代理发布
|
||||
|
||||
@ -53,7 +53,7 @@ V197 使用 epoch 秒作为有效期依据,不受 JVM/JDBC 时区变化影响
|
||||
|
||||
V198 同样以绝对时间保存调度租约截止。升级时旧租约失效,按已有检查点恢复:安全工作可建立新 attempt,不确定副作用仍阻断并要求核实。过期 owner 不能续租、提交检查点、结算或使用受管 JSON 工具。续租在获得 Goal 锁后检查两侧当前租约,迟到调度 tick 不能利用旧时间戳复活 owner;新的有效 owner 可按现有要求继续。恢复扫描遇到 continuation 租约仍有效或 owner 已变化的记录时会跳过,继续处理其他可恢复目标。JSON 绑定通过也不能越过不确定工具结果导致的暂停。
|
||||
|
||||
验证快照(2026-09-15):默认后端完整测试集实际通过 5,359 项、条件跳过 44 项,前端通过 391 项。受管契约还覆盖真实编译的 ReAct/Plan 图及账户/调度 owner 四种组合;模型选择和语义评价是受控夹具,不是在线模型基准。专门集成 profile 与 Kingbase 专有引擎不包含在“默认完整测试集”结论中。
|
||||
验证快照(2026-09-15):默认后端完整测试集实际通过 5,359 项、条件跳过 46 项,前端通过 391 项。受管契约还覆盖真实编译的 ReAct/Plan 图及账户/调度 owner 四种组合;模型选择和语义评价是受控夹具,不是在线模型基准。专门集成 profile 与 Kingbase 专有引擎不包含在“默认完整测试集”结论中。
|
||||
|
||||
内置 shell/code 执行没有与服务宿主做操作系统隔离。选择 JSON 验收不会把这些工具变成沙箱;此协议不能抵抗能访问数据库凭据或文件的宿主代码,环境变量名称过滤和工作区路径检查也不能替代隔离。租约截止从绝对时刻计算,覆盖夏令时回拨;调度显示字段仍使用本地时间戳。
|
||||
|
||||
|
||||
@ -0,0 +1,54 @@
|
||||
package vip.mate.goal;
|
||||
|
||||
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
import org.springframework.test.context.DynamicPropertyRegistry;
|
||||
import org.springframework.test.context.DynamicPropertySource;
|
||||
|
||||
/** Opt-in real HTTP approval replay against a disposable MySQL or PostgreSQL database. */
|
||||
@EnabledIfSystemProperty(named = "mateclaw.json.external.enabled", matches = "true")
|
||||
class GoalJsonExternalApprovalIntegrationTest extends GoalJsonHttpRuntimeIntegrationTest {
|
||||
@org.springframework.boot.test.mock.mockito.MockBean
|
||||
private vip.mate.skill.workspace.SkillWorkspaceBootstrapRunner skillWorkspaceBootstrap;
|
||||
|
||||
@Override
|
||||
@ParameterizedTest
|
||||
@CsvSource({"false,approval,true", "true,approval,true",
|
||||
"false,terminal-approval,true", "true,terminal-approval,true",
|
||||
"false,legacy-terminal-approval,true", "true,legacy-terminal-approval,true",
|
||||
"false,originless-terminal-approval,true", "true,originless-terminal-approval,true"})
|
||||
void authenticatedGoalCompletesThroughHttpOrScheduledProductionRuntime(
|
||||
boolean plan, String entry, boolean accepted) throws Exception {
|
||||
super.authenticatedGoalCompletesThroughHttpOrScheduledProductionRuntime(plan, entry, accepted);
|
||||
}
|
||||
|
||||
@DynamicPropertySource
|
||||
static void externalDatabase(DynamicPropertyRegistry properties) {
|
||||
String url = required("url");
|
||||
String driver = required("driver");
|
||||
String username = required("username");
|
||||
String password = required("password");
|
||||
String dialect = required("dialect");
|
||||
if (!dialect.equals("mysql") && !dialect.equals("kingbase"))
|
||||
throw new IllegalArgumentException("External dialect must be mysql or kingbase");
|
||||
properties.add("spring.datasource.url", () -> url);
|
||||
properties.add("spring.datasource.driver-class-name", () -> driver);
|
||||
properties.add("spring.datasource.username", () -> username);
|
||||
properties.add("spring.datasource.password", () -> password);
|
||||
properties.add("spring.flyway.url", () -> url);
|
||||
properties.add("spring.flyway.user", () -> username);
|
||||
properties.add("spring.flyway.password", () -> password);
|
||||
properties.add("spring.flyway.locations", () -> System.getProperty(
|
||||
"mateclaw.json.external.migration-location", "classpath:db/migration/" + dialect));
|
||||
if (dialect.equals("mysql"))
|
||||
properties.add("spring.datasource.hikari.transaction-isolation", () -> "TRANSACTION_REPEATABLE_READ");
|
||||
}
|
||||
|
||||
private static String required(String name) {
|
||||
String value = System.getProperty("mateclaw.json.external." + name);
|
||||
if (value == null || value.isBlank())
|
||||
throw new IllegalArgumentException("Missing external database property: " + name);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user