ctx_runner 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +7 -1
- data/docs/contracts-2026-10-29.md +86 -0
- data/docs/contracts-2026-10-30.md +58 -0
- data/docs/module-boundaries.md +12 -10
- data/docs/verification-2026-10-29.md +76 -0
- data/examples/execution.rb +1 -1
- data/examples/report.rb +1 -1
- data/lib/ctx_runner/batch.rb +23 -6
- data/lib/ctx_runner/collection.rb +1 -0
- data/lib/ctx_runner/configuration_session.rb +43 -0
- data/lib/ctx_runner/document.rb +5 -3
- data/lib/ctx_runner/evidence.rb +72 -9
- data/lib/ctx_runner/execution.rb +6 -3
- data/lib/ctx_runner/fingerprint.rb +1 -1
- data/lib/ctx_runner/observation.rb +24 -6
- data/lib/ctx_runner/query.rb +2 -1
- data/lib/ctx_runner/report.rb +5 -4
- data/lib/ctx_runner/snapshot.rb +67 -0
- data/lib/ctx_runner/target.rb +40 -0
- data/lib/ctx_runner/version.rb +1 -1
- data/lib/ctx_runner.rb +2 -0
- metadata +15 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 309468f8b97d51e31739cf478abc3af96885ba53453366837c1b7dba56518a9f
|
|
4
|
+
data.tar.gz: 80edf1ff1d91b7de2f5cd3618346e55d1761f4c5a3940ecd2bb4eaa5af8287f6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 72f558b4857909003298d7593574a2c913face19002e9afd980a832fc69572e3a88fa603358b9ac434a019267dc022ae93a9cc89b8736fbe68fbd964757bf048
|
|
7
|
+
data.tar.gz: 762d6e943fc55eeba9f4989098bb23804233590d3f743445782506330146d02f689b1be8b0cb0ada2ba235b5c632a4d9051a24e174f1e6c6b89dfba146a4a223
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.5.0 (2026-10-30)
|
|
6
|
+
|
|
7
|
+
- Adopt immutable `Target` identity values and typed observation sources; share `records(name)` and configuration session behavior. Schema 4 uses `target`, validates aggregate status and full identity, and rejects empty applicability proof. Reject duplicate/unrequested batch work and mismatched returned snapshots. Align fingerprint depth with Document.
|
|
8
|
+
|
|
9
|
+
## 0.4.0 (2026-10-29)
|
|
10
|
+
|
|
11
|
+
- Add composed Snapshot and public Target contracts, independent collection status, and typed UTC times. Empty requests remain not_requested.
|
|
12
|
+
- Share observation scopes and acquisition times, requiring evidence for not_applicable. Preserve unfinished callback failures when cleanup also fails.
|
|
13
|
+
- Version collection, batch, change plan, review and execution documents with schema 3 and explicit kinds; reject older reports and plans.
|
|
14
|
+
|
|
5
15
|
## 0.3.0 (2026-10-29)
|
|
6
16
|
|
|
7
17
|
- Remove `Collection.new(strict:)`: provider contract failures consistently return structured diagnostics without replay and preserve the first failure. Batch consumers now expose `snapshot.observations`.
|
data/README.md
CHANGED
|
@@ -38,7 +38,7 @@ end
|
|
|
38
38
|
|
|
39
39
|
领域 Profile 实现 `parse_many(names, body, complete:, command:)`;不可用投影接收 `(name, capture, failure)`。一次 Query 对应一条命令,多个视图共享同一份 Capture。
|
|
40
40
|
|
|
41
|
-
`Collection.new` 统一记录 session_not_opened/session_reentered,保留首次失败且不重放;strict: 参数已移除。批次快照统一提供 observations Ruby
|
|
41
|
+
`Collection.new` 统一记录 session_not_opened/session_reentered,保留首次失败且不重放;strict: 参数已移除。批次快照统一提供 observations Ruby 成员,文档统一使用 observations,采集结论独立为 collection_status,不再生成 :collection 伪观测。交付块未正常完成但异常被连接器吞掉时记录 session_incomplete;跨线程交付记录 session_out_of_scope,并拒绝执行领域块。连接关闭错误不会覆盖已完成的领域事实或先前交付故障。借用会话直接使用 Reader/Query,无需再进入 Collection。
|
|
42
42
|
|
|
43
43
|
Collection 与 Execution 共用 `SessionScope`。会话必须由创建流程的线程同步交付;并行调度应在每个设备任务内部创建流程。重复交付的异常即使被提供方吞掉,流程仍不能报告完成;所有者退出后保留的回调立即失效。作用域不持有或关闭会话,连接清理仍由连接器负责。跨模块职责、业务原子边界与领域拆分见 [模块设计](docs/module-boundaries.md)。
|
|
44
44
|
|
|
@@ -68,3 +68,9 @@ ruby script/verify_package.rb pkg/ctx_runner-0.1.0.gem
|
|
|
68
68
|
默认 rake 运行 RSpec、RuboCop 和离线示例。CI 沿用 ctx_parser 的 Ruby 4.0.6 / Linux、macOS 矩阵和固定 action 提交。源码联调在消费仓库显式设置 `CTX_RUNNER_PATH=../ctx_runner`;普通验证使用已安装依赖。首次发版前须先构建安装 runner 候选包再验证消费包。
|
|
69
69
|
|
|
70
70
|
首个版本为 0.1.0。发布流程复用 CI 制品,验证 GitHub Release 与 RubyGems 下载字节。
|
|
71
|
+
|
|
72
|
+
模块契约、破坏性迁移与版本矩阵见 [契约迁移](docs/contracts-2026-10-29.md)。
|
|
73
|
+
|
|
74
|
+
## Domain contract migration (2026-10-30)
|
|
75
|
+
|
|
76
|
+
Adopt immutable `Target` identity values and typed observation sources; share `records(name)` and configuration session behavior. Schema 4 uses `target`, validates aggregate status and full identity, and rejects empty applicability proof. Reject duplicate/unrequested batch work and mismatched returned snapshots. Align fingerprint depth with Document. See the [schema 4 migration and module contracts](https://github.com/gatework/ctx_runner/blob/main/docs/contracts-2026-10-30.md). Regenerate old collection reports and change plans; changing only their version number is not supported.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# 九模块契约与迁移
|
|
2
|
+
|
|
3
|
+
> Historical schema 3 review. Current contracts and migration: [2026-10-30](contracts-2026-10-30.md).
|
|
4
|
+
|
|
5
|
+
此次改动以实际调用链和既有故障测试为依据。保持九个 gem,不新增公共工具 gem;厂商语法、AP 租约、Fabric 范围及健康规则仍由对应领域维护。
|
|
6
|
+
|
|
7
|
+
## 质量审查结论
|
|
8
|
+
|
|
9
|
+
| 模块 | 主要结论 | 本次处理 |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| expect-pty(仓库 expect-ruby) | IO/PID 所有权、超时、脱敏和回收已有独立边界 | 保留实现,验证 PTY、资源关闭和独立安装 |
|
|
12
|
+
| net-connector | 已有独占会话与 Credentials;消费端 apply 重复凭据逻辑;归档投递可能漏检同一时钟粒度内的源文件覆写 | 复用 Credentials,限定依赖区间;投递后在原描述符上再次核对大小与摘要 |
|
|
13
|
+
| ctx_parser | ScopedResult 在消费端另行定义值语义;命令校验散落多处 | Result 正式包含 covered_scopes;统一 command_text 和严格时刻解析 |
|
|
14
|
+
| ctx_driver | 借用会话、单命令回执边界清晰 | 使用公共命令校验,保留失同步后停止和不重连契约 |
|
|
15
|
+
| ctx_runner | 三个领域的快照聚合与 Batch 不一致;关闭失败可能遮盖被吞掉的回调失败 | 公共 Snapshot/Target,独立 collection_status,保留最初失败 |
|
|
16
|
+
| ctx_cli | 两套 apply 重复校验和、确认、错误处理和执行编排 | 注入领域 adapter 与执行器的 Apply;无 Runner/连接器依赖 |
|
|
17
|
+
| ctx_checker | 严格领域校验有价值,但公共值与时间接口分叉 | 组合公共 Observation/Snapshot,保留身份、字段和覆盖校验 |
|
|
18
|
+
| VXLAN | OSPF 字段与 Checker 同义不同名;快照接收任意身份字段 | 统一公共字段和快照;保留 Fabric/ACL/ChangePlan |
|
|
19
|
+
| Wireless | 未知维度与已知不支持维度混淆;计划缺少统一选择和校验和 | 未知维度报错,已知不支持保留 unsupported;并发收集后稳定汇总具名计划 |
|
|
20
|
+
|
|
21
|
+
完整采集、语法覆盖、领域健康、设备变更效果和报告持久性是不同事实。此次统一接口不把它们合并成单一 success。
|
|
22
|
+
|
|
23
|
+
## 对象契约
|
|
24
|
+
|
|
25
|
+
- `CtxParser::Result` 是深度不可变的 Data 值:`status, records, issues, covered_scopes`。默认 scopes 为 `[]`,参与 `==`、`eql?`、`hash`、`with`、模式匹配和 `to_h`;不再使用 ScopedResult。
|
|
26
|
+
- `CtxParser::Commands.command_text(value)` 接受非空、无控制字符的单行 String,返回独立冻结文本。Profile、Driver、Query 和 Execution 共用该边界。
|
|
27
|
+
- `CtxParser::Values.timestamp(value)` 接受含明确时区的 ISO8601 文本,拒绝日期、时分秒和时区越界,返回 UTC Time。
|
|
28
|
+
- `Observation` 的公共字段为 `name, status, records, issues, evidence, started_at, completed_at, covered_scopes`。采集时间为 Time 或 nil;`observed_at` 从来源 evidence 的时刻得出,不能用报告时间替代。
|
|
29
|
+
- Checker 组合公共 Observation,再约束领域字段、记录身份和 scope;VXLAN/Wireless 保留公开 Observation 类型。不会冻结调用方对象。
|
|
30
|
+
- `Snapshot` 提供 `target, observations, observed_at, issues, collection_status, observation(name), complete?, same_target?, to_h`。领域通过组合声明允许的维度;未知维度或键值名称不一致立即报错。
|
|
31
|
+
- `target` 只允许 `host, platform, name, model, software_version, id`;String/Symbol 键归一为 Symbol,拒绝重复、未知字段和控制字符。host 必须有值;id 可为文本或非负整数。密码、连接选项及任意属性不可进入身份。
|
|
32
|
+
- Snapshot 的 `observed_at` 必须是 Time。Ruby `to_h` 保留类型;JSON 必须经 `CtxRunner::Document.call`,统一为 UTC ISO8601(六位小数)。
|
|
33
|
+
|
|
34
|
+
Observation 状态包括 complete、partial、failed、unsupported、not_requested、not_applicable。不可用状态不能带 records;not_applicable 必须携带来源证据。
|
|
35
|
+
|
|
36
|
+
| 所请求的观测 | collection_status |
|
|
37
|
+
| --- | --- |
|
|
38
|
+
| 无请求或全部 not_requested,且无采集错误 | not_requested |
|
|
39
|
+
| 有请求,但既无可用事实,也无有证据的不适用结论 | failed |
|
|
40
|
+
| 全部 complete 或有证据的 not_applicable,且无采集错误 | complete |
|
|
41
|
+
| 部分事实、部分失败或已取得事实后关闭失败 | partial |
|
|
42
|
+
|
|
43
|
+
不再创建 `observations[:collection]`。Batch 从 `snapshot.collection_status` 取结论;`snapshot.issues` 保存会话层诊断。Batch 摘要的 `dimensions` 是按维度计数的摘要,并非 Snapshot 字段别名。
|
|
44
|
+
|
|
45
|
+
VXLAN OSPF 使用 `process_id, vrf, router_id, neighbor_address, interface, state, neighbor_role`;state 为 Symbol(如 `:full`、`:two_way`),角色独立为 `:dr/:bdr/:drother/:unknown`。原有 priority 和 uptime 继续保留。厂商命令文件名与解析入口不变。
|
|
46
|
+
|
|
47
|
+
## 文件格式与 apply
|
|
48
|
+
|
|
49
|
+
两个领域 CLI 的新报告/计划使用 `schema_version: 3` 和明确的 `kind`:collection、batch、recommendations、review、fabric_review、change_plan、change、execution。离线 review/apply 拒绝旧版本;请重新采集、重新生成计划,不用字段猜测或手工只改版本号。
|
|
50
|
+
|
|
51
|
+
collection 的 snapshot 使用 `observations` 和独立 `collection_status`。读取端同时核对身份、维度、时间、状态及聚合结论,领域记录交由领域 adapter 验证。
|
|
52
|
+
|
|
53
|
+
两个领域都输出 `plan.json`,结构为 `kind: change_plan, platform, changes: { ID => change }`。每项 change 绑定设备、完整配置指纹、类型化增量及重新生成的 commands/rollback;相邻的 `plan.json.sha256` 绑定文件内容。checksum 只检测内容变化,不是签名或授权。
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
vxlan apply --plan plan.json --item CHANGE_ID
|
|
57
|
+
wireless apply --plan plan.json --item CHANGE_ID
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
必须显式选一项;终端确认绑定 host、计划摘要和 item。确认后经 Credentials 解析平台优先/通用回退凭据,再创建执行日志、回读前置配置、逐条记账和回读验收。失败后不重放、不自动回退、不保存 startup 配置。执行成功仍需要业务验收。
|
|
61
|
+
|
|
62
|
+
`CtxCli::Apply` 的 adapter 提供 `select_plan(document, item:)`、`validate_plan(plan)`、`credentials(options)`、`report(options)`、`with_session(device, settings)`。注入的 execution 实现 `run`、`started?`、`journal_failed?`。CLI 不解释厂商命令或业务健康。
|
|
63
|
+
|
|
64
|
+
## 版本及验证入口
|
|
65
|
+
|
|
66
|
+
| gem | 候选版本 | Ruby 下限 |
|
|
67
|
+
| --- | --- | --- |
|
|
68
|
+
| expect-pty | 0.9.6(实现未改) | 3.4 |
|
|
69
|
+
| net-connector | 0.20.0 | 3.4 |
|
|
70
|
+
| ctx_cli | 0.4.0 | 3.4 |
|
|
71
|
+
| ctx_parser / ctx_driver / ctx_runner | 0.4.0 | 4.0.6 |
|
|
72
|
+
| ctx_checker | 0.5.0 | 4.0.6 |
|
|
73
|
+
| vxlan | 0.7.0 | 4.0.6 |
|
|
74
|
+
| wireless-rb | 0.8.0 | 4.0.6 |
|
|
75
|
+
|
|
76
|
+
依赖按支持的下一个 minor 设上界。使用 RVM 安装和选择运行时,例如 `rvm install ruby-4.0.6`、`rvm use ruby-4.0.6`;3.4 库另用 3.4 分支验证。
|
|
77
|
+
|
|
78
|
+
每个仓库先运行自己的 Bundler 检查;跨仓库源码联调与普通安装分别验证。工作区目录名须与下列脚本声明一致:
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
ruby ctx_runner/script/verify_stack.rb /absolute/workspace /absolute/artifacts
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
脚本构建九个候选,校验全部依赖边,将运行依赖缓存和候选装进临时 GEM_HOME,禁止源码路径进入消费环境,执行三个领域的 Batch/schema 往返、离线示例、普通 CLI 和真实 PTY,再通过最小 Bundler 消费方重复验证。manifest.json 记录源提交、候选版本与 SHA256。未提交改动以候选包摘要确定内容,不将基线提交冒充最终源码提交。
|
|
85
|
+
|
|
86
|
+
单机离线测试不等于 macOS 或网络设备型号验证;未实际运行的环境不列为通过。
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# 领域契约与 schema 4 迁移
|
|
2
|
+
|
|
3
|
+
本轮一次性切换公共接口,不保留旧字段别名。旧报告、变更计划必须重新采集或生成;仅把 schema_version 改为 4 无法补足身份、来源和聚合证据。
|
|
4
|
+
|
|
5
|
+
## 模块职责
|
|
6
|
+
|
|
7
|
+
| 模块 | 拥有的领域责任 | 不承担的责任 |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| expect-pty | PTY、IO、进程、匹配与终端恢复 | 设备健康、业务策略 |
|
|
10
|
+
| net-connector | 会话、登录、操作租约、资产与库存、邻居发现 | 公共观察结论和领域配置验收 |
|
|
11
|
+
| ctx_parser | 纯值、解析完整性、命令声明、语法注册 | 连接与报告交付 |
|
|
12
|
+
| ctx_driver | 单命令回执、来源摘要、借用会话读写 | 重连、健康判断、厂商配置策略 |
|
|
13
|
+
| ctx_runner | Target、Observation、Snapshot、采集交付、配置会话、受控执行 | 厂商语法、资产持久化 |
|
|
14
|
+
| ctx_checker | 运行事实、维度身份、健康与覆盖规则 | 配置下发 |
|
|
15
|
+
| vxlan | NX-OS、Fabric、配置依赖、可验证变更 | PTY 和公共交付状态机 |
|
|
16
|
+
| wireless-rb | AP/Radio/客户端、模板、AP 转接、无线变更 | 公共报告持久性与终端确认 |
|
|
17
|
+
| ctx_cli | 配置发现、用户输入输出、宿主入口编排 | 领域身份、采集完整性、网络会话 |
|
|
18
|
+
|
|
19
|
+
## 公共 Ruby 协议
|
|
20
|
+
|
|
21
|
+
- `Target.coerce(hash)` 接受明确的公开字段,内部使用 Symbol 键;`host` 必填,其他字段为 `platform/name/model/software_version/id`。对象深度不可变,支持 `with`、相等性、Hash 键和模式匹配。`same_identity?` 只比较 host/platform/id;显示名变化不改变身份。平台由领域 Registry 归一化,采集前拒绝目标与连接平台冲突。
|
|
22
|
+
- `Snapshot#target` 返回 Target;`to_h` 投影为普通数据。三个领域都提供 `observations`、`observation(name)`、`records(name)`、`collection_status`、`same_target?`。
|
|
23
|
+
- `Observation#evidence` 返回 `CtxDriver::Source` 数组。Source 的核心字段为 command、sha256、bytes、reference、observed_at、status、context;摘要和非负字节数必须同时存在。空 Hash 或仅有时间的来源无效,`not_applicable` 至少需要一份带摘要的来源。
|
|
24
|
+
- Source 属性 observed_at 是 UTC Time,`to_h` 将它输出为 ISO8601;领域附加属性放在 context。来源的摘要取自原始输出,不是解析后的正文。时间读取失败不得丢弃已经取得的摘要。
|
|
25
|
+
- Checker Observation 继承公共不可变值语义,但每次 `new`/`with` 都重新执行领域字段、身份和状态校验。
|
|
26
|
+
- `ConfigurationSession` 借用会话,接受领域注入的准备命令、配置查询和解析器。准备、写入和读取都验证单命令回执;失败不自动重放、不关闭借用会话。领域保留操作租约和前后配置验收。
|
|
27
|
+
- 变更对象提供 `to_h`、`commands`、`rollback`、`eligible?`、`satisfied?`;工厂提供 `build`、`candidate`。无线配置索引只构建一次,重复模板名仍是歧义,不能选第一条执行。
|
|
28
|
+
|
|
29
|
+
## 序列化与字段切换
|
|
30
|
+
|
|
31
|
+
| 旧接口 | 新接口 |
|
|
32
|
+
| --- | --- |
|
|
33
|
+
| 报告/计划/执行的 device | target |
|
|
34
|
+
| Hash 形式 snapshot.target | Target 值对象,序列化后仍是映射 |
|
|
35
|
+
| 任意 Hash 来源附加字段 | Source.context |
|
|
36
|
+
| neighbor_name / neighbor_interface / chassis_id | remote_name / remote_interface / remote_chassis_id |
|
|
37
|
+
| CDP interface | local_interface |
|
|
38
|
+
| BGP peer / peer_ip | peer_address |
|
|
39
|
+
| VXLAN BGP address_family: L2VPN EVPN | afi_safi: l2vpn_evpn |
|
|
40
|
+
| prefixes_received | received_prefixes |
|
|
41
|
+
| BGP 字符串状态 | Symbol 状态,管理关闭为 :shutdown |
|
|
42
|
+
| AP 原始状态文本 | :online / :offline / :unknown |
|
|
43
|
+
| channel_width / utilization | channel_width_mhz / utilization_percent |
|
|
44
|
+
| 无线报告平台 h3c_wireless | h3c |
|
|
45
|
+
|
|
46
|
+
厂商 CLI 原文和命令名称不改写。Netdisco 的 vendor、连接器凭据命名空间仍保留 h3c_wireless;无线 CLI 在领域平台边界进行映射。Netdisco 资产 Device 仍是资产对象。
|
|
47
|
+
|
|
48
|
+
schema 4 集合报告的顶层 status 必须与快照实际聚合结果一致;target 与 snapshot.target 的 host/platform/id 必须一致。无快照只能报告 failed。计划的目标平台必须匹配计划平台。Batch 在执行前拒绝重复和未请求目标,返回快照身份不符时不发布其事实。
|
|
49
|
+
|
|
50
|
+
纯数据和 JSON 使用 128 层深度预算;Fingerprint 不再受 JSON 默认 100 层限制。对象循环、键归一化碰撞和非有限数字仍被拒绝。
|
|
51
|
+
|
|
52
|
+
## 升级与验证
|
|
53
|
+
|
|
54
|
+
候选版本:ctx_cli/ctx_driver/ctx_runner 0.5.0,ctx_checker 0.6.0,net-connector 0.21.0,vxlan 0.8.0,wireless-rb 0.9.0。ctx_parser 继续 0.4.0,expect-pty 继续 0.9.6;没有为了统一命名而改动其稳定执行内核。
|
|
55
|
+
|
|
56
|
+
按 ctx_cli → ctx_driver → ctx_runner → 消费模块更新依赖;net-connector 0.21 依赖 ctx_cli 0.5。Parser 继续使用 0.4 系列。锁文件必须同步,避免把源码联调误当成已安装依赖兼容。
|
|
57
|
+
|
|
58
|
+
使用 RVM Ruby 4.0.6 执行各仓库 `bundle exec rake`。`script/verify_stack.rb WORKSPACE OUTPUT` 构建九个候选,在临时 GEM_HOME 验证依赖、普通入口、领域 Batch/schema 往返、本地 PTY 和最小 Bundler 消费方。无线 `benchmark/review.rb` 测完整审查序列化,`benchmark/configuration_index.rb` 测候选索引;合成性能不代表实机吞吐或型号认证。
|
data/docs/module-boundaries.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 网络模块的业务边界与原子操作
|
|
2
2
|
|
|
3
|
-
本设计覆盖 ctx_parser、ctx_driver、ctx_runner、ctx_cli、ctx_checker、net-connector、expect-pty、VXLAN 和 Wireless
|
|
3
|
+
本设计覆盖 ctx_parser、ctx_driver、ctx_runner、ctx_cli、ctx_checker、net-connector、expect-pty、VXLAN 和 Wireless。目录 `expect-ruby` 对应 gem expect-pty,`wireless-rb` 对应 Ruby 命名空间 Wireless。相邻 worktree 可能包含不同工作,不能当作同一版本。
|
|
4
4
|
|
|
5
5
|
## 业务链路与依赖
|
|
6
6
|
|
|
@@ -26,7 +26,7 @@ flowchart TD
|
|
|
26
26
|
| ctx_driver | 校验单条查询、执行回执、正文和原始摘要分离 | Reader、Capture、可选 Session 适配 | 借用会话;首次失同步后停止后续命令 |
|
|
27
27
|
| ctx_parser | 文本来源、命令声明、共享视图、事实快照 | Commands、Profile、Result、Immutable | 不持有连接或宿主状态 |
|
|
28
28
|
| ctx_runner | 唯一会话交付、单查询、批量结果、证据发布和已确认变更 | SessionScope、Collection、Query、Batch、Report、Execution | 借用会话;报告对象拥有自己的文件 |
|
|
29
|
-
| ctx_cli | 来源配置、输入预算、静态预览、预检顺序、交互和退出码 | Configuration、Collection、Review、Output | 借用标准流;调度任务须由宿主回收 |
|
|
29
|
+
| ctx_cli | 来源配置、输入预算、静态预览、预检顺序、交互和退出码 | Configuration、Collection、Review、Apply、Output | 借用标准流;调度任务须由宿主回收 |
|
|
30
30
|
| ctx_checker | 配置适用性、有限发现、观测关联、健康和计数策略 | Collector、Applicability、Snapshot、Evaluator | 借用连接器;规则独立于传输 |
|
|
31
31
|
| VXLAN | 配置依赖、Fabric 范围、服务身份、ACL 和类型化增量 | CollectionPlan、Collector、Fabric::Review、ChangePlan | 领域连接适配器取得操作租约 |
|
|
32
32
|
| Wireless | 控制器查询、AP 身份和选择、邻居覆盖、模板增量 | Collector、ApCollection、ApSession、Projection、ChangePlan | ApCollection 借用控制器;ApSession 管理转接租约 |
|
|
@@ -64,13 +64,13 @@ stateDiagram-v2
|
|
|
64
64
|
|
|
65
65
|
交付失败状态保留到流程结束,即使连接器 rescue 了回调异常,也不能恢复为完成。作用域结束后的回调直接抛出 IOError,且不修改已经发布的结果。
|
|
66
66
|
|
|
67
|
-
| 事实 | Collection
|
|
68
|
-
| --- | --- | --- |
|
|
69
|
-
| 没有交付 | session_not_opened |
|
|
70
|
-
| 重复交付 | session_reentered;保留首次事实 |
|
|
71
|
-
| 交付块未完成但异常被提供方吞掉 | session_incomplete |
|
|
72
|
-
| 跨线程交付 | session_out_of_scope;不调用领域块 |
|
|
73
|
-
| 关闭连接失败 | session_close_failed;保留已完成事实和先前交付故障 |
|
|
67
|
+
| 事实 | Collection | Execution |
|
|
68
|
+
| --- | --- | --- |
|
|
69
|
+
| 没有交付 | session_not_opened | failed;不发命令 |
|
|
70
|
+
| 重复交付 | session_reentered;保留首次事实 | 已发送则 uncertain;不重放 |
|
|
71
|
+
| 交付块未完成但异常被提供方吞掉 | session_incomplete,关闭失败不覆盖它 | failed/uncertain,取决于是否开始发送 |
|
|
72
|
+
| 跨线程交付 | session_out_of_scope;不调用领域块 | failed;不发命令 |
|
|
73
|
+
| 关闭连接失败 | session_close_failed;保留已完成事实和先前交付故障 | 不发布 configuration_verified |
|
|
74
74
|
|
|
75
75
|
线程池应在每个设备任务内部创建 Collection/Execution 并同步打开、使用、关闭该设备的会话。并行发生在设备任务之间,不能将已借出的会话回调移交给后台线程。
|
|
76
76
|
|
|
@@ -80,7 +80,7 @@ stateDiagram-v2
|
|
|
80
80
|
|
|
81
81
|
ApCollection 负责 AP 选择、缺失名称、覆盖范围、回执归属及逐 AP 失败隔离;`ApSession` 继续负责登录/返回控制器和嵌套操作租约。厂商 Profile 和 NeighborParser 继续维护命令及语法。公共 Runner 不承担 AP、型号、Fabric 或健康策略。
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
`Wireless::Collector#collect` 使用公共身份白名单和快照,返回结构按 schema 3 迁移。新的领域对象可以单独使用,但必须显式提供 `Wireless::Observation(name: :access_points)`;选择范围在回调前快照,非法输入在访问凭据前拒绝。
|
|
84
84
|
|
|
85
85
|
## 本次落地与验证边界
|
|
86
86
|
|
|
@@ -92,3 +92,5 @@ ApCollection 负责 AP 选择、缺失名称、覆盖范围、回执归属及逐
|
|
|
92
92
|
后续改动仍应以具体业务不变量为依据:发现策略留在 ctx_checker,配置依赖留在 VXLAN,AP 选择和租约留在 Wireless;不要因类名相似而合并这些策略,也不要新增统一工作流 DSL。对底层资源所有权的修改必须覆盖取消、关闭失败和已完成设备效果的保留。
|
|
93
93
|
|
|
94
94
|
本次验证结果、环境限制与复现证据见 [2026-10-25 验证记录](verification-2026-10-25.md)。
|
|
95
|
+
|
|
96
|
+
2026-10-29 的值对象、快照、apply 和文件格式契约见 [契约迁移](contracts-2026-10-29.md)。
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# 九模块契约改造验证记录
|
|
2
|
+
|
|
3
|
+
日期:2026-10-29。环境:Linux x86_64;运行时均由 RVM 安装。工作区为 `/root/gatework-contracts-20261029`,各仓库开发分支为 `contracts/unify`。本记录描述发布前的本地验证;远端 CI 和发布结果以对应版本标签及 GitHub Release 为准。
|
|
4
|
+
|
|
5
|
+
契约、职责和迁移说明见 [contracts-2026-10-29.md](contracts-2026-10-29.md)。本记录区分源码测试、独立安装与尚未运行的外部环境。
|
|
6
|
+
|
|
7
|
+
## 运行时
|
|
8
|
+
|
|
9
|
+
- Ruby 4.0.6,revision `03b6d3f889`:九模块完整检查。
|
|
10
|
+
- Ruby 3.4.12,revision `366f5fdc00`:最低 Ruby 版本为 3.4 的 ctx_cli、expect-pty、net-connector。
|
|
11
|
+
- Bundler 4.0.16;各仓库分别使用自己的 Gemfile 和已解析依赖。跨仓库源码联调另使用工作区 Gemfile,不能替代独立安装。
|
|
12
|
+
- 此环境的 RVM 选择命令使用完整名称,例如 `rvm use ruby-4.0.6`,避免旧版 RVM 对裸 `4.0.6` 的识别问题。
|
|
13
|
+
|
|
14
|
+
## 源码与工具检查
|
|
15
|
+
|
|
16
|
+
用例数为 RSpec examples 或 Minitest runs;Ruby 3.4 的重复运行不计入 Ruby 4 总数。
|
|
17
|
+
|
|
18
|
+
| 仓库 | Ruby 4.0.6 用例 | Ruby 3.4.12 用例 | 其他检查 |
|
|
19
|
+
| --- | ---: | ---: | --- |
|
|
20
|
+
| expect-ruby | 634 | 634 | lint、API/RBS;4.0.6 完整 script/ci、示例、七组 smoke benchmark |
|
|
21
|
+
| net-connector | 1284 | 1284 | lint、行/分支覆盖率门槛;4.0.6 源码/历史/包扫描、actionlint、benchmark、隔离包 |
|
|
22
|
+
| ctx_cli | 36 | 36 | lint、离线示例、rake build |
|
|
23
|
+
| ctx_parser | 140 | 不适用 | lint、离线示例、rake build |
|
|
24
|
+
| ctx_driver | 49 | 不适用 | lint、离线及真实 PTY 示例、rake build |
|
|
25
|
+
| ctx_runner | 78 | 不适用 | lint、离线示例、rake build |
|
|
26
|
+
| ctx_checker | 704 | 不适用 | lint、离线及真实 PTY 示例、rake build |
|
|
27
|
+
| vxlan | 482 | 不适用 | lint、离线示例、普通 CLI、rake build |
|
|
28
|
+
| wireless-rb | 340 | 不适用 | lint、离线示例、普通 CLI、rake build |
|
|
29
|
+
|
|
30
|
+
Ruby 4.0.6 共 3,747 个用例通过;Ruby 3.4.12 的三个库共 1,954 个用例通过。Parser/Driver/Runner/Checker/VXLAN/Wireless 的声明下限为 Ruby 4.0.6,不将它们列为 Ruby 3.4 已支持。
|
|
31
|
+
|
|
32
|
+
net-connector 的完整检查曾因环境缺少 GNU time 停在 benchmark;安装系统 time 后,续跑 `rake benchmark:smoke package:verify` 通过。测试、扫描和 lint 在此前已通过,分步日志共同构成完整结果。Ruby 3.4 只声明实际运行的 `bundle exec rake` 及其覆盖率检查,不将 Ruby 4 的包检查冒充为 Ruby 3.4 包检查。
|
|
33
|
+
|
|
34
|
+
原生 PTY 用例使用本地模拟设备,经过真实 expect-pty 和连接器;子进程使用 `--disable-gems`,避免把不需要的 Bundler 启动纳入两秒登录时限。没有访问网络设备。
|
|
35
|
+
|
|
36
|
+
## 独立安装
|
|
37
|
+
|
|
38
|
+
七个 ctx/领域仓库各自的 `script/verify_package.rb` 均通过,显式提供未发布依赖候选。Expect 和连接器的隔离安装由各自 CI/package 任务完成。
|
|
39
|
+
|
|
40
|
+
VXLAN/Wireless 另验证无连接器安装时的离线解析、review、帮助和计划输出,再安装连接器验证配置初始化、权限、清单预览与错误出口。安装过程不使用相邻源码目录;CLI 候选逐文件校验一致。
|
|
41
|
+
|
|
42
|
+
统一验证入口为:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
rvm use ruby-4.0.6
|
|
46
|
+
ruby ctx_runner/script/verify_stack.rb /root/gatework-contracts-20261029 /root/gatework-contracts-20261029/.artifacts
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
脚本从九个 checkout 构建候选,检查全部运行依赖约束,在临时 GEM_HOME 进行普通安装和最小 Bundler 安装。两种消费方式均检查精确候选版本、来源路径、三个领域共用 Batch、schema 3 往返、离线示例、普通 CLI 和真实 PTY。运行依赖来自已解析的本地 gem 缓存;候选不能被线上旧版替换。
|
|
50
|
+
|
|
51
|
+
最终包及 SHA256 记录在工作区 `.artifacts/manifest.json`,最终整体验证日志为 `.validation/stack-install-final.log`。manifest 中的 revision 是各仓库基线 HEAD;未提交的最终内容由候选包摘要确定。
|
|
52
|
+
|
|
53
|
+
## 重点回归
|
|
54
|
+
|
|
55
|
+
- Result 的 covered_scopes 参与 Data 值相等、hash、with 与模式匹配;不再由 ScopedResult 绕开值协议。
|
|
56
|
+
- Snapshot 对空请求、全部不可用、部分事实、关闭失败及有证据的不适用分别聚合;移除伪造的 collection 观测。
|
|
57
|
+
- Target 白名单、不可变输入、严格时刻与 schema 校验拒绝旧格式、未知身份字段、伪造的聚合结论及越界日期。
|
|
58
|
+
- 被连接器吞掉的回调失败不会被后续关闭失败覆盖;取消、重复回调、持久化失败和执行后记账失败仍保留既有事实。
|
|
59
|
+
- 共用 Apply 验证具名项和文件摘要,从领域增量重新生成命令;取消不连接、不重放、凭据空值回退及平台 enable password 均有消费端回归。
|
|
60
|
+
- 无线并发报告完整汇总、稳定排序;同一配置的模板计划共享指纹;新的报告重新计算指纹。
|
|
61
|
+
- Wireless 独立 review 缺失维度注册表 require 的问题由子进程回归复现,补齐显式加载后通过;不能依赖先加载根入口。
|
|
62
|
+
- net-connector 既有归档测试在基线上复现同一时钟粒度内覆写漏检;投递后在原描述符上复核摘要,完整测试通过。该修复增加一次有界读取,不声称零成本或对外部并发写入提供事务锁。
|
|
63
|
+
|
|
64
|
+
## 日志与范围
|
|
65
|
+
|
|
66
|
+
工作区 `.validation/` 保留原始日志:
|
|
67
|
+
|
|
68
|
+
- `*-locked-rake.log`:各仓库独立 Bundler 检查;VXLAN/Wireless 的最终结果使用 `*-final-rake.log`。
|
|
69
|
+
- `*-ruby34-rake.log`:Ruby 3.4 三库检查。
|
|
70
|
+
- `expect-ci.log`、`connector-ci.log`、`connector-package.log`:底层两库完整检查步骤。
|
|
71
|
+
- `*-build.log`、`*-package.log`、`stack-install-final.log`:构建、逐包安装和最终候选组合验证。
|
|
72
|
+
- `connector-baseline-mutation.log`、`wireless-review-loading-regression.log`:修复前的回归复现,保留失败输出以便追溯。
|
|
73
|
+
|
|
74
|
+
Wireless review(100/500/1000 模板)和 VXLAN fabric(100/1000/3000 组)基准的功能断言通过;本机共享负载下不据此宣称性能提升。
|
|
75
|
+
|
|
76
|
+
本地未运行 macOS、真实交换机/无线控制器、外部 SSH 或 PostgreSQL 联机矩阵。本次变更包含破坏性接口与 schema 3 迁移,旧报告及计划必须重新生成。本地验证不能替代发布标签对应的 CI 与制品读回校验。
|
data/examples/execution.rb
CHANGED
|
@@ -22,7 +22,7 @@ end
|
|
|
22
22
|
|
|
23
23
|
Dir.mktmpdir do |root|
|
|
24
24
|
report = CtxRunner::Report.new(File.join(root, "execution"))
|
|
25
|
-
plan = { "
|
|
25
|
+
plan = { "target" => { "host" => "192.0.2.1" }, "expected_config_sha256" => CtxRunner::Fingerprint.call("mode" => "disabled") }
|
|
26
26
|
execution = CtxRunner::Execution.new(plan: plan, change: ExampleChange.new, journal: report, plan_sha256: "a" * 64)
|
|
27
27
|
result = execution.run { |operation| operation.call(ExampleSession.new) }
|
|
28
28
|
raise "Unverified configuration" unless result["status"] == "configuration_verified"
|
data/examples/report.rb
CHANGED
|
@@ -8,7 +8,7 @@ Dir.mktmpdir do |root|
|
|
|
8
8
|
report = CtxRunner::Report.new(File.join(root, "reports"))
|
|
9
9
|
report.publish("evidence.json", JSON.generate(source: "synthetic", records: []))
|
|
10
10
|
device = { "host" => "192.0.2.1", "name" => "example" }
|
|
11
|
-
summary = report.finish([ {
|
|
11
|
+
summary = report.finish([ { target: device, status: :complete, report_saved: true } ], requested: [ device ]) do |value|
|
|
12
12
|
"Evidence: #{value.fetch('status')}; health was not evaluated.\n"
|
|
13
13
|
end
|
|
14
14
|
raise "Report incomplete" unless summary.fetch("status") == "complete"
|
data/lib/ctx_runner/batch.rb
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require "ctx_parser/immutable"
|
|
4
4
|
require "ctx_driver/failure"
|
|
5
5
|
require_relative "document"
|
|
6
|
+
require_relative "target"
|
|
6
7
|
|
|
7
8
|
module CtxRunner
|
|
8
9
|
# 批量采集的交付账本;调度器负责并发与回收,领域块只返回设备快照。
|
|
@@ -73,26 +74,42 @@ module CtxRunner
|
|
|
73
74
|
end
|
|
74
75
|
|
|
75
76
|
def initialize(report:, progress:, requested:)
|
|
76
|
-
|
|
77
|
+
raise ArgumentError, "Requested targets must be a list" unless requested.is_a?(Array)
|
|
78
|
+
targets = requested.map { |value| Target.coerce(value) }
|
|
79
|
+
@identities = targets.to_h { |target| [ target.identity_key, true ] }.freeze
|
|
80
|
+
raise ArgumentError, "Duplicate requested target" unless targets.size == @identities.size
|
|
81
|
+
@requested = Document.call(targets)
|
|
82
|
+
@claimed = {}
|
|
77
83
|
@report, @progress = report, progress
|
|
78
84
|
@results, @lock = [], Mutex.new
|
|
79
85
|
end
|
|
80
86
|
|
|
81
87
|
# 先登记设备事实,再保存报告;报告失败仍可在最终摘要中定位未交付结果。
|
|
82
88
|
def collect(device)
|
|
83
|
-
|
|
84
|
-
device =
|
|
89
|
+
identity = Target.coerce(device)
|
|
90
|
+
device = Document.call(identity)
|
|
91
|
+
@lock.synchronize do
|
|
92
|
+
raise ArgumentError, "Batch is closed" if @closed
|
|
93
|
+
unless @identities.key?(identity.identity_key) && !@claimed.key?(identity.identity_key)
|
|
94
|
+
raise ArgumentError, "Target must be requested exactly once"
|
|
95
|
+
end
|
|
96
|
+
@claimed[identity.identity_key] = true
|
|
97
|
+
end
|
|
85
98
|
started = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
86
99
|
@progress.start(device)
|
|
87
100
|
snapshot = nil
|
|
88
101
|
begin
|
|
89
102
|
snapshot = yield
|
|
103
|
+
unless snapshot.respond_to?(:target) && identity.same_identity?(snapshot.target)
|
|
104
|
+
snapshot = nil
|
|
105
|
+
raise ArgumentError, "Snapshot identity differs from the requested target"
|
|
106
|
+
end
|
|
90
107
|
dimensions = snapshot.observations.transform_values do |value|
|
|
91
108
|
{ status: value.status, records: value.records.size, issues: value.issues.map { |issue| issue[:code] }.uniq }
|
|
92
109
|
end
|
|
93
|
-
result = {
|
|
110
|
+
result = { target: device, status: snapshot.collection_status, dimensions: dimensions }
|
|
94
111
|
rescue StandardError => error
|
|
95
|
-
result = {
|
|
112
|
+
result = { target: device, status: :failed, error: CtxDriver::Failure.code(error, :collection_failed), dimensions: {} }
|
|
96
113
|
end
|
|
97
114
|
result[:duration_ms] = ((Process.clock_gettime(Process::CLOCK_MONOTONIC) - started) * 1000).round
|
|
98
115
|
result[:report_saved] = false
|
|
@@ -105,7 +122,7 @@ module CtxRunner
|
|
|
105
122
|
end
|
|
106
123
|
|
|
107
124
|
def results
|
|
108
|
-
@lock.synchronize { CtxParser::Immutable.copy(@results).sort_by { |result| result[:
|
|
125
|
+
@lock.synchronize { CtxParser::Immutable.copy(@results).sort_by { |result| result[:target].fetch("host") }.freeze }
|
|
109
126
|
end
|
|
110
127
|
|
|
111
128
|
# 调度器回收后调用;输出诊断只补写报告,绝不重新执行设备操作。
|
|
@@ -45,6 +45,7 @@ module CtxRunner
|
|
|
45
45
|
contract_failure(scope.failure) if scope.failure
|
|
46
46
|
rescue StandardError => error
|
|
47
47
|
raise unless CtxDriver::Failure.connection_error?(error, connector)
|
|
48
|
+
contract_failure(scope.failure) if scope&.failure && stage != :connect
|
|
48
49
|
details = CtxDriver::Failure.details(error, fallback: :connection_failed, stage: stage)
|
|
49
50
|
@failure ||= (stage == :close ? details.merge(code: :session_close_failed) : details).freeze
|
|
50
51
|
ensure
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "ctx_driver"
|
|
4
|
+
require "ctx_driver/receipt"
|
|
5
|
+
require "ctx_parser/commands"
|
|
6
|
+
require_relative "document"
|
|
7
|
+
|
|
8
|
+
module CtxRunner
|
|
9
|
+
# 借用领域已取得租约的会话;查询策略和配置解析器由领域显式注入。
|
|
10
|
+
class ConfigurationSession
|
|
11
|
+
def initialize(session:, preparation_commands:, configuration_command:, parser:, clock: -> { Time.now.utc })
|
|
12
|
+
unless preparation_commands.is_a?(Array) && parser.respond_to?(:parse) && session.respond_to?(:write_command)
|
|
13
|
+
raise ArgumentError, "Configuration session requires a writer and parser"
|
|
14
|
+
end
|
|
15
|
+
@preparation = preparation_commands.map { |command| CtxParser::Commands.command_text(command) }.freeze
|
|
16
|
+
@command = CtxParser::Commands.command_text(configuration_command)
|
|
17
|
+
@session, @parser = session, parser
|
|
18
|
+
@reader = CtxDriver::Reader.new(session: session, clock: clock)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def read_configuration
|
|
22
|
+
@preparation.each { |command| write(command) }
|
|
23
|
+
capture = @reader.read(@command)
|
|
24
|
+
raise IOError, "Configuration readback failed" unless capture.success?
|
|
25
|
+
observation = @parser.parse(capture.body, complete: true)
|
|
26
|
+
unless observation.complete? && observation.records.one?
|
|
27
|
+
raise ArgumentError, "Configuration evidence is incomplete"
|
|
28
|
+
end
|
|
29
|
+
Document.call(observation.records.first)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def write(command)
|
|
33
|
+
command = CtxParser::Commands.command_text(command).strip
|
|
34
|
+
receipt = @session.write_command(command)
|
|
35
|
+
raise IOError, "Device command is unconfirmed" unless CtxDriver::Receipt.validate(receipt, command: command)
|
|
36
|
+
true
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def inspect = "#<#{self.class.name}>"
|
|
40
|
+
alias to_s inspect
|
|
41
|
+
def pretty_print(printer) = printer.text(inspect)
|
|
42
|
+
end
|
|
43
|
+
end
|
data/lib/ctx_runner/document.rb
CHANGED
|
@@ -6,6 +6,8 @@ module CtxRunner
|
|
|
6
6
|
# 显式证据边界:生成独立 JSON 值,不通过文本往返转换业务事实。
|
|
7
7
|
module Document
|
|
8
8
|
MAX_DEPTH = 128
|
|
9
|
+
# 组合值对象显式加入文档协议;不对任意外部对象调用 to_h。
|
|
10
|
+
module Value; end
|
|
9
11
|
|
|
10
12
|
def self.call(value)
|
|
11
13
|
convert(value, {}.compare_by_identity, 0)
|
|
@@ -14,12 +16,12 @@ module CtxRunner
|
|
|
14
16
|
def self.convert(value, active, depth)
|
|
15
17
|
raise ArgumentError, "Document nesting exceeds the evidence budget" if depth > MAX_DEPTH
|
|
16
18
|
case value
|
|
17
|
-
when Hash, Array, Data
|
|
19
|
+
when Hash, Array, Data, Value
|
|
18
20
|
raise ArgumentError, "Document must not contain cyclic data" if active[value]
|
|
19
21
|
active[value] = true
|
|
20
22
|
begin
|
|
21
23
|
case value
|
|
22
|
-
when Data then convert(value.to_h, active, depth + 1)
|
|
24
|
+
when Data, Value then convert(value.to_h, active, depth + 1)
|
|
23
25
|
when Array then value.map { |item| convert(item, active, depth + 1) }.freeze
|
|
24
26
|
when Hash
|
|
25
27
|
value.each_with_object({}) do |(key, item), result|
|
|
@@ -36,7 +38,7 @@ module CtxRunner
|
|
|
36
38
|
ensure
|
|
37
39
|
active.delete(value)
|
|
38
40
|
end
|
|
39
|
-
when Time then value.iso8601(6).freeze
|
|
41
|
+
when Time then value.getutc.iso8601(6).freeze
|
|
40
42
|
when String then value.dup.freeze
|
|
41
43
|
when Symbol then value.name
|
|
42
44
|
when Rational, Complex then value.to_s.freeze
|
data/lib/ctx_runner/evidence.rb
CHANGED
|
@@ -1,30 +1,93 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "ipaddr"
|
|
4
|
+
require_relative "document"
|
|
5
|
+
require_relative "target"
|
|
6
|
+
require_relative "observation"
|
|
7
|
+
require_relative "snapshot"
|
|
4
8
|
|
|
5
9
|
module CtxRunner
|
|
6
10
|
# 离线证据的公共外壳;记录字段和领域语义交给消费模块校验。
|
|
7
11
|
module Evidence
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
VERSION = 4
|
|
13
|
+
KINDS = %w[collection batch change_plan change execution review recommendations fabric_review].freeze
|
|
14
|
+
|
|
15
|
+
def self.wrap(value, kind:)
|
|
16
|
+
raise ArgumentError, "Unknown evidence kind" unless KINDS.include?(kind)
|
|
17
|
+
Document.call(value).merge("schema_version" => VERSION, "kind" => kind.dup.freeze).freeze
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# 旧报告和计划必须重新生成;拒绝以默认值猜测版本。
|
|
21
|
+
def self.validate_version!(document, kind:)
|
|
22
|
+
unless document.is_a?(Hash) && document["schema_version"] == VERSION && document["kind"] == kind
|
|
23
|
+
raise ArgumentError, "Unsupported evidence format; regenerate reports and plans with schema version #{VERSION}"
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.plan(document, item:, platform:)
|
|
28
|
+
validate_version!(document, kind: "change_plan")
|
|
29
|
+
unless document["platform"] == platform && document["changes"].is_a?(Hash) && item.is_a?(String) &&
|
|
30
|
+
item.match?(/\A[A-Za-z0-9_.-]+\z/) && document["changes"].key?(item)
|
|
31
|
+
raise ArgumentError, "A supported plan and explicit --item are required"
|
|
32
|
+
end
|
|
33
|
+
selected = document["changes"].fetch(item)
|
|
34
|
+
validate_version!(selected, kind: "change")
|
|
35
|
+
raise ArgumentError, "Change platform differs from its plan" unless selected["platform"] == platform
|
|
36
|
+
identity = Target.coerce(selected.fetch("target"))
|
|
37
|
+
raise ArgumentError, "Change target platform differs from its plan" unless identity.platform == platform
|
|
38
|
+
host = identity.host
|
|
39
|
+
unless !host.include?("/") && IPAddr.new(host).to_s == host &&
|
|
40
|
+
selected["expected_config_sha256"].is_a?(String) && selected["expected_config_sha256"].match?(/\A[0-9a-f]{64}\z/)
|
|
41
|
+
raise ArgumentError, "Invalid change target or configuration fingerprint"
|
|
42
|
+
end
|
|
43
|
+
Document.call(selected)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def self.validate(document, names:)
|
|
47
|
+
validate_version!(document, kind: "collection")
|
|
48
|
+
unless document.is_a?(Hash) && document["target"].is_a?(Hash) &&
|
|
49
|
+
%w[name host].all? { |key| document["target"][key].is_a?(String) && !document["target"][key].empty? }
|
|
11
50
|
raise ArgumentError, "Device identity is missing"
|
|
12
51
|
end
|
|
13
|
-
host = document["
|
|
52
|
+
host = document["target"]["host"]
|
|
53
|
+
Target.coerce(document["target"])
|
|
14
54
|
raise ArgumentError, "Target address must be a canonical host address" unless !host.include?("/") && IPAddr.new(host).to_s == host
|
|
15
55
|
snapshot = document.fetch("snapshot")
|
|
16
|
-
|
|
17
|
-
|
|
56
|
+
if snapshot.nil?
|
|
57
|
+
raise ArgumentError, "Missing snapshots cannot claim successful collection" unless document["status"] == "failed"
|
|
58
|
+
return
|
|
59
|
+
end
|
|
60
|
+
unless snapshot.is_a?(Hash) && snapshot["observations"].is_a?(Hash) &&
|
|
61
|
+
%w[complete partial failed not_requested].include?(snapshot["collection_status"])
|
|
62
|
+
raise ArgumentError, "Invalid snapshot structure"
|
|
63
|
+
end
|
|
18
64
|
if !snapshot["target"].is_a?(Hash) || snapshot["target"]["host"] != host
|
|
19
65
|
raise ArgumentError, "Device identity does not match the collection target"
|
|
20
66
|
end
|
|
21
|
-
snapshot["
|
|
22
|
-
|
|
67
|
+
identity = Target.coerce(snapshot["target"])
|
|
68
|
+
%w[platform id].each do |field|
|
|
69
|
+
if document["target"][field] != snapshot["target"][field]
|
|
70
|
+
raise ArgumentError, "Device identity does not match the collection target"
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
observations = snapshot["observations"].to_h do |dimension, observation|
|
|
74
|
+
unless names.map(&:to_s).include?(dimension) && observation.is_a?(Hash) &&
|
|
75
|
+
Observation::STATUSES.map(&:to_s).include?(observation["status"]) && observation["name"] == dimension
|
|
23
76
|
raise ArgumentError, "Invalid observation structure"
|
|
24
77
|
end
|
|
25
78
|
records = array(observation.fetch("records"))
|
|
26
|
-
|
|
79
|
+
value = Observation.new(name: dimension.to_sym, status: observation["status"].to_sym, records: records,
|
|
80
|
+
issues: array(observation.fetch("issues", [])), evidence: array(observation.fetch("evidence", [])),
|
|
81
|
+
covered_scopes: array(observation.fetch("covered_scopes", [])),
|
|
82
|
+
started_at: observation["started_at"] && CtxParser::Values.timestamp(observation["started_at"]),
|
|
83
|
+
completed_at: observation["completed_at"] && CtxParser::Values.timestamp(observation["completed_at"]))
|
|
27
84
|
records.each { |record| yield(record, dimension) }
|
|
85
|
+
[ dimension.to_sym, value ]
|
|
86
|
+
end
|
|
87
|
+
value = Snapshot.new(target: identity, observations: observations, names: names,
|
|
88
|
+
observed_at: CtxParser::Values.timestamp(snapshot.fetch("observed_at")), issues: array(snapshot.fetch("issues", [])))
|
|
89
|
+
unless value.collection_status.to_s == snapshot["collection_status"] && document["status"] == snapshot["collection_status"]
|
|
90
|
+
raise ArgumentError, "Collection status differs from its evidence"
|
|
28
91
|
end
|
|
29
92
|
end
|
|
30
93
|
|
data/lib/ctx_runner/execution.rb
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "ctx_parser/immutable"
|
|
4
|
+
require "ctx_parser/commands"
|
|
4
5
|
require "ctx_driver/failure"
|
|
5
6
|
require_relative "fingerprint"
|
|
6
7
|
require_relative "session_scope"
|
|
8
|
+
require_relative "evidence"
|
|
7
9
|
|
|
8
10
|
module CtxRunner
|
|
9
11
|
# 只执行已确认的单项领域变更;日志、设备效果与配置验收分别记账。
|
|
@@ -11,7 +13,7 @@ module CtxRunner
|
|
|
11
13
|
# 领域动作负责有限命令及前后置条件;日志接收独立的不可变检查点。
|
|
12
14
|
def initialize(plan:, change:, journal:, plan_sha256:, item: nil)
|
|
13
15
|
@plan = CtxParser::Immutable.copy(plan)
|
|
14
|
-
unless @plan.is_a?(Hash) && @plan["
|
|
16
|
+
unless @plan.is_a?(Hash) && @plan["target"].is_a?(Hash) &&
|
|
15
17
|
[ @plan["expected_config_sha256"], plan_sha256 ].all? { |value| value.is_a?(String) && /\A[0-9a-f]{64}\z/.match?(value) }
|
|
16
18
|
raise ArgumentError, "Execution requires a verified plan and fingerprints"
|
|
17
19
|
end
|
|
@@ -19,11 +21,12 @@ module CtxRunner
|
|
|
19
21
|
raise ArgumentError, "Execution requires a typed change and journal"
|
|
20
22
|
end
|
|
21
23
|
@commands = CtxParser::Immutable.copy(change.commands)
|
|
22
|
-
unless @commands.is_a?(Array) && @commands.any?
|
|
24
|
+
unless @commands.is_a?(Array) && @commands.any?
|
|
23
25
|
raise ArgumentError, "Change commands must be individual lines"
|
|
24
26
|
end
|
|
27
|
+
@commands.each { |command| CtxParser::Commands.command_text(command) }
|
|
25
28
|
@change, @journal = change, journal
|
|
26
|
-
@state = { "status" => "confirmed", "
|
|
29
|
+
@state = { "schema_version" => Evidence::VERSION, "kind" => "execution", "status" => "confirmed", "target" => @plan["target"], "plan_sha256" => plan_sha256.dup.freeze,
|
|
27
30
|
"expected_config_sha256" => @plan["expected_config_sha256"], "commands" => @commands, "steps" => [] }
|
|
28
31
|
@state["plan_item"] = CtxParser::Immutable.copy(item) if item
|
|
29
32
|
@started = @used = @journal_failed = false
|
|
@@ -7,7 +7,7 @@ require "ctx_parser/immutable"
|
|
|
7
7
|
module CtxRunner
|
|
8
8
|
# 配置映射顺序不影响身份;列表顺序和全部字段仍参与旧版摘要协议。
|
|
9
9
|
module Fingerprint
|
|
10
|
-
def self.call(value) = Digest::SHA256.hexdigest(JSON.generate(canonical(value)))
|
|
10
|
+
def self.call(value) = Digest::SHA256.hexdigest(JSON.generate(canonical(value), max_nesting: false))
|
|
11
11
|
|
|
12
12
|
# 先拒绝非纯数据与循环,再将键归一化;重名键不能静默覆盖来源事实。
|
|
13
13
|
def self.canonical(value)
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "ctx_parser/immutable"
|
|
4
|
+
require "ctx_driver/source"
|
|
5
|
+
require "ctx_parser/values"
|
|
6
|
+
require "time"
|
|
4
7
|
|
|
5
8
|
module CtxRunner
|
|
6
9
|
# 不可变的事实外壳;领域可继承外壳或复用校验,记录身份和业务字段仍由领域负责。
|
|
7
|
-
class Observation < Data.define(:name, :status, :records, :issues, :evidence, :started_at, :completed_at)
|
|
8
|
-
STATUSES = %i[complete partial failed unsupported not_requested].freeze
|
|
10
|
+
class Observation < Data.define(:name, :status, :records, :issues, :evidence, :started_at, :completed_at, :covered_scopes)
|
|
11
|
+
STATUSES = %i[complete partial failed unsupported not_requested not_applicable].freeze
|
|
9
12
|
|
|
10
13
|
def self.validate(name:, status:, records:, issues:, evidence:, statuses: STATUSES)
|
|
11
14
|
raise ArgumentError, "Observation name must be a symbol" unless name.is_a?(Symbol)
|
|
12
15
|
raise ArgumentError, "Invalid observation status" unless statuses.include?(status)
|
|
13
|
-
unless [ records, issues
|
|
16
|
+
unless [ records, issues ].all? { |entries| entries.is_a?(Array) && entries.all? { |entry| entry.is_a?(Hash) } }
|
|
14
17
|
raise ArgumentError, "Observation entries must be arrays of hashes"
|
|
15
18
|
end
|
|
16
19
|
if %i[failed unsupported not_requested not_applicable].include?(status) && records.any?
|
|
@@ -18,19 +21,34 @@ module CtxRunner
|
|
|
18
21
|
end
|
|
19
22
|
end
|
|
20
23
|
|
|
21
|
-
def initialize(name:, status:, records: [], issues: [], evidence: [], started_at: nil, completed_at: nil)
|
|
24
|
+
def initialize(name:, status:, records: [], issues: [], evidence: [], started_at: nil, completed_at: nil, covered_scopes: [])
|
|
22
25
|
self.class.validate(name: name, status: status, records: records, issues: issues, evidence: evidence)
|
|
23
26
|
unless [ started_at, completed_at ].all? { |time| time.nil? || time.is_a?(Time) }
|
|
24
27
|
raise ArgumentError, "Observation timestamps must be Time values or nil"
|
|
25
28
|
end
|
|
29
|
+
unless covered_scopes.is_a?(Array) && covered_scopes.all? { |scope| scope.is_a?(Hash) } && covered_scopes.uniq == covered_scopes &&
|
|
30
|
+
(covered_scopes.empty? || %i[complete partial].include?(status))
|
|
31
|
+
raise ArgumentError, "Covered scopes require available observations and unique hashes"
|
|
32
|
+
end
|
|
33
|
+
raise ArgumentError, "Evidence must be a list of sources" unless evidence.is_a?(Array)
|
|
34
|
+
evidence = evidence.map { |entry| CtxDriver::Source.coerce(entry) }.freeze
|
|
35
|
+
if status == :not_applicable && !evidence.any?(&:verified?)
|
|
36
|
+
raise ArgumentError, "Not applicable observations require evidence"
|
|
37
|
+
end
|
|
38
|
+
@observed_at = evidence.filter_map(&:observed_at).max
|
|
26
39
|
super(name: name, status: status, records: CtxParser::Immutable.copy(records),
|
|
27
|
-
issues: CtxParser::Immutable.copy(issues), evidence:
|
|
28
|
-
started_at: started_at&.
|
|
40
|
+
issues: CtxParser::Immutable.copy(issues), evidence: evidence,
|
|
41
|
+
started_at: started_at&.getutc&.freeze, completed_at: completed_at&.getutc&.freeze,
|
|
42
|
+
covered_scopes: CtxParser::Immutable.copy(covered_scopes))
|
|
29
43
|
end
|
|
30
44
|
|
|
45
|
+
def to_h = super.merge(evidence: evidence.map(&:to_h))
|
|
46
|
+
|
|
31
47
|
def complete? = status == :complete
|
|
32
48
|
def partial? = status == :partial
|
|
33
49
|
def available? = complete? || partial?
|
|
50
|
+
# 来源采样时间不由较晚的快照或报告时间替代。
|
|
51
|
+
attr_reader :observed_at
|
|
34
52
|
def inspect = "#<#{self.class.name} name=#{name} status=#{status} records=#{records.size}>"
|
|
35
53
|
alias to_s inspect
|
|
36
54
|
def pretty_print(printer) = printer.text(inspect)
|
data/lib/ctx_runner/query.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "ctx_parser/immutable"
|
|
4
|
+
require "ctx_parser/commands"
|
|
4
5
|
require "ctx_driver/failure"
|
|
5
6
|
|
|
6
7
|
module CtxRunner
|
|
@@ -16,7 +17,7 @@ module CtxRunner
|
|
|
16
17
|
raise ArgumentError, "Query views must be unique symbols"
|
|
17
18
|
end
|
|
18
19
|
names = CtxParser::Immutable.copy(names)
|
|
19
|
-
command = CtxParser::
|
|
20
|
+
command = CtxParser::Commands.command_text(command)
|
|
20
21
|
capture = @reader.read(command)
|
|
21
22
|
failure = capture.failure
|
|
22
23
|
if capture.success?
|
data/lib/ctx_runner/report.rb
CHANGED
|
@@ -5,6 +5,7 @@ require "time"
|
|
|
5
5
|
require "tempfile"
|
|
6
6
|
require "fileutils"
|
|
7
7
|
require_relative "document"
|
|
8
|
+
require_relative "evidence"
|
|
8
9
|
|
|
9
10
|
module CtxRunner
|
|
10
11
|
# 持有私有证据批次,统一检查点、发布和失败恢复;领域只提供展示内容。
|
|
@@ -54,9 +55,9 @@ module CtxRunner
|
|
|
54
55
|
summary = checkpoint = nil
|
|
55
56
|
# 转换和编码也属于发布;失败或取消不能让上一轮完成结论继续生效。
|
|
56
57
|
checkpoint_body = publish_checkpoint("summary.json") do
|
|
57
|
-
#
|
|
58
|
-
|
|
59
|
-
pending = requested.reject { |
|
|
58
|
+
# 按完整目标身份索引一次,不让同地址的其他平台或资产替代待采集目标。
|
|
59
|
+
completed_targets = results.to_h { |result| [ Target.coerce(result.fetch(:target)).identity_key, true ] }
|
|
60
|
+
pending = requested.reject { |target| completed_targets.key?(Target.coerce(target).identity_key) }
|
|
60
61
|
complete = !report_error && !execution_error && !output_error && pending.empty? && results.any? && results.all? { |r| r[:status] == :complete && r[:report_saved] != false }
|
|
61
62
|
summary = { status: interrupted ? :interrupted : (complete ? :complete : :incomplete),
|
|
62
63
|
total: [ requested.size, results.size ].max, completed: results.size, pending: pending, counts: results.map { |r| r[:status] }.tally, devices: results,
|
|
@@ -65,7 +66,7 @@ module CtxRunner
|
|
|
65
66
|
summary[:report_error] = report_error if report_error
|
|
66
67
|
summary[:execution_error] = execution_error if execution_error
|
|
67
68
|
summary[:output_error] = output_error if output_error
|
|
68
|
-
summary =
|
|
69
|
+
summary = Evidence.wrap(summary, kind: "batch")
|
|
69
70
|
# 检查点共享已固定的证据;不重复转换,也不重新读取调用方对象。
|
|
70
71
|
checkpoint = summary.merge("status" => interrupted ? "interrupted" : "incomplete",
|
|
71
72
|
"report_error" => summary["report_error"] || "report_finalization_unconfirmed").freeze
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "target"
|
|
4
|
+
require_relative "observation"
|
|
5
|
+
require_relative "document"
|
|
6
|
+
|
|
7
|
+
module CtxRunner
|
|
8
|
+
# 领域组合公共快照;采集结论与领域健康、报告持久性分别表达。
|
|
9
|
+
class Snapshot
|
|
10
|
+
include Document::Value
|
|
11
|
+
attr_reader :target, :observations, :observed_at, :issues, :collection_status
|
|
12
|
+
|
|
13
|
+
def initialize(target:, observations:, observed_at:, names:, issues: [])
|
|
14
|
+
unless names.is_a?(Array) && names.all? { |name| name.is_a?(Symbol) } && names.uniq == names
|
|
15
|
+
raise ArgumentError, "Snapshot dimensions must be unique symbols"
|
|
16
|
+
end
|
|
17
|
+
unless observations.is_a?(Hash) && observations.all? do |name, value|
|
|
18
|
+
names.include?(name) && %i[name status records issues evidence covered_scopes started_at completed_at complete? to_h].all? { |method| value.respond_to?(method) } && value.name == name && Observation::STATUSES.include?(value.status) && value.frozen?
|
|
19
|
+
end
|
|
20
|
+
raise ArgumentError, "Snapshot observations must match declared dimensions"
|
|
21
|
+
end
|
|
22
|
+
raise ArgumentError, "Snapshot time must be a Time" unless observed_at.is_a?(Time)
|
|
23
|
+
unless issues.is_a?(Array) && issues.all? { |issue| issue.is_a?(Hash) }
|
|
24
|
+
raise ArgumentError, "Snapshot issues must be hashes"
|
|
25
|
+
end
|
|
26
|
+
@target = Target.coerce(target)
|
|
27
|
+
@names = names.dup.freeze
|
|
28
|
+
@observations = observations.to_h { |name, value| [ name, value ] }.freeze
|
|
29
|
+
@observed_at = observed_at.getutc.freeze
|
|
30
|
+
@issues = CtxParser::Immutable.copy(issues)
|
|
31
|
+
@collection_status = aggregate
|
|
32
|
+
freeze
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def observation(name)
|
|
36
|
+
raise ArgumentError, "Unknown observation dimension" unless @names.include?(name)
|
|
37
|
+
observations.fetch(name) { Observation.new(name: name, status: :not_requested) }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def complete? = collection_status == :complete
|
|
41
|
+
def same_target?(other) = other.respond_to?(:target) && target.same_identity?(other.target)
|
|
42
|
+
def records(name) = observation(name).records
|
|
43
|
+
|
|
44
|
+
def to_h
|
|
45
|
+
{ target: target.to_h, observations: observations.transform_values(&:to_h), observed_at: observed_at,
|
|
46
|
+
issues: issues, collection_status: collection_status }
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def inspect = "#<#{self.class.name} collection_status=#{collection_status}>"
|
|
50
|
+
alias to_s inspect
|
|
51
|
+
def pretty_print(printer) = printer.text(inspect)
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
# 不适用必须已有来源证据;空请求不通过 all? 被提升为完整。
|
|
56
|
+
def aggregate
|
|
57
|
+
selected = observations.values.reject { |observation| observation.status == :not_requested }
|
|
58
|
+
return issues.empty? ? :not_requested : :failed if selected.empty?
|
|
59
|
+
conclusive = selected.select do |observation|
|
|
60
|
+
%i[complete partial].include?(observation.status) || observation.status == :not_applicable && observation.evidence.any?
|
|
61
|
+
end
|
|
62
|
+
return :failed if conclusive.empty?
|
|
63
|
+
return :complete if issues.empty? && conclusive.size == selected.size && selected.none? { |observation| observation.status == :partial }
|
|
64
|
+
:partial
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "ctx_parser/immutable"
|
|
4
|
+
|
|
5
|
+
module CtxRunner
|
|
6
|
+
# 设备身份与连接设置分离;边界只接受公开字段,Ruby 内部统一符号键。
|
|
7
|
+
class Target < Data.define(:host, :platform, :name, :model, :software_version, :id)
|
|
8
|
+
FIELDS = %i[host platform name model software_version id].freeze
|
|
9
|
+
|
|
10
|
+
def self.coerce(value)
|
|
11
|
+
return value if value.is_a?(self)
|
|
12
|
+
raise ArgumentError, "Target must be a mapping of public identity fields" unless value.is_a?(Hash)
|
|
13
|
+
result = value.each_with_object({}) do |(key, entry), target|
|
|
14
|
+
unless (key.is_a?(String) || key.is_a?(Symbol)) && FIELDS.include?(key.to_sym) && !target.key?(key.to_sym)
|
|
15
|
+
raise ArgumentError, "Target contains unknown or duplicate identity fields"
|
|
16
|
+
end
|
|
17
|
+
target[key.to_sym] = entry
|
|
18
|
+
end
|
|
19
|
+
raise ArgumentError, "Target requires a host" unless result[:host].is_a?(String)
|
|
20
|
+
new(**result)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def initialize(host:, platform: nil, name: nil, model: nil, software_version: nil, id: nil)
|
|
24
|
+
attributes = { host: host, platform: platform, name: name, model: model, software_version: software_version, id: id }
|
|
25
|
+
unless host.is_a?(String) && attributes.all? do |key, value|
|
|
26
|
+
value.nil? || value.is_a?(String) && !value.strip.empty? && !/[\x00-\x1f\x7f]/.match?(value) || key == :id && value.is_a?(Integer) && value >= 0
|
|
27
|
+
end
|
|
28
|
+
raise ArgumentError, "Invalid target identity value"
|
|
29
|
+
end
|
|
30
|
+
super(**CtxParser::Immutable.copy(attributes))
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def identity_key = [ host, platform, id ].freeze
|
|
34
|
+
def same_identity?(other) = other.is_a?(Target) && identity_key == other.identity_key
|
|
35
|
+
def to_h = super.compact
|
|
36
|
+
def inspect = "#<#{self.class.name}>"
|
|
37
|
+
alias to_s inspect
|
|
38
|
+
def pretty_print(printer) = printer.text(inspect)
|
|
39
|
+
end
|
|
40
|
+
end
|
data/lib/ctx_runner/version.rb
CHANGED
data/lib/ctx_runner.rb
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative "ctx_runner/version"
|
|
4
4
|
require_relative "ctx_runner/observation"
|
|
5
|
+
require_relative "ctx_runner/snapshot"
|
|
5
6
|
require_relative "ctx_runner/session_scope"
|
|
6
7
|
require_relative "ctx_runner/collection"
|
|
7
8
|
require_relative "ctx_runner/query"
|
|
@@ -11,3 +12,4 @@ require_relative "ctx_runner/fingerprint"
|
|
|
11
12
|
require_relative "ctx_runner/document"
|
|
12
13
|
require_relative "ctx_runner/evidence"
|
|
13
14
|
require_relative "ctx_runner/execution"
|
|
15
|
+
require_relative "ctx_runner/configuration_session"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ctx_runner
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gatework contributors
|
|
@@ -15,40 +15,40 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 0.
|
|
18
|
+
version: 0.4.0
|
|
19
19
|
- - "<"
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
|
-
version: '0.
|
|
21
|
+
version: '0.5'
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
25
|
requirements:
|
|
26
26
|
- - ">="
|
|
27
27
|
- !ruby/object:Gem::Version
|
|
28
|
-
version: 0.
|
|
28
|
+
version: 0.4.0
|
|
29
29
|
- - "<"
|
|
30
30
|
- !ruby/object:Gem::Version
|
|
31
|
-
version: '0.
|
|
31
|
+
version: '0.5'
|
|
32
32
|
- !ruby/object:Gem::Dependency
|
|
33
33
|
name: ctx_driver
|
|
34
34
|
requirement: !ruby/object:Gem::Requirement
|
|
35
35
|
requirements:
|
|
36
36
|
- - ">="
|
|
37
37
|
- !ruby/object:Gem::Version
|
|
38
|
-
version: 0.
|
|
38
|
+
version: 0.5.0
|
|
39
39
|
- - "<"
|
|
40
40
|
- !ruby/object:Gem::Version
|
|
41
|
-
version: '0.
|
|
41
|
+
version: '0.6'
|
|
42
42
|
type: :runtime
|
|
43
43
|
prerelease: false
|
|
44
44
|
version_requirements: !ruby/object:Gem::Requirement
|
|
45
45
|
requirements:
|
|
46
46
|
- - ">="
|
|
47
47
|
- !ruby/object:Gem::Version
|
|
48
|
-
version: 0.
|
|
48
|
+
version: 0.5.0
|
|
49
49
|
- - "<"
|
|
50
50
|
- !ruby/object:Gem::Version
|
|
51
|
-
version: '0.
|
|
51
|
+
version: '0.6'
|
|
52
52
|
- !ruby/object:Gem::Dependency
|
|
53
53
|
name: digest
|
|
54
54
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -142,17 +142,21 @@ files:
|
|
|
142
142
|
- CHANGELOG.md
|
|
143
143
|
- LICENSE
|
|
144
144
|
- README.md
|
|
145
|
+
- docs/contracts-2026-10-29.md
|
|
146
|
+
- docs/contracts-2026-10-30.md
|
|
145
147
|
- docs/module-boundaries.md
|
|
146
148
|
- docs/superpowers/plans/2026-10-21-runner.md
|
|
147
149
|
- docs/superpowers/plans/2026-10-23-report-documents.md
|
|
148
150
|
- docs/superpowers/specs/2026-10-23-report-documents.md
|
|
149
151
|
- docs/verification-2026-10-22.md
|
|
150
152
|
- docs/verification-2026-10-25.md
|
|
153
|
+
- docs/verification-2026-10-29.md
|
|
151
154
|
- examples/execution.rb
|
|
152
155
|
- examples/report.rb
|
|
153
156
|
- lib/ctx_runner.rb
|
|
154
157
|
- lib/ctx_runner/batch.rb
|
|
155
158
|
- lib/ctx_runner/collection.rb
|
|
159
|
+
- lib/ctx_runner/configuration_session.rb
|
|
156
160
|
- lib/ctx_runner/document.rb
|
|
157
161
|
- lib/ctx_runner/evidence.rb
|
|
158
162
|
- lib/ctx_runner/execution.rb
|
|
@@ -161,6 +165,8 @@ files:
|
|
|
161
165
|
- lib/ctx_runner/query.rb
|
|
162
166
|
- lib/ctx_runner/report.rb
|
|
163
167
|
- lib/ctx_runner/session_scope.rb
|
|
168
|
+
- lib/ctx_runner/snapshot.rb
|
|
169
|
+
- lib/ctx_runner/target.rb
|
|
164
170
|
- lib/ctx_runner/version.rb
|
|
165
171
|
licenses:
|
|
166
172
|
- MIT
|