textus 0.55.1 → 0.56.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 +175 -2768
- data/README.md +17 -18
- data/lib/textus/artifact.rb +8 -0
- data/lib/textus/errors.rb +2 -39
- data/lib/textus/human.rb +7 -0
- data/lib/textus/infra/adapters/concurrency_adapter.rb +15 -0
- data/lib/textus/infra/clock.rb +7 -0
- data/lib/textus/infra/database.rb +127 -0
- data/lib/textus/infra/file_system.rb +54 -0
- data/lib/textus/infra/locks.rb +50 -0
- data/lib/textus/infra/port/clock.rb +18 -0
- data/lib/textus/infra/port/publisher.rb +71 -0
- data/lib/textus/infra/port/sentinel.rb +25 -0
- data/lib/textus/infra/port/sentinel_store.rb +93 -0
- data/lib/textus/infra/store/audit_log.rb +42 -0
- data/lib/textus/infra/store/base.rb +25 -0
- data/lib/textus/infra/store/cursor_store.rb +27 -0
- data/lib/textus/infra/store/entry_index.rb +31 -0
- data/lib/textus/infra/store/envelope/meta.rb +63 -0
- data/lib/textus/infra/store/file_store.rb +23 -0
- data/lib/textus/infra/store/index/builder.rb +28 -0
- data/lib/textus/infra/store/index/lookup.rb +23 -0
- data/lib/textus/infra/store/link_store.rb +43 -0
- data/lib/textus/infra/store/workflow_queue.rb +54 -0
- data/lib/textus/infra/store.rb +29 -0
- data/lib/textus/ingest.rb +8 -0
- data/lib/textus/lanes/artifact/cache.rb +35 -0
- data/lib/textus/lanes/artifact/handlers.rb +29 -0
- data/lib/textus/lanes/artifact/lifecycle.rb +23 -0
- data/lib/textus/lanes/artifact/verbs.rb +18 -0
- data/lib/textus/lanes/ingest/dedup.rb +17 -0
- data/lib/textus/lanes/ingest/entry_types/asset.rb +45 -0
- data/lib/textus/lanes/ingest/entry_types/link.rb +16 -0
- data/lib/textus/lanes/ingest/entry_types/text.rb +17 -0
- data/lib/textus/lanes/ingest/entry_types.rb +25 -0
- data/lib/textus/lanes/ingest/handlers.rb +54 -0
- data/lib/textus/lanes/ingest/index_rebuilder.rb +13 -0
- data/lib/textus/lanes/ingest/key_builder.rb +33 -0
- data/lib/textus/lanes/ingest/resolver.rb +21 -0
- data/lib/textus/lanes/knowledge/freeform.rb +15 -0
- data/lib/textus/lanes/knowledge/handlers.rb +53 -0
- data/lib/textus/lanes/knowledge/runner.rb +45 -0
- data/lib/textus/lanes/knowledge/verbs.rb +16 -0
- data/lib/textus/lanes/scratchpad/handlers.rb +164 -0
- data/lib/textus/lanes/scratchpad/verbs.rb +73 -0
- data/lib/textus/{gate → protocol}/binder.rb +2 -10
- data/lib/textus/protocol/boot/catalog.rb +34 -0
- data/lib/textus/protocol/boot/context.rb +124 -0
- data/lib/textus/protocol/boot/protocol.rb +33 -0
- data/lib/textus/protocol/boot.rb +42 -0
- data/lib/textus/protocol/builder/domain.rb +17 -0
- data/lib/textus/protocol/builder/infrastructure.rb +17 -0
- data/lib/textus/protocol/builder/runtime.rb +46 -0
- data/lib/textus/protocol/builder.rb +11 -0
- data/lib/textus/protocol/container.rb +22 -0
- data/lib/textus/protocol/diff.rb +170 -0
- data/lib/textus/protocol/entry_constraint.rb +54 -0
- data/lib/textus/protocol/envelope.rb +70 -0
- data/lib/textus/protocol/format/base.rb +80 -0
- data/lib/textus/protocol/format/bash.rb +10 -0
- data/lib/textus/protocol/format/javascript.rb +10 -0
- data/lib/textus/protocol/format/json.rb +82 -0
- data/lib/textus/protocol/format/markdown.rb +53 -0
- data/lib/textus/protocol/format/python.rb +10 -0
- data/lib/textus/protocol/format/ruby.rb +10 -0
- data/lib/textus/protocol/format/script.rb +55 -0
- data/lib/textus/protocol/format/text.rb +48 -0
- data/lib/textus/protocol/format/yaml.rb +105 -0
- data/lib/textus/protocol/format.rb +73 -0
- data/lib/textus/protocol/freshness/ttl_evaluator.rb +61 -0
- data/lib/textus/protocol/gate.rb +61 -0
- data/lib/textus/protocol/handlers/command_context.rb +19 -0
- data/lib/textus/protocol/handlers/concern.rb +15 -0
- data/lib/textus/protocol/handlers/ops/audit_filter.rb +37 -0
- data/lib/textus/protocol/handlers/ops/bulk_planner.rb +38 -0
- data/lib/textus/protocol/handlers/ops/data_mv.rb +49 -0
- data/lib/textus/protocol/handlers/ops/git_blame.rb +65 -0
- data/lib/textus/protocol/handlers/ops/pulse_coordinator.rb +37 -0
- data/lib/textus/protocol/handlers/ops/source_expander.rb +41 -0
- data/lib/textus/protocol/handlers/query_context.rb +41 -0
- data/lib/textus/protocol/handlers/read.rb +67 -0
- data/lib/textus/protocol/handlers/system.rb +93 -0
- data/lib/textus/protocol/handlers/write.rb +57 -0
- data/lib/textus/protocol/init.rb +143 -0
- data/lib/textus/protocol/key/grammar.rb +35 -0
- data/lib/textus/protocol/key/matching.rb +23 -0
- data/lib/textus/protocol/key/path.rb +23 -0
- data/lib/textus/protocol/key.rb +25 -0
- data/lib/textus/protocol/lane.rb +12 -0
- data/lib/textus/{store/geometry.rb → protocol/layout.rb} +32 -22
- data/lib/textus/protocol/links/resolver.rb +33 -0
- data/lib/textus/protocol/links/uri_rewriter.rb +30 -0
- data/lib/textus/protocol/links.rb +10 -0
- data/lib/textus/protocol/manifest/data.rb +90 -0
- data/lib/textus/protocol/manifest/entry/base.rb +95 -0
- data/lib/textus/protocol/manifest/entry/leaf.rb +19 -0
- data/lib/textus/protocol/manifest/entry/nested.rb +19 -0
- data/lib/textus/protocol/manifest/entry/parser.rb +71 -0
- data/lib/textus/protocol/manifest/entry/publish.rb +209 -0
- data/lib/textus/protocol/manifest/entry.rb +10 -0
- data/lib/textus/protocol/manifest/policy/publish_target.rb +36 -0
- data/lib/textus/protocol/manifest/policy.rb +69 -0
- data/lib/textus/protocol/manifest/resolver.rb +156 -0
- data/lib/textus/protocol/manifest/schema/contract.rb +53 -0
- data/lib/textus/protocol/manifest/schema/validator.rb +52 -0
- data/lib/textus/protocol/manifest/schema.rb +40 -0
- data/lib/textus/protocol/manifest.rb +62 -0
- data/lib/textus/protocol/produce/render/context.rb +43 -0
- data/lib/textus/protocol/produce/render.rb +44 -0
- data/lib/textus/protocol/schema/registry.rb +44 -0
- data/lib/textus/protocol/schema/tools.rb +104 -0
- data/lib/textus/protocol/schema.rb +117 -0
- data/lib/textus/protocol/session/bridge.rb +11 -0
- data/lib/textus/protocol/session/context.rb +5 -0
- data/lib/textus/protocol/session.rb +87 -0
- data/lib/textus/protocol/store_engine/delete.rb +37 -0
- data/lib/textus/protocol/store_engine/move.rb +109 -0
- data/lib/textus/protocol/store_engine/pipeline.rb +61 -0
- data/lib/textus/protocol/store_engine/put.rb +104 -0
- data/lib/textus/protocol/store_engine.rb +86 -0
- data/lib/textus/protocol/v4.rb +25 -0
- data/lib/textus/protocol/verb_registry/arg_spec.rb +19 -0
- data/lib/textus/protocol/verb_registry/core_verbs.rb +164 -0
- data/lib/textus/protocol/verb_registry/verb_spec.rb +42 -0
- data/lib/textus/protocol/verb_registry.rb +42 -0
- data/lib/textus/surface/cli/group/{rule.rb → web.rb} +2 -2
- data/lib/textus/surface/cli/runner.rb +25 -25
- data/lib/textus/surface/cli/sources.rb +1 -3
- data/lib/textus/surface/cli/verb/get.rb +3 -6
- data/lib/textus/surface/cli/verb/init.rb +1 -1
- data/lib/textus/surface/cli/verb/put.rb +8 -6
- data/lib/textus/surface/cli/verb/web_serve.rb +22 -0
- data/lib/textus/surface/cli.rb +25 -6
- data/lib/textus/surface/dispatch.rb +17 -0
- data/lib/textus/surface/mcp/adapters/mcp_adapter.rb +28 -0
- data/lib/textus/surface/mcp/catalog.rb +26 -62
- data/lib/textus/surface/mcp/cursor_manager.rb +22 -0
- data/lib/textus/surface/mcp/drift_annotation.rb +19 -0
- data/lib/textus/surface/mcp/errors.rb +0 -10
- data/lib/textus/surface/mcp/server.rb +46 -46
- data/lib/textus/surface/watcher.rb +18 -12
- data/lib/textus/surface/web.rb +50 -0
- data/lib/textus/value/call.rb +1 -1
- data/lib/textus/{core → value}/duration.rb +1 -4
- data/lib/textus/value/etag.rb +7 -7
- data/lib/textus/value/payload.rb +7 -0
- data/lib/textus/version.rb +1 -1
- data/lib/textus/workflow/consumer.rb +39 -0
- data/lib/textus/workflow/dsl/lifecycle.rb +32 -0
- data/lib/textus/workflow/dsl/pattern_matcher.rb +20 -0
- data/lib/textus/workflow/dsl/step_builder.rb +56 -0
- data/lib/textus/workflow/dsl.rb +111 -21
- data/lib/textus/workflow/event_emitter.rb +21 -0
- data/lib/textus/workflow/publisher.rb +59 -0
- data/lib/textus/workflow/registry.rb +31 -8
- data/lib/textus/workflow/runner.rb +25 -61
- data/lib/textus/workflow/scheduler.rb +45 -0
- data/lib/textus/workflow/step_executor.rb +78 -0
- data/lib/textus/workflow/step_helpers.rb +102 -0
- data/lib/textus/workflow.rb +2 -5
- data/lib/textus.rb +16 -80
- metadata +167 -183
- data/SPEC.md +0 -908
- data/docs/architecture/README.md +0 -273
- data/docs/reference/conventions.md +0 -138
- data/lib/textus/action/accept.rb +0 -46
- data/lib/textus/action/audit.rb +0 -94
- data/lib/textus/action/base.rb +0 -42
- data/lib/textus/action/blame.rb +0 -79
- data/lib/textus/action/boot.rb +0 -15
- data/lib/textus/action/data_mv.rb +0 -58
- data/lib/textus/action/deps.rb +0 -19
- data/lib/textus/action/doctor.rb +0 -17
- data/lib/textus/action/drain.rb +0 -31
- data/lib/textus/action/enqueue.rb +0 -37
- data/lib/textus/action/get.rb +0 -34
- data/lib/textus/action/ingest.rb +0 -199
- data/lib/textus/action/jobs.rb +0 -27
- data/lib/textus/action/key_delete.rb +0 -26
- data/lib/textus/action/key_delete_prefix.rb +0 -35
- data/lib/textus/action/key_mv.rb +0 -122
- data/lib/textus/action/key_mv_prefix.rb +0 -48
- data/lib/textus/action/list.rb +0 -28
- data/lib/textus/action/propose.rb +0 -42
- data/lib/textus/action/published.rb +0 -22
- data/lib/textus/action/pulse.rb +0 -49
- data/lib/textus/action/put.rb +0 -38
- data/lib/textus/action/rdeps.rb +0 -24
- data/lib/textus/action/reject.rb +0 -28
- data/lib/textus/action/rule_explain.rb +0 -81
- data/lib/textus/action/rule_lint.rb +0 -62
- data/lib/textus/action/rule_list.rb +0 -38
- data/lib/textus/action/schema_envelope.rb +0 -22
- data/lib/textus/action/uid.rb +0 -19
- data/lib/textus/action/where.rb +0 -21
- data/lib/textus/boot.rb +0 -202
- data/lib/textus/contract/arg.rb +0 -10
- data/lib/textus/contract/dsl.rb +0 -88
- data/lib/textus/contract/spec.rb +0 -25
- data/lib/textus/contract.rb +0 -12
- data/lib/textus/core/freshness/evaluator.rb +0 -150
- data/lib/textus/core/freshness/verdict.rb +0 -34
- data/lib/textus/core/freshness.rb +0 -11
- data/lib/textus/core/retention/sweep.rb +0 -57
- data/lib/textus/core/retention.rb +0 -11
- data/lib/textus/core/sentinel.rb +0 -30
- data/lib/textus/doctor/check/audit_log.rb +0 -34
- data/lib/textus/doctor/check/generator_drift.rb +0 -29
- data/lib/textus/doctor/check/illegal_keys.rb +0 -60
- data/lib/textus/doctor/check/manifest_files.rb +0 -25
- data/lib/textus/doctor/check/notebook_sources.rb +0 -50
- data/lib/textus/doctor/check/orphaned_publish_targets.rb +0 -35
- data/lib/textus/doctor/check/proposal_targets.rb +0 -45
- data/lib/textus/doctor/check/protocol_version.rb +0 -47
- data/lib/textus/doctor/check/publish_tree_index_overlap.rb +0 -48
- data/lib/textus/doctor/check/raw_asset_paths.rb +0 -50
- data/lib/textus/doctor/check/rule_ambiguity.rb +0 -49
- data/lib/textus/doctor/check/schema_parse_error.rb +0 -28
- data/lib/textus/doctor/check/schema_violations.rb +0 -28
- data/lib/textus/doctor/check/schemas.rb +0 -26
- data/lib/textus/doctor/check/sentinels.rb +0 -60
- data/lib/textus/doctor/check/stale_reviewed_stamp.rb +0 -54
- data/lib/textus/doctor/check/templates.rb +0 -29
- data/lib/textus/doctor/check/unowned_schema_fields.rb +0 -40
- data/lib/textus/doctor/check.rb +0 -41
- data/lib/textus/doctor/validator.rb +0 -93
- data/lib/textus/doctor.rb +0 -54
- data/lib/textus/format/base.rb +0 -49
- data/lib/textus/format/json.rb +0 -102
- data/lib/textus/format/markdown.rb +0 -80
- data/lib/textus/format/shared.rb +0 -17
- data/lib/textus/format/text.rb +0 -55
- data/lib/textus/format/yaml.rb +0 -125
- data/lib/textus/format.rb +0 -46
- data/lib/textus/gate/auth.rb +0 -212
- data/lib/textus/gate.rb +0 -92
- data/lib/textus/init.rb +0 -157
- data/lib/textus/jobs.rb +0 -9
- data/lib/textus/key/distance.rb +0 -55
- data/lib/textus/key/grammar.rb +0 -33
- data/lib/textus/key/matching.rb +0 -24
- data/lib/textus/key/path.rb +0 -28
- data/lib/textus/manifest/capabilities.rb +0 -29
- data/lib/textus/manifest/data.rb +0 -102
- data/lib/textus/manifest/entry/base.rb +0 -105
- data/lib/textus/manifest/entry/ignore_matcher.rb +0 -46
- data/lib/textus/manifest/entry/leaf.rb +0 -17
- data/lib/textus/manifest/entry/nested.rb +0 -37
- data/lib/textus/manifest/entry/parser.rb +0 -99
- data/lib/textus/manifest/entry/produced.rb +0 -36
- data/lib/textus/manifest/entry/publish/mode.rb +0 -45
- data/lib/textus/manifest/entry/publish/none.rb +0 -14
- data/lib/textus/manifest/entry/publish/subtree_mirror.rb +0 -73
- data/lib/textus/manifest/entry/publish/template.rb +0 -16
- data/lib/textus/manifest/entry/publish/to_paths.rb +0 -76
- data/lib/textus/manifest/entry/publish/tree.rb +0 -50
- data/lib/textus/manifest/entry/publish.rb +0 -45
- data/lib/textus/manifest/entry/validators/format_matrix.rb +0 -21
- data/lib/textus/manifest/entry/validators/ignore.rb +0 -28
- data/lib/textus/manifest/entry/validators/publish.rb +0 -30
- data/lib/textus/manifest/entry/validators.rb +0 -18
- data/lib/textus/manifest/entry.rb +0 -8
- data/lib/textus/manifest/policy/matcher.rb +0 -51
- data/lib/textus/manifest/policy/publish_target.rb +0 -34
- data/lib/textus/manifest/policy/react.rb +0 -30
- data/lib/textus/manifest/policy/retention.rb +0 -29
- data/lib/textus/manifest/policy/source.rb +0 -30
- data/lib/textus/manifest/policy.rb +0 -95
- data/lib/textus/manifest/resolver.rb +0 -118
- data/lib/textus/manifest/rules.rb +0 -86
- data/lib/textus/manifest/schema/contract.rb +0 -61
- data/lib/textus/manifest/schema/keys.rb +0 -90
- data/lib/textus/manifest/schema/semantics/cross_field.rb +0 -53
- data/lib/textus/manifest/schema/semantics/invariants.rb +0 -125
- data/lib/textus/manifest/schema/semantics/migration.rb +0 -83
- data/lib/textus/manifest/schema/semantics.rb +0 -27
- data/lib/textus/manifest/schema/validator.rb +0 -48
- data/lib/textus/manifest/schema/vocabulary.rb +0 -25
- data/lib/textus/manifest/schema.rb +0 -30
- data/lib/textus/manifest.rb +0 -65
- data/lib/textus/meta.rb +0 -54
- data/lib/textus/port/audit_log.rb +0 -268
- data/lib/textus/port/build_lock.rb +0 -64
- data/lib/textus/port/clock.rb +0 -10
- data/lib/textus/port/publisher.rb +0 -60
- data/lib/textus/port/sentinel_store.rb +0 -83
- data/lib/textus/port/storage/file_stat.rb +0 -19
- data/lib/textus/port/storage/file_store.rb +0 -26
- data/lib/textus/port/store.rb +0 -93
- data/lib/textus/port/watcher_lock.rb +0 -48
- data/lib/textus/produce/engine.rb +0 -50
- data/lib/textus/produce/render.rb +0 -20
- data/lib/textus/schema/tools.rb +0 -115
- data/lib/textus/schema.rb +0 -100
- data/lib/textus/schemas.rb +0 -54
- data/lib/textus/store/compositor.rb +0 -34
- data/lib/textus/store/container.rb +0 -43
- data/lib/textus/store/cursor.rb +0 -26
- data/lib/textus/store/envelope/reader.rb +0 -43
- data/lib/textus/store/envelope/writer.rb +0 -195
- data/lib/textus/store/index/builder.rb +0 -74
- data/lib/textus/store/index/lookup.rb +0 -60
- data/lib/textus/store/jobs/base.rb +0 -13
- data/lib/textus/store/jobs/index.rb +0 -15
- data/lib/textus/store/jobs/materialize.rb +0 -15
- data/lib/textus/store/jobs/plan.rb +0 -11
- data/lib/textus/store/jobs/planner.rb +0 -104
- data/lib/textus/store/jobs/queue.rb +0 -154
- data/lib/textus/store/jobs/registry.rb +0 -19
- data/lib/textus/store/jobs/retention.rb +0 -50
- data/lib/textus/store/jobs/sweep.rb +0 -21
- data/lib/textus/store/jobs/worker.rb +0 -64
- data/lib/textus/store/session.rb +0 -37
- data/lib/textus/store.rb +0 -99
- data/lib/textus/surface/cli/verb/doctor.rb +0 -19
- data/lib/textus/surface/cli/verb/schema_diff.rb +0 -17
- data/lib/textus/surface/cli/verb/schema_init.rb +0 -21
- data/lib/textus/surface/cli/verb/schema_migrate.rb +0 -21
- data/lib/textus/surface/mcp.rb +0 -8
- data/lib/textus/surface/projector.rb +0 -27
- data/lib/textus/surface/role_scope.rb +0 -34
- data/lib/textus/value/command.rb +0 -16
- data/lib/textus/value/envelope.rb +0 -89
- data/lib/textus/value/result.rb +0 -26
- data/lib/textus/workflow/collector.rb +0 -27
- data/lib/textus/workflow/context.rb +0 -5
- data/lib/textus/workflow/loader.rb +0 -17
- data/lib/textus/workflow/pattern.rb +0 -18
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
module Textus
|
|
2
|
-
class Manifest
|
|
3
|
-
class Rules
|
|
4
|
-
# Every structural member here derives from Schema::FIELD_REGISTRY (WS3),
|
|
5
|
-
# so a new rule field is added in one place. `in_pick` selects the fields
|
|
6
|
-
# that participate in the most-specific `for(key)` resolution.
|
|
7
|
-
PICK_FIELDS = Schema::FIELD_REGISTRY.select { |_, m| m[:in_pick] }.keys.freeze
|
|
8
|
-
|
|
9
|
-
RuleSet = ::Data.define(*PICK_FIELDS)
|
|
10
|
-
EMPTY_SET = RuleSet.new(**PICK_FIELDS.to_h { |f| [f, nil] })
|
|
11
|
-
|
|
12
|
-
def self.parse(raw)
|
|
13
|
-
new(Array(raw).map { |b| Block.new(b) })
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def initialize(blocks)
|
|
17
|
-
@blocks = blocks
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
attr_reader :blocks
|
|
21
|
-
|
|
22
|
-
def for(key)
|
|
23
|
-
slots = PICK_FIELDS.to_h { |f| [f, []] }
|
|
24
|
-
@blocks.each do |b|
|
|
25
|
-
next unless Textus::Manifest::Policy::Matcher.matches?(b.match, key)
|
|
26
|
-
|
|
27
|
-
slots.each_key { |slot| slots[slot] << b if b.public_send(slot) }
|
|
28
|
-
end
|
|
29
|
-
RuleSet.new(**slots.to_h { |slot, blocks| [slot, pick(blocks, slot, key)] })
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def explain(key)
|
|
33
|
-
@blocks.select { |b| Textus::Manifest::Policy::Matcher.matches?(b.match, key) }
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
private
|
|
37
|
-
|
|
38
|
-
def pick(blocks, slot, key)
|
|
39
|
-
return nil if blocks.empty?
|
|
40
|
-
|
|
41
|
-
globs = blocks.map(&:match)
|
|
42
|
-
winning = Textus::Manifest::Policy::Matcher.pick_most_specific(globs, key: key)
|
|
43
|
-
blocks.find { |b| b.match == winning }&.public_send(slot)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
class Block
|
|
47
|
-
attr_reader :match, *Schema::FIELD_REGISTRY.keys
|
|
48
|
-
|
|
49
|
-
def initialize(raw)
|
|
50
|
-
@match = raw["match"] or raise Textus::UsageError.new("rule block missing match:")
|
|
51
|
-
Schema::FIELD_REGISTRY.each do |field, meta|
|
|
52
|
-
instance_variable_set("@#{field}", parse_field(meta, raw[meta[:yaml_key]]))
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
private
|
|
57
|
-
|
|
58
|
-
# One dispatch over the registry, replacing the four bespoke parse_*
|
|
59
|
-
# methods. :deferred carries the raw Hash after a shape check (its
|
|
60
|
-
# contents validate later — guard predicates at Dispatch::Auth check time,
|
|
61
|
-
# ADR 0031); :immediate instantiates the policy class now. :tagged passes
|
|
62
|
-
# the raw Hash straight to a policy class that is a tagged union and
|
|
63
|
-
# dispatches on its discriminator field (e.g. upkeep's on:). A mapping
|
|
64
|
-
# field (sub_keys) splats its nested keys as kwargs; a scalar/array
|
|
65
|
-
# field passes its raw value under arg_key.
|
|
66
|
-
def parse_field(meta, value)
|
|
67
|
-
return nil if value.nil?
|
|
68
|
-
|
|
69
|
-
if meta[:validation] == :deferred
|
|
70
|
-
raise Textus::BadManifest.new("#{meta[:yaml_key]}: must be a map of transition => [predicates]") unless value.is_a?(Hash)
|
|
71
|
-
|
|
72
|
-
return value
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
return meta[:policy_class].new(value) if meta[:validation] == :tagged
|
|
76
|
-
|
|
77
|
-
if meta[:sub_keys]
|
|
78
|
-
meta[:policy_class].new(**meta[:sub_keys].to_h { |k| [k.to_sym, value[k]] })
|
|
79
|
-
else
|
|
80
|
-
meta[:policy_class].new(meta[:arg_key] => value)
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
end
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "dry/schema"
|
|
4
|
-
|
|
5
|
-
module Textus
|
|
6
|
-
class Manifest
|
|
7
|
-
module Schema
|
|
8
|
-
# rubocop:disable Metrics/BlockLength
|
|
9
|
-
Contract = Dry::Schema.JSON do
|
|
10
|
-
required(:lanes).value(:array).each do
|
|
11
|
-
hash do
|
|
12
|
-
required(:name).value(:string)
|
|
13
|
-
required(:kind).value(included_in?: Vocabulary::LANE_KINDS)
|
|
14
|
-
optional(:owner).value(:string)
|
|
15
|
-
optional(:desc).value(:string)
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
optional(:roles).value(:array).each do
|
|
20
|
-
hash do
|
|
21
|
-
required(:name).value(:string)
|
|
22
|
-
optional(:can).value(:array).each(:string)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
optional(:entries).value(:array).each do
|
|
27
|
-
hash do
|
|
28
|
-
required(:key).value(:string)
|
|
29
|
-
required(:lane).value(:string)
|
|
30
|
-
optional(:path).value(:string)
|
|
31
|
-
optional(:owner).value(:string)
|
|
32
|
-
optional(:format).value(:string)
|
|
33
|
-
optional(:schema).maybe(:string)
|
|
34
|
-
optional(:kind).value(:string)
|
|
35
|
-
optional(:nested).value(:bool)
|
|
36
|
-
optional(:tracked).value(:bool)
|
|
37
|
-
optional(:ignore)
|
|
38
|
-
optional(:source)
|
|
39
|
-
optional(:publish).value(:array)
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
optional(:rules).value(:array).each do
|
|
44
|
-
hash do
|
|
45
|
-
optional(:match).value(:string)
|
|
46
|
-
optional(:guard)
|
|
47
|
-
optional(:retention)
|
|
48
|
-
optional(:react)
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
optional(:audit).hash do
|
|
53
|
-
optional(:max_size).value(:integer)
|
|
54
|
-
optional(:keep).value(:integer)
|
|
55
|
-
end
|
|
56
|
-
optional(:version).value(:string)
|
|
57
|
-
end
|
|
58
|
-
# rubocop:enable Metrics/BlockLength
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
module Textus
|
|
2
|
-
class Manifest
|
|
3
|
-
module Schema
|
|
4
|
-
# The manifest's key whitelists and the rule-field registry — the schema's
|
|
5
|
-
# data tables (ADR 0109; the vocabulary lives in Schema::Vocabulary).
|
|
6
|
-
module Keys
|
|
7
|
-
ROOT_KEYS = %w[version roles lanes entries rules audit].freeze
|
|
8
|
-
ROLE_KEYS = %w[name can].freeze
|
|
9
|
-
LANE_KEYS = %w[name kind owner desc].freeze
|
|
10
|
-
ENTRY_KEYS = %w[
|
|
11
|
-
key path lane kind schema owner nested format
|
|
12
|
-
source publish tracked ignore
|
|
13
|
-
].freeze
|
|
14
|
-
# ADR 0052: the typed publish block — `publish: { to: [...] }` (file
|
|
15
|
-
# fan-out) xor `publish: { tree: "dir" }` (subtree mirror).
|
|
16
|
-
PUBLISH_KEYS = %w[to tree].freeze
|
|
17
|
-
# entry-level external-generator block — only `from: external` is valid.
|
|
18
|
-
# `from: fetch` and `from: derive` and their specific fields (handler,
|
|
19
|
-
# config, ttl, select, pluck, sort_by, transform) were removed in the
|
|
20
|
-
# workflow redesign.
|
|
21
|
-
SOURCE_KEYS = %w[from command sources].freeze
|
|
22
|
-
# ADR 0093: rule-level GC slot. drop/archive only (refresh gone).
|
|
23
|
-
RETENTION_KEYS = %w[ttl action].freeze
|
|
24
|
-
|
|
25
|
-
# The ONE source of truth for the rule-block field set (WS3). Adding a
|
|
26
|
-
# rule field means adding one entry here; everything downstream derives
|
|
27
|
-
# from it so the ~9 enumeration sites the audit found can't drift:
|
|
28
|
-
# - Schema::RULE_KEYS and the per-field sub-key walk (Schema::Validator)
|
|
29
|
-
# - Rules: the RuleSet members, EMPTY_SET, the `for` slots accumulator,
|
|
30
|
-
# Block's attr_readers, and the parse dispatch
|
|
31
|
-
# - Doctor::Check::RuleAmbiguity SLOTS (in_ambiguity)
|
|
32
|
-
# - Read::RuleList / Read::RuleExplain field membership
|
|
33
|
-
# (in_rule_list / in_rule_explain)
|
|
34
|
-
#
|
|
35
|
-
# Per field:
|
|
36
|
-
# yaml_key manifest key used in a rule block
|
|
37
|
-
# policy_class the Manifest::Policy backing the field (nil = raw value)
|
|
38
|
-
# validation :immediate (instantiate the policy at parse, surfacing
|
|
39
|
-
# shape errors eagerly), :deferred (shape-check + carry
|
|
40
|
-
# the raw Hash; guard predicates validate at Dispatch::Auth
|
|
41
|
-
# build time, ADR 0031), or :tagged (pass the raw Hash to a
|
|
42
|
-
# tagged-union policy that dispatches on its discriminator
|
|
43
|
-
# field, e.g. upkeep's on:)
|
|
44
|
-
# sub_keys allowed nested keys for a mapping field (drives both the
|
|
45
|
-
# schema sub-key walk and the kwargs splat into policy_class)
|
|
46
|
-
# arg_key for an immediate non-mapping field, the single kwarg the
|
|
47
|
-
# raw value is passed under
|
|
48
|
-
# in_pick participates in the most-specific `for(key)` resolution
|
|
49
|
-
# in_ambiguity linted by doctor's same-specificity tie check
|
|
50
|
-
# in_rule_list shown in the whole-manifest rule_list view
|
|
51
|
-
# in_rule_explain depths the field shows at: :lean and/or :detail
|
|
52
|
-
#
|
|
53
|
-
# Key order here fixes the order of RULE_KEYS (after match), the slots,
|
|
54
|
-
# the RuleSet members, and the doctor SLOTS.
|
|
55
|
-
FIELD_REGISTRY = {
|
|
56
|
-
guard: {
|
|
57
|
-
yaml_key: "guard",
|
|
58
|
-
policy_class: nil,
|
|
59
|
-
validation: :deferred, sub_keys: nil, arg_key: nil,
|
|
60
|
-
in_pick: true, in_ambiguity: true,
|
|
61
|
-
in_rule_list: true, in_rule_explain: %i[lean detail]
|
|
62
|
-
},
|
|
63
|
-
retention: {
|
|
64
|
-
yaml_key: "retention",
|
|
65
|
-
policy_class: Textus::Manifest::Policy::Retention,
|
|
66
|
-
validation: :tagged, sub_keys: RETENTION_KEYS, arg_key: nil,
|
|
67
|
-
in_pick: true, in_ambiguity: true,
|
|
68
|
-
in_rule_list: true, in_rule_explain: %i[lean detail]
|
|
69
|
-
},
|
|
70
|
-
react: {
|
|
71
|
-
yaml_key: "react",
|
|
72
|
-
policy_class: Textus::Manifest::Policy::React,
|
|
73
|
-
validation: :immediate, sub_keys: nil, arg_key: :raw,
|
|
74
|
-
in_pick: true, in_ambiguity: true,
|
|
75
|
-
in_rule_list: true, in_rule_explain: %i[lean detail]
|
|
76
|
-
},
|
|
77
|
-
}.freeze
|
|
78
|
-
|
|
79
|
-
RULE_KEYS = (["match"] + FIELD_REGISTRY.values.map { |m| m[:yaml_key] }).freeze
|
|
80
|
-
AUDIT_KEYS = %w[max_size keep].freeze
|
|
81
|
-
# Syntactic shape of an `owner:` subject token (the `patrick` in
|
|
82
|
-
# `human:patrick`) — the subject half of the owner-validation rule below.
|
|
83
|
-
# Role supplies the archetype set (Role::NAMES); this pattern is the
|
|
84
|
-
# owner-specific part, so it lives with the rule that composes them
|
|
85
|
-
# (ADR 0045 D1). Acting-role *names* are gated by Role::NAMES, not a regex.
|
|
86
|
-
OWNER_SUBJECT_PATTERN = /\A[a-z][a-z0-9_-]*\z/
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
end
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
module Textus
|
|
2
|
-
class Manifest
|
|
3
|
-
module Schema
|
|
4
|
-
module Semantics
|
|
5
|
-
module CrossField
|
|
6
|
-
def check_cross_field!(raw)
|
|
7
|
-
check_owners!(raw["lanes"], raw["entries"])
|
|
8
|
-
check_lane_kind_consistency!(raw)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def check_owners!(lanes, entries)
|
|
12
|
-
Array(lanes).each_with_index { |z, i| check_owner!(z["owner"], "$.lanes[#{i}]") }
|
|
13
|
-
Array(entries).each_with_index { |e, i| check_owner!(e["owner"], "$.entries[#{i}]") }
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def check_owner!(owner, path)
|
|
17
|
-
return if owner.nil?
|
|
18
|
-
return if valid_owner?(owner)
|
|
19
|
-
|
|
20
|
-
raise BadManifest.new(
|
|
21
|
-
"invalid owner '#{owner}' at '#{path}' " \
|
|
22
|
-
"(expected <archetype> or <archetype>:<subject>, archetype one of: #{Textus::Value::Role::NAMES.join(", ")})",
|
|
23
|
-
)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def valid_owner?(token)
|
|
27
|
-
return false unless token.is_a?(String) && !token.empty?
|
|
28
|
-
|
|
29
|
-
archetype, subject = token.split(":", 2)
|
|
30
|
-
return false unless Textus::Value::Role::NAMES.include?(archetype)
|
|
31
|
-
return true if subject.nil?
|
|
32
|
-
|
|
33
|
-
OWNER_SUBJECT_PATTERN.match?(subject)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def check_lane_kind_consistency!(raw)
|
|
37
|
-
held = Capabilities.resolve(raw["roles"]).values.flatten.uniq
|
|
38
|
-
|
|
39
|
-
Array(raw["lanes"]).each_with_index do |z, i|
|
|
40
|
-
verb = KIND_REQUIRES_VERB[z["kind"]]
|
|
41
|
-
next if verb.nil? || held.include?(verb)
|
|
42
|
-
|
|
43
|
-
raise BadManifest.new(
|
|
44
|
-
"lane '#{z["name"]}' (#{z["kind"]}) at '$.lanes[#{i}]' " \
|
|
45
|
-
"needs a role with capability '#{verb}'; none declared",
|
|
46
|
-
)
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
module Textus
|
|
2
|
-
class Manifest
|
|
3
|
-
module Schema
|
|
4
|
-
module Semantics
|
|
5
|
-
module Invariants
|
|
6
|
-
def check_invariants!(raw)
|
|
7
|
-
check_roles!(raw["roles"])
|
|
8
|
-
check_lanes!(raw["lanes"])
|
|
9
|
-
check_entries!(raw["entries"])
|
|
10
|
-
check_rules!(raw["rules"])
|
|
11
|
-
check_single_queue!(raw)
|
|
12
|
-
check_single_machine!(raw)
|
|
13
|
-
walk(raw["audit"], AUDIT_KEYS, "$.audit") if raw["audit"].is_a?(Hash)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def check_roles!(roles)
|
|
17
|
-
return if roles.nil?
|
|
18
|
-
|
|
19
|
-
roles.each_with_index do |r, i|
|
|
20
|
-
path = "$.roles[#{i}]"
|
|
21
|
-
name = r["name"]
|
|
22
|
-
unless Textus::Value::Role::NAMES.include?(name)
|
|
23
|
-
raise BadManifest.new(
|
|
24
|
-
"unknown role name '#{name}' at '#{path}' (allowed: #{Textus::Value::Role::NAMES.join(", ")})",
|
|
25
|
-
)
|
|
26
|
-
end
|
|
27
|
-
Array(r["can"]).each do |verb|
|
|
28
|
-
next if CAPABILITIES.include?(verb)
|
|
29
|
-
|
|
30
|
-
hint = %w[ingest fetch].include?(verb) ? " — the quarantine capability folded into 'converge' (ADR 0090)" : ""
|
|
31
|
-
raise BadManifest.new(
|
|
32
|
-
"unknown capability '#{verb}' for role '#{name}' at '#{path}' " \
|
|
33
|
-
"(known: #{CAPABILITIES.join(", ")})#{hint}",
|
|
34
|
-
)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
author_holders = roles.count { |r| Array(r["can"]).include?("author") }
|
|
39
|
-
return if author_holders <= 1
|
|
40
|
-
|
|
41
|
-
raise BadManifest.new(
|
|
42
|
-
"manifest declares #{author_holders} roles with the author capability; at most one is allowed",
|
|
43
|
-
)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def check_lanes!(lanes)
|
|
47
|
-
Array(lanes).each_with_index do |z, i|
|
|
48
|
-
walk(z, LANE_KEYS, "$.lanes[#{i}]")
|
|
49
|
-
next unless %w[quarantine derived].include?(z["kind"])
|
|
50
|
-
|
|
51
|
-
raise BadManifest.new(
|
|
52
|
-
"lane kind '#{z["kind"]}' at '$.lanes[#{i}]' was folded into 'machine' (ADR 0091) — " \
|
|
53
|
-
"use `kind: machine`",
|
|
54
|
-
)
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def check_entries!(entries)
|
|
59
|
-
Array(entries).each_with_index do |e, i|
|
|
60
|
-
path = "$.entries[#{i}]"
|
|
61
|
-
walk(e, ENTRY_KEYS, path)
|
|
62
|
-
check_publish_block!(e, path)
|
|
63
|
-
walk(e["source"], SOURCE_KEYS, "#{path}.source") if e.is_a?(Hash) && e["source"].is_a?(Hash)
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def check_rules!(rules)
|
|
68
|
-
Array(rules).each_with_index do |r, i|
|
|
69
|
-
path = "$.rules[#{i}]"
|
|
70
|
-
walk(r, RULE_KEYS, path)
|
|
71
|
-
FIELD_REGISTRY.each_value do |meta|
|
|
72
|
-
next unless meta[:sub_keys]
|
|
73
|
-
|
|
74
|
-
value = r.is_a?(Hash) ? r[meta[:yaml_key]] : nil
|
|
75
|
-
walk(value, meta[:sub_keys], "#{path}.#{meta[:yaml_key]}") if value.is_a?(Hash)
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def check_publish_block!(entry, path)
|
|
81
|
-
return unless entry.is_a?(Hash) && entry.key?("publish")
|
|
82
|
-
|
|
83
|
-
block = entry["publish"]
|
|
84
|
-
if block.is_a?(Hash)
|
|
85
|
-
raise BadManifest.new(
|
|
86
|
-
"publish: at '#{path}.publish' must be a list of targets (ADR 0094); the map form was retired.",
|
|
87
|
-
)
|
|
88
|
-
end
|
|
89
|
-
raise BadManifest.new("publish: must be a list of targets at '#{path}.publish'") unless block.is_a?(Array)
|
|
90
|
-
|
|
91
|
-
block.each_with_index do |t, i|
|
|
92
|
-
raise BadManifest.new("publish target ##{i} must be a mapping at '#{path}.publish'") unless t.is_a?(Hash)
|
|
93
|
-
|
|
94
|
-
walk(t, %w[to tree template inject_boot], "#{path}.publish[#{i}]")
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def check_single_queue!(raw)
|
|
99
|
-
queues = Array(raw["lanes"]).select { |z| z["kind"] == "queue" }.map { |z| z["name"] }
|
|
100
|
-
return if queues.size <= 1
|
|
101
|
-
|
|
102
|
-
raise BadManifest.new("at most one lane may declare kind: queue (found: #{queues.join(", ")})")
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def check_single_machine!(raw)
|
|
106
|
-
machines = Array(raw["lanes"]).select { |z| z["kind"] == "machine" }.map { |z| z["name"] }
|
|
107
|
-
return if machines.size <= 1
|
|
108
|
-
|
|
109
|
-
raise BadManifest.new("at most one lane may declare kind: machine (found: #{machines.join(", ")})")
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
def walk(hash, allowed, path)
|
|
113
|
-
return unless hash.is_a?(Hash)
|
|
114
|
-
|
|
115
|
-
hash.each_key do |k|
|
|
116
|
-
next if allowed.include?(k)
|
|
117
|
-
|
|
118
|
-
raise BadManifest.new("unknown key '#{k}' at '#{path}'")
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
end
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
module Textus
|
|
2
|
-
class Manifest
|
|
3
|
-
module Schema
|
|
4
|
-
module Semantics
|
|
5
|
-
module Migration
|
|
6
|
-
def check_migration!(raw)
|
|
7
|
-
Array(raw["entries"]).each_with_index do |e, i|
|
|
8
|
-
path = "$.entries[#{i}]"
|
|
9
|
-
check_retired_publish_keys!(e, path)
|
|
10
|
-
check_retired_render_keys!(e, path)
|
|
11
|
-
end
|
|
12
|
-
check_rules_retired_keys!(raw["rules"])
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def check_retired_publish_keys!(entry, path)
|
|
16
|
-
return unless entry.is_a?(Hash)
|
|
17
|
-
|
|
18
|
-
if entry.key?("publish_each")
|
|
19
|
-
raise BadManifest.new(
|
|
20
|
-
"publish_each was removed in 0.42.0 (ADR 0051) at '#{path}' — " \
|
|
21
|
-
"mirror the subtree with `publish: { tree: \"...\" }`.",
|
|
22
|
-
)
|
|
23
|
-
end
|
|
24
|
-
if entry.key?("publish_to")
|
|
25
|
-
raise BadManifest.new(
|
|
26
|
-
"publish_to was replaced by the publish: block in 0.43.0 (ADR 0052) at '#{path}' — " \
|
|
27
|
-
"use `publish: { to: [...] }`.",
|
|
28
|
-
)
|
|
29
|
-
end
|
|
30
|
-
if entry.key?("publish_tree")
|
|
31
|
-
raise BadManifest.new(
|
|
32
|
-
"publish_tree was replaced by the publish: block in 0.43.0 (ADR 0052) at '#{path}' — " \
|
|
33
|
-
"use `publish: { tree: \"...\" }`.",
|
|
34
|
-
)
|
|
35
|
-
end
|
|
36
|
-
return unless entry.key?("index_filename")
|
|
37
|
-
|
|
38
|
-
raise BadManifest.new(
|
|
39
|
-
"index_filename was removed in 0.43.0 (ADR 0053) at '#{path}'.",
|
|
40
|
-
)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def check_retired_render_keys!(entry, path)
|
|
44
|
-
return unless entry.is_a?(Hash)
|
|
45
|
-
|
|
46
|
-
if entry.key?("template")
|
|
47
|
-
raise BadManifest.new(
|
|
48
|
-
"entry-level `template:` was removed at '#{path}' (ADR 0094): rendering is a " \
|
|
49
|
-
"publish concern — `publish: [{ to:, template: }]`.",
|
|
50
|
-
)
|
|
51
|
-
end
|
|
52
|
-
if entry.key?("inject_boot")
|
|
53
|
-
raise BadManifest.new(
|
|
54
|
-
"entry-level `inject_boot:` was removed at '#{path}' (ADR 0094).",
|
|
55
|
-
)
|
|
56
|
-
end
|
|
57
|
-
return unless entry.key?("provenance")
|
|
58
|
-
|
|
59
|
-
raise BadManifest.new("entry-level `provenance:` was removed at '#{path}' (ADR 0094).")
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def check_rules_retired_keys!(rules)
|
|
63
|
-
Array(rules).each_with_index do |r, i|
|
|
64
|
-
path = "$.rules[#{i}]"
|
|
65
|
-
{ "lifecycle" => "age GC moved to `retention:` rule", "materialize" => "removed (ADR 0093)" }
|
|
66
|
-
.each do |old, hint|
|
|
67
|
-
next unless r.is_a?(Hash) && r.key?(old)
|
|
68
|
-
|
|
69
|
-
raise BadManifest.new("`#{old}:` was removed at '#{path}' (ADR 0093) — #{hint}.")
|
|
70
|
-
end
|
|
71
|
-
next unless r.is_a?(Hash) && r.key?("upkeep")
|
|
72
|
-
|
|
73
|
-
raise BadManifest.new(
|
|
74
|
-
"rule key `upkeep:` was removed (ADR 0093): move age-GC to `retention:` " \
|
|
75
|
-
"and production to the entry's `source:`",
|
|
76
|
-
)
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "semantics/invariants"
|
|
4
|
-
require_relative "semantics/migration"
|
|
5
|
-
require_relative "semantics/cross_field"
|
|
6
|
-
|
|
7
|
-
module Textus
|
|
8
|
-
class Manifest
|
|
9
|
-
module Schema
|
|
10
|
-
# Cross-field rules and ADR migration hints. Called by Validator.validate!
|
|
11
|
-
# AFTER the structural dry-schema Contract passes. Operates on the raw hash.
|
|
12
|
-
module Semantics
|
|
13
|
-
extend Invariants
|
|
14
|
-
extend Migration
|
|
15
|
-
extend CrossField
|
|
16
|
-
|
|
17
|
-
module_function
|
|
18
|
-
|
|
19
|
-
def check!(raw)
|
|
20
|
-
check_migration!(raw)
|
|
21
|
-
check_invariants!(raw)
|
|
22
|
-
check_cross_field!(raw)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Textus
|
|
4
|
-
class Manifest
|
|
5
|
-
module Schema
|
|
6
|
-
# Orchestrates structural validation (dry-schema Contract) then cross-field
|
|
7
|
-
# semantic checks (Semantics). Public interface unchanged: Validator.validate!(raw).
|
|
8
|
-
module Validator
|
|
9
|
-
module_function
|
|
10
|
-
|
|
11
|
-
def validate!(raw)
|
|
12
|
-
raise BadManifest.new("manifest must be a hash") unless raw.is_a?(Hash)
|
|
13
|
-
|
|
14
|
-
# Root unknown-key check before Contract so it fires even when lanes: is empty.
|
|
15
|
-
Semantics.walk(raw, ROOT_KEYS, "$")
|
|
16
|
-
|
|
17
|
-
result = Contract.call(raw)
|
|
18
|
-
raise BadManifest.new(format_first_error(result.errors.messages)) unless result.success?
|
|
19
|
-
|
|
20
|
-
raise BadManifest.new("manifest must declare lanes:") if Array(raw["lanes"]).empty?
|
|
21
|
-
|
|
22
|
-
Semantics.check!(raw)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
# Format the first dry-schema error to match the legacy path-prefixed style:
|
|
26
|
-
# "unknown key 'x' at '$.lanes[0]'" for extra-key errors;
|
|
27
|
-
# "manifest structure error at <path>: <msg>" for type/value errors.
|
|
28
|
-
def format_first_error(messages)
|
|
29
|
-
msg = messages.first
|
|
30
|
-
return "manifest structure error: unknown" unless msg
|
|
31
|
-
|
|
32
|
-
parent = format_path(msg.path[0..-2])
|
|
33
|
-
key = msg.path.last
|
|
34
|
-
|
|
35
|
-
if msg.text == "is not allowed"
|
|
36
|
-
"unknown key '#{key}' at '#{parent}'"
|
|
37
|
-
else
|
|
38
|
-
"manifest structure error at #{format_path(msg.path)}: #{msg.text}"
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def format_path(parts)
|
|
43
|
-
"$" + Array(parts).map { |p| p.is_a?(Integer) ? "[#{p}]" : ".#{p}" }.join
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
module Textus
|
|
2
|
-
class Manifest
|
|
3
|
-
module Schema
|
|
4
|
-
# The closed coordination vocabulary (ADR 0028; five in 0033; unified in
|
|
5
|
-
# 0034; the quarantine + derived ZONE-KINDS folded into one `machine` kind
|
|
6
|
-
# in ADR 0091). Each kind pairs with the capability that authorizes
|
|
7
|
-
# originating bytes in it. ONE source of truth; the derived constants below
|
|
8
|
-
# cannot drift. A BIJECTION again (0090 had two kinds → the converge capability; 0091
|
|
9
|
-
# collapses them, so kind ↔ capability is 1:1).
|
|
10
|
-
module Vocabulary
|
|
11
|
-
LANES = {
|
|
12
|
-
"canon" => "author",
|
|
13
|
-
"workspace" => "keep",
|
|
14
|
-
"machine" => "converge",
|
|
15
|
-
"queue" => "propose",
|
|
16
|
-
"raw" => "ingest",
|
|
17
|
-
}.freeze
|
|
18
|
-
|
|
19
|
-
LANE_KINDS = LANES.keys.freeze
|
|
20
|
-
CAPABILITIES = LANES.values.uniq.freeze
|
|
21
|
-
KIND_REQUIRES_VERB = LANES
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
module Textus
|
|
2
|
-
class Manifest
|
|
3
|
-
# The manifest schema. Its data is split across Schema::Vocabulary (the
|
|
4
|
-
# coordination vocabulary) and Schema::Keys (key whitelists + FIELD_REGISTRY)
|
|
5
|
-
# as of ADR 0109; the validation walk lives in Schema::Validator (ADR 0107).
|
|
6
|
-
# The constants are re-exported here so callers keep saying `Schema::LANES`.
|
|
7
|
-
module Schema
|
|
8
|
-
# Re-export the vocabulary.
|
|
9
|
-
LANES = Vocabulary::LANES
|
|
10
|
-
LANE_KINDS = Vocabulary::LANE_KINDS
|
|
11
|
-
CAPABILITIES = Vocabulary::CAPABILITIES
|
|
12
|
-
KIND_REQUIRES_VERB = Vocabulary::KIND_REQUIRES_VERB
|
|
13
|
-
# Re-export the keys + registry.
|
|
14
|
-
ROOT_KEYS = Keys::ROOT_KEYS
|
|
15
|
-
ROLE_KEYS = Keys::ROLE_KEYS
|
|
16
|
-
LANE_KEYS = Keys::LANE_KEYS
|
|
17
|
-
ENTRY_KEYS = Keys::ENTRY_KEYS
|
|
18
|
-
PUBLISH_KEYS = Keys::PUBLISH_KEYS
|
|
19
|
-
SOURCE_KEYS = Keys::SOURCE_KEYS
|
|
20
|
-
RETENTION_KEYS = Keys::RETENTION_KEYS
|
|
21
|
-
AUDIT_KEYS = Keys::AUDIT_KEYS
|
|
22
|
-
FIELD_REGISTRY = Keys::FIELD_REGISTRY
|
|
23
|
-
RULE_KEYS = Keys::RULE_KEYS
|
|
24
|
-
OWNER_SUBJECT_PATTERN = Keys::OWNER_SUBJECT_PATTERN
|
|
25
|
-
|
|
26
|
-
# Public entry point — the validation walk lives in Schema::Validator (ADR 0107).
|
|
27
|
-
def self.validate!(raw) = Validator.validate!(raw)
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|