textus 0.55.2 → 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 +8 -9
- data/lib/textus/artifact.rb +8 -0
- data/lib/textus/errors.rb +0 -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/{dispatch → protocol}/binder.rb +1 -7
- 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/{store → protocol}/freshness/ttl_evaluator.rb +7 -3
- 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 → protocol}/layout.rb +16 -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 +22 -21
- data/lib/textus/surface/cli/sources.rb +1 -3
- data/lib/textus/surface/cli/verb/get.rb +2 -7
- data/lib/textus/surface/cli/verb/init.rb +1 -1
- data/lib/textus/surface/cli/verb/put.rb +7 -7
- 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 +12 -12
- 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/server.rb +35 -24
- 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/value/etag.rb +7 -7
- 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 -53
- 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 -16
- metadata +169 -185
- data/SPEC.md +0 -909
- data/docs/architecture/README.md +0 -273
- data/docs/reference/conventions.md +0 -141
- data/lib/textus/boot.rb +0 -181
- data/lib/textus/dispatch/contracts.rb +0 -63
- data/lib/textus/dispatch/handler_registry.rb +0 -21
- data/lib/textus/dispatch/middleware/audit_index.rb +0 -51
- data/lib/textus/dispatch/middleware/auth.rb +0 -40
- data/lib/textus/dispatch/middleware/base.rb +0 -26
- data/lib/textus/dispatch/middleware/binder.rb +0 -20
- data/lib/textus/dispatch/middleware/cascade.rb +0 -53
- data/lib/textus/dispatch/pipeline.rb +0 -35
- 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/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/scratchpad_sources.rb +0 -55
- 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 -43
- data/lib/textus/doctor/validator.rb +0 -93
- data/lib/textus/doctor.rb +0 -54
- data/lib/textus/format/base.rb +0 -77
- data/lib/textus/format/json.rb +0 -81
- data/lib/textus/format/markdown.rb +0 -59
- data/lib/textus/format/text.rb +0 -55
- data/lib/textus/format/yaml.rb +0 -104
- data/lib/textus/format.rb +0 -61
- data/lib/textus/handlers/maintenance/boot_store.rb +0 -15
- data/lib/textus/handlers/maintenance/doctor_store.rb +0 -15
- data/lib/textus/handlers/maintenance/drain_store.rb +0 -21
- data/lib/textus/handlers/maintenance/ingest_entry.rb +0 -159
- data/lib/textus/handlers/maintenance/jobs_action.rb +0 -21
- data/lib/textus/handlers/maintenance/published_entries.rb +0 -17
- data/lib/textus/handlers/maintenance/rule_explain.rb +0 -77
- data/lib/textus/handlers/maintenance/rule_lint.rb +0 -54
- data/lib/textus/handlers/maintenance/rule_list.rb +0 -32
- data/lib/textus/handlers/maintenance/schema_envelope.rb +0 -19
- data/lib/textus/handlers/read/audit_entries.rb +0 -48
- data/lib/textus/handlers/read/blame_entry.rb +0 -71
- data/lib/textus/handlers/read/deps_entry.rb +0 -17
- data/lib/textus/handlers/read/get_entry.rb +0 -68
- data/lib/textus/handlers/read/list_keys.rb +0 -36
- data/lib/textus/handlers/read/pulse_entries.rb +0 -66
- data/lib/textus/handlers/read/rdeps_entry.rb +0 -21
- data/lib/textus/handlers/read/uid_entry.rb +0 -18
- data/lib/textus/handlers/read/where_entry.rb +0 -18
- data/lib/textus/handlers/write/accept_proposal.rb +0 -39
- data/lib/textus/handlers/write/data_mv.rb +0 -55
- data/lib/textus/handlers/write/delete_key.rb +0 -17
- data/lib/textus/handlers/write/enqueue_job.rb +0 -27
- data/lib/textus/handlers/write/key_delete_prefix.rb +0 -32
- data/lib/textus/handlers/write/key_mv_prefix.rb +0 -45
- data/lib/textus/handlers/write/move_key.rb +0 -80
- data/lib/textus/handlers/write/propose_entry.rb +0 -29
- data/lib/textus/handlers/write/put_entry.rb +0 -29
- data/lib/textus/handlers/write/reject_proposal.rb +0 -29
- 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/predicates/author_held.rb +0 -22
- data/lib/textus/manifest/policy/predicates/etag_match.rb +0 -18
- data/lib/textus/manifest/policy/predicates/fresh_within.rb +0 -13
- data/lib/textus/manifest/policy/predicates/lane_deletable_by.rb +0 -31
- data/lib/textus/manifest/policy/predicates/lane_writable_by.rb +0 -23
- data/lib/textus/manifest/policy/predicates/raw_lane_ingest_only.rb +0 -25
- data/lib/textus/manifest/policy/predicates/raw_write_once.rb +0 -24
- data/lib/textus/manifest/policy/predicates/schema_valid.rb +0 -41
- data/lib/textus/manifest/policy/predicates/target_is_canon.rb +0 -20
- data/lib/textus/manifest/policy/predicates.rb +0 -54
- 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/orchestration.rb +0 -55
- 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.rb +0 -25
- 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 -49
- data/lib/textus/port/storage/interface.rb +0 -17
- data/lib/textus/port/store.rb +0 -149
- data/lib/textus/port/watcher_lock.rb +0 -48
- data/lib/textus/produce/engine.rb +0 -40
- data/lib/textus/produce/publisher.rb +0 -21
- data/lib/textus/produce/render.rb +0 -20
- data/lib/textus/schema/registry.rb +0 -42
- data/lib/textus/schema/tools.rb +0 -108
- data/lib/textus/schema.rb +0 -100
- data/lib/textus/store/container.rb +0 -173
- data/lib/textus/store/cursor.rb +0 -26
- data/lib/textus/store/entry/reader.rb +0 -47
- data/lib/textus/store/entry/writer.rb +0 -219
- data/lib/textus/store/envelope/meta.rb +0 -61
- data/lib/textus/store/freshness/drift_detector.rb +0 -93
- data/lib/textus/store/freshness/evaluator.rb +0 -20
- data/lib/textus/store/freshness/verdict.rb +0 -24
- data/lib/textus/store/freshness.rb +0 -8
- data/lib/textus/store/index/builder.rb +0 -76
- 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 -124
- data/lib/textus/store/jobs/queue.rb +0 -162
- data/lib/textus/store/jobs/registry.rb +0 -19
- data/lib/textus/store/jobs/retention/base.rb +0 -52
- data/lib/textus/store/jobs/retention/sweep.rb +0 -55
- data/lib/textus/store/jobs/retention.rb +0 -8
- data/lib/textus/store/jobs/sweep.rb +0 -21
- data/lib/textus/store/jobs/worker.rb +0 -64
- data/lib/textus/store.rb +0 -122
- data/lib/textus/surface/cli/verb/doctor.rb +0 -20
- 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/projector.rb +0 -20
- data/lib/textus/surface/mcp.rb +0 -8
- data/lib/textus/value/command.rb +0 -16
- data/lib/textus/value/envelope.rb +0 -90
- data/lib/textus/value/result.rb +0 -46
- data/lib/textus/verb_registry.rb +0 -417
- 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,118 +0,0 @@
|
|
|
1
|
-
module Textus
|
|
2
|
-
class Manifest
|
|
3
|
-
class Resolver
|
|
4
|
-
Resolution = ::Data.define(:entry, :path, :remaining)
|
|
5
|
-
|
|
6
|
-
def initialize(data)
|
|
7
|
-
@data = data
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def resolve(key)
|
|
11
|
-
@data.validate_key!(key)
|
|
12
|
-
segments = key.split(".")
|
|
13
|
-
candidates = @data.entries
|
|
14
|
-
.map { |e| [e, e.key.split(".")] }
|
|
15
|
-
.select { |(_, esegs)| esegs == segments[0, esegs.length] }
|
|
16
|
-
.sort_by { |(_, esegs)| -esegs.length }
|
|
17
|
-
raise UnknownKey.new(key, suggestions: suggestions_for(key)) if candidates.empty?
|
|
18
|
-
|
|
19
|
-
entry, esegs = candidates.first
|
|
20
|
-
remaining = segments[esegs.length..]
|
|
21
|
-
build_resolution(entry, remaining, key)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def suggestions_for(key)
|
|
25
|
-
candidates = enumerate.map { |r| r[:key] }
|
|
26
|
-
candidates.concat(@data.entries.reject { |e| nested_entry?(e) }.map(&:key))
|
|
27
|
-
candidates.uniq!
|
|
28
|
-
Key::Distance.suggest(key, candidates, limit: 5)
|
|
29
|
-
rescue StandardError
|
|
30
|
-
[]
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def enumerate(prefix: nil, include_keyless: false)
|
|
34
|
-
out = @data.entries.flat_map do |entry|
|
|
35
|
-
nested_entry?(entry) ? enumerate_nested(entry, include_keyless: include_keyless) : enumerate_leaf(entry)
|
|
36
|
-
end
|
|
37
|
-
out.select! { |row| row[:key] == prefix || row[:key].start_with?("#{prefix}.") } if prefix
|
|
38
|
-
out.sort_by { |row| row[:key] }
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
private
|
|
42
|
-
|
|
43
|
-
# Returns true for entries that behave as nested (Nested subclass, or any
|
|
44
|
-
# entry with nested: true in the raw YAML — e.g. Intake entries covering
|
|
45
|
-
# a directory of leaf files).
|
|
46
|
-
def nested_entry?(entry)
|
|
47
|
-
entry.nested?
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def build_resolution(entry, remaining, key)
|
|
51
|
-
if remaining.empty?
|
|
52
|
-
Resolution.new(entry: entry, path: resolve_leaf_path(entry), remaining: [])
|
|
53
|
-
else
|
|
54
|
-
raise UnknownKey.new(key, suggestions: suggestions_for(key)) unless nested_entry?(entry)
|
|
55
|
-
|
|
56
|
-
primary_ext = Textus::Format.for(entry.format).extensions.first
|
|
57
|
-
base = Textus::Key::Path.normalize_relative_path(entry.path)
|
|
58
|
-
path = File.join(@data.root, base, *remaining) + primary_ext
|
|
59
|
-
Resolution.new(entry: entry, path: path, remaining: remaining)
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def enumerate_leaf(entry)
|
|
64
|
-
fp = resolve_leaf_path(entry)
|
|
65
|
-
File.exist?(fp) ? [{ key: entry.key, path: fp, manifest_entry: entry }] : []
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def enumerate_nested(entry, include_keyless: false)
|
|
69
|
-
# publish_tree mirrors opaque payload by path — its files are never
|
|
70
|
-
# enumerated as keys (ADR 0047). Ask the resolved mode, not the path.
|
|
71
|
-
# The `include_keyless:` override is used only by the projection lister
|
|
72
|
-
# so that `from: project` selects can read source data from keyless
|
|
73
|
-
# nested entries (e.g. knowledge.decisions) without exposing them as
|
|
74
|
-
# addressable store keys in the public `list` surface.
|
|
75
|
-
return [] if entry.publish_mode.keyless? && !include_keyless
|
|
76
|
-
|
|
77
|
-
base = File.join(@data.root, Textus::Key::Path.normalize_relative_path(entry.path))
|
|
78
|
-
return [] unless File.directory?(base)
|
|
79
|
-
|
|
80
|
-
Dir.glob(File.join(base, nested_glob(entry.format)))
|
|
81
|
-
.filter_map { |path| nested_row_for(entry, base, path) }
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def nested_row_for(entry, base, path)
|
|
85
|
-
rel = path.sub(%r{\A#{Regexp.escape(base)}/?}, "")
|
|
86
|
-
return nil if entry.ignored?(rel)
|
|
87
|
-
|
|
88
|
-
stripped = rel.sub(/#{Regexp.escape(File.extname(rel))}\z/, "")
|
|
89
|
-
segs = stripped.split("/").reject { |s| s.empty? || s == "." }
|
|
90
|
-
return nil if segs.empty?
|
|
91
|
-
|
|
92
|
-
illegal = segs.find { |s| !valid_segment?(s) }
|
|
93
|
-
if illegal
|
|
94
|
-
warn("textus: skipping illegal key segment '#{illegal}' at #{path} — " \
|
|
95
|
-
"rename to match [a-z0-9][a-z0-9-]* (run 'textus doctor' for the full list)")
|
|
96
|
-
return nil
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
{ key: (entry.key.split(".") + segs).join("."), path: path, manifest_entry: entry }
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
def valid_segment?(seg)
|
|
103
|
-
return false if seg.nil? || seg.empty?
|
|
104
|
-
return false if seg.length > Key::Grammar::MAX_SEGMENT_LEN
|
|
105
|
-
|
|
106
|
-
seg.match?(Key::Grammar::SEGMENT)
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def resolve_leaf_path(entry)
|
|
110
|
-
Textus::Key::Path.resolve(@data, entry)
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
def nested_glob(format)
|
|
114
|
-
Textus::Format.for(format).nested_glob
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
end
|
|
@@ -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
|