textus 0.54.2 → 0.55.2
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 +38 -1
- data/README.md +17 -10
- data/SPEC.md +39 -11
- data/docs/architecture/README.md +23 -11
- data/docs/reference/conventions.md +5 -2
- data/exe/textus +1 -1
- data/lib/textus/boot.rb +64 -93
- data/lib/textus/dispatch/binder.rb +48 -0
- data/lib/textus/dispatch/contracts.rb +63 -0
- data/lib/textus/dispatch/handler_registry.rb +21 -0
- data/lib/textus/dispatch/middleware/audit_index.rb +51 -0
- data/lib/textus/dispatch/middleware/auth.rb +40 -0
- data/lib/textus/dispatch/middleware/base.rb +26 -0
- data/lib/textus/dispatch/middleware/binder.rb +20 -0
- data/lib/textus/dispatch/middleware/cascade.rb +53 -0
- data/lib/textus/dispatch/pipeline.rb +35 -0
- data/lib/textus/doctor/check/audit_log.rb +2 -2
- data/lib/textus/doctor/check/generator_drift.rb +4 -4
- data/lib/textus/doctor/check/orphaned_publish_targets.rb +3 -3
- data/lib/textus/doctor/check/protocol_version.rb +2 -2
- data/lib/textus/doctor/check/raw_asset_paths.rb +1 -1
- data/lib/textus/doctor/check/schema_parse_error.rb +1 -1
- data/lib/textus/doctor/check/schema_violations.rb +2 -2
- data/lib/textus/doctor/check/schemas.rb +1 -1
- data/lib/textus/doctor/check/{notebook_sources.rb → scratchpad_sources.rb} +10 -5
- data/lib/textus/doctor/check/sentinels.rb +4 -4
- data/lib/textus/doctor/check/templates.rb +1 -1
- data/lib/textus/doctor/check/unowned_schema_fields.rb +1 -1
- data/lib/textus/doctor/check.rb +9 -10
- data/lib/textus/doctor.rb +2 -2
- data/lib/textus/errors.rb +8 -0
- data/lib/textus/format/base.rb +34 -10
- data/lib/textus/format/json.rb +5 -27
- data/lib/textus/format/markdown.rb +5 -27
- data/lib/textus/format/text.rb +5 -4
- data/lib/textus/format/yaml.rb +30 -27
- data/lib/textus/format.rb +22 -1
- data/lib/textus/handlers/maintenance/boot_store.rb +15 -0
- data/lib/textus/handlers/maintenance/doctor_store.rb +15 -0
- data/lib/textus/handlers/maintenance/drain_store.rb +21 -0
- data/lib/textus/handlers/maintenance/ingest_entry.rb +159 -0
- data/lib/textus/handlers/maintenance/jobs_action.rb +21 -0
- data/lib/textus/handlers/maintenance/published_entries.rb +17 -0
- data/lib/textus/handlers/maintenance/rule_explain.rb +77 -0
- data/lib/textus/handlers/maintenance/rule_lint.rb +54 -0
- data/lib/textus/handlers/maintenance/rule_list.rb +32 -0
- data/lib/textus/handlers/maintenance/schema_envelope.rb +19 -0
- data/lib/textus/handlers/read/audit_entries.rb +48 -0
- data/lib/textus/handlers/read/blame_entry.rb +71 -0
- data/lib/textus/handlers/read/deps_entry.rb +17 -0
- data/lib/textus/handlers/read/get_entry.rb +68 -0
- data/lib/textus/handlers/read/list_keys.rb +36 -0
- data/lib/textus/handlers/read/pulse_entries.rb +66 -0
- data/lib/textus/handlers/read/rdeps_entry.rb +21 -0
- data/lib/textus/handlers/read/uid_entry.rb +18 -0
- data/lib/textus/handlers/read/where_entry.rb +18 -0
- data/lib/textus/handlers/write/accept_proposal.rb +39 -0
- data/lib/textus/handlers/write/data_mv.rb +55 -0
- data/lib/textus/handlers/write/delete_key.rb +17 -0
- data/lib/textus/handlers/write/enqueue_job.rb +27 -0
- data/lib/textus/handlers/write/key_delete_prefix.rb +32 -0
- data/lib/textus/handlers/write/key_mv_prefix.rb +45 -0
- data/lib/textus/handlers/write/move_key.rb +80 -0
- data/lib/textus/handlers/write/propose_entry.rb +29 -0
- data/lib/textus/handlers/write/put_entry.rb +29 -0
- data/lib/textus/handlers/write/reject_proposal.rb +29 -0
- data/lib/textus/init.rb +5 -7
- data/lib/textus/jobs.rb +3 -9
- data/lib/textus/manifest/capabilities.rb +4 -4
- data/lib/textus/manifest/entry/base.rb +3 -3
- data/lib/textus/manifest/entry/publish/subtree_mirror.rb +2 -2
- data/lib/textus/manifest/entry/publish/to_paths.rb +2 -2
- data/lib/textus/manifest/policy/predicates/author_held.rb +22 -0
- data/lib/textus/manifest/policy/predicates/etag_match.rb +18 -0
- data/lib/textus/manifest/policy/predicates/fresh_within.rb +13 -0
- data/lib/textus/manifest/policy/predicates/lane_deletable_by.rb +31 -0
- data/lib/textus/manifest/policy/predicates/lane_writable_by.rb +23 -0
- data/lib/textus/manifest/policy/predicates/raw_lane_ingest_only.rb +25 -0
- data/lib/textus/manifest/policy/predicates/raw_write_once.rb +24 -0
- data/lib/textus/manifest/policy/predicates/schema_valid.rb +41 -0
- data/lib/textus/manifest/policy/predicates/target_is_canon.rb +20 -0
- data/lib/textus/manifest/policy/predicates.rb +54 -0
- data/lib/textus/manifest/policy/retention.rb +1 -1
- data/lib/textus/manifest/schema/semantics/cross_field.rb +53 -0
- data/lib/textus/manifest/schema/semantics/invariants.rb +125 -0
- data/lib/textus/manifest/schema/semantics/migration.rb +83 -0
- data/lib/textus/manifest/schema/semantics.rb +11 -216
- data/lib/textus/orchestration.rb +55 -0
- data/lib/textus/{ports → port}/audit_log.rb +46 -6
- data/lib/textus/{ports → port}/build_lock.rb +2 -2
- data/lib/textus/{ports → port}/clock.rb +1 -1
- data/lib/textus/{ports → port}/publisher.rb +5 -5
- data/lib/textus/{core → port}/sentinel.rb +1 -6
- data/lib/textus/{ports → port}/sentinel_store.rb +4 -4
- data/lib/textus/{ports → port}/storage/file_stat.rb +1 -1
- data/lib/textus/port/storage/file_store.rb +49 -0
- data/lib/textus/port/storage/interface.rb +17 -0
- data/lib/textus/port/store.rb +149 -0
- data/lib/textus/{ports → port}/watcher_lock.rb +3 -3
- data/lib/textus/produce/engine.rb +1 -11
- data/lib/textus/produce/publisher.rb +21 -0
- data/lib/textus/schema/registry.rb +42 -0
- data/lib/textus/schema/tools.rb +7 -10
- data/lib/textus/store/container.rb +173 -0
- data/lib/textus/store/cursor.rb +26 -0
- data/lib/textus/store/entry/reader.rb +47 -0
- data/lib/textus/store/entry/writer.rb +219 -0
- data/lib/textus/store/envelope/meta.rb +61 -0
- data/lib/textus/store/freshness/drift_detector.rb +93 -0
- data/lib/textus/store/freshness/evaluator.rb +20 -0
- data/lib/textus/store/freshness/ttl_evaluator.rb +57 -0
- data/lib/textus/{core → store}/freshness/verdict.rb +1 -11
- data/lib/textus/store/freshness.rb +8 -0
- data/lib/textus/store/index/builder.rb +76 -0
- data/lib/textus/store/index/lookup.rb +60 -0
- data/lib/textus/store/jobs/base.rb +13 -0
- data/lib/textus/store/jobs/index.rb +15 -0
- data/lib/textus/store/jobs/materialize.rb +15 -0
- data/lib/textus/store/jobs/plan.rb +11 -0
- data/lib/textus/store/jobs/planner.rb +124 -0
- data/lib/textus/store/jobs/queue.rb +162 -0
- data/lib/textus/store/jobs/registry.rb +19 -0
- data/lib/textus/store/jobs/retention/base.rb +52 -0
- data/lib/textus/store/jobs/retention/sweep.rb +55 -0
- data/lib/textus/store/jobs/retention.rb +8 -0
- data/lib/textus/store/jobs/sweep.rb +21 -0
- data/lib/textus/store/jobs/worker.rb +64 -0
- data/lib/textus/store/layout.rb +97 -0
- data/lib/textus/store.rb +63 -32
- data/lib/textus/{surfaces → surface}/cli/group/data.rb +1 -1
- data/lib/textus/{surfaces → surface}/cli/group/key.rb +1 -1
- data/lib/textus/{surfaces → surface}/cli/group/mcp.rb +1 -1
- data/lib/textus/{surfaces → surface}/cli/group/rule.rb +1 -1
- data/lib/textus/{surfaces → surface}/cli/group/schema.rb +1 -1
- data/lib/textus/{surfaces → surface}/cli/group.rb +2 -2
- data/lib/textus/{surfaces → surface}/cli/runner.rb +14 -68
- data/lib/textus/surface/cli/sources.rb +41 -0
- data/lib/textus/{surfaces → surface}/cli/verb/doctor.rb +5 -6
- data/lib/textus/{surfaces → surface}/cli/verb/get.rb +7 -5
- data/lib/textus/{surfaces → surface}/cli/verb/init.rb +1 -1
- data/lib/textus/{surfaces → surface}/cli/verb/mcp_serve.rb +3 -3
- data/lib/textus/surface/cli/verb/put.rb +27 -0
- data/lib/textus/{surfaces → surface}/cli/verb/schema_diff.rb +1 -1
- data/lib/textus/{surfaces → surface}/cli/verb/schema_init.rb +1 -1
- data/lib/textus/{surfaces → surface}/cli/verb/schema_migrate.rb +1 -1
- data/lib/textus/{surfaces → surface}/cli/verb/watch.rb +2 -2
- data/lib/textus/{surfaces → surface}/cli/verb.rb +3 -8
- data/lib/textus/{surfaces → surface}/cli.rb +1 -1
- data/lib/textus/surface/mcp/catalog.rb +58 -0
- data/lib/textus/{surfaces → surface}/mcp/errors.rb +1 -11
- data/lib/textus/surface/mcp/projector.rb +20 -0
- data/lib/textus/{surfaces → surface}/mcp/server.rb +24 -35
- data/lib/textus/{surfaces → surface}/mcp.rb +2 -2
- data/lib/textus/{surfaces → surface}/watcher.rb +8 -8
- data/lib/textus/value/call.rb +30 -0
- data/lib/textus/value/command.rb +16 -0
- data/lib/textus/{core → value}/duration.rb +1 -4
- data/lib/textus/value/envelope.rb +90 -0
- data/lib/textus/value/etag.rb +39 -0
- data/lib/textus/value/payload.rb +7 -0
- data/lib/textus/value/result.rb +46 -0
- data/lib/textus/value/role.rb +38 -0
- data/lib/textus/value/types.rb +13 -0
- data/lib/textus/{uid.rb → value/uid.rb} +9 -7
- data/lib/textus/verb_registry.rb +417 -0
- data/lib/textus/version.rb +1 -1
- data/lib/textus/workflow/loader.rb +4 -4
- data/lib/textus/workflow/runner.rb +11 -33
- data/lib/textus.rb +4 -69
- metadata +142 -105
- data/lib/textus/action/accept.rb +0 -44
- data/lib/textus/action/audit.rb +0 -131
- data/lib/textus/action/base.rb +0 -42
- data/lib/textus/action/blame.rb +0 -97
- data/lib/textus/action/boot.rb +0 -17
- data/lib/textus/action/data_mv.rb +0 -69
- data/lib/textus/action/deps.rb +0 -34
- data/lib/textus/action/doctor.rb +0 -24
- data/lib/textus/action/drain.rb +0 -39
- data/lib/textus/action/enqueue.rb +0 -53
- data/lib/textus/action/get.rb +0 -78
- data/lib/textus/action/ingest.rb +0 -203
- data/lib/textus/action/jobs.rb +0 -36
- data/lib/textus/action/key_delete.rb +0 -36
- data/lib/textus/action/key_delete_prefix.rb +0 -44
- data/lib/textus/action/key_mv.rb +0 -129
- data/lib/textus/action/key_mv_prefix.rb +0 -57
- data/lib/textus/action/list.rb +0 -42
- data/lib/textus/action/propose.rb +0 -52
- data/lib/textus/action/published.rb +0 -24
- data/lib/textus/action/pulse.rb +0 -56
- data/lib/textus/action/put.rb +0 -52
- data/lib/textus/action/rdeps.rb +0 -39
- data/lib/textus/action/reject.rb +0 -37
- data/lib/textus/action/rule_explain.rb +0 -91
- data/lib/textus/action/rule_lint.rb +0 -68
- data/lib/textus/action/rule_list.rb +0 -42
- data/lib/textus/action/schema_envelope.rb +0 -29
- data/lib/textus/action/uid.rb +0 -33
- data/lib/textus/action/where.rb +0 -36
- data/lib/textus/action/write_verb.rb +0 -44
- data/lib/textus/call.rb +0 -28
- data/lib/textus/command.rb +0 -41
- data/lib/textus/container.rb +0 -26
- data/lib/textus/contract/around.rb +0 -29
- data/lib/textus/contract/binder.rb +0 -88
- data/lib/textus/contract/resources/build_lock.rb +0 -17
- data/lib/textus/contract/resources/cursor.rb +0 -26
- data/lib/textus/contract/sources.rb +0 -39
- data/lib/textus/contract/view.rb +0 -15
- data/lib/textus/contract.rb +0 -174
- data/lib/textus/core/freshness/evaluator.rb +0 -150
- 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/cursor_store.rb +0 -24
- data/lib/textus/envelope/reader.rb +0 -46
- data/lib/textus/envelope/writer.rb +0 -209
- data/lib/textus/envelope.rb +0 -79
- data/lib/textus/etag.rb +0 -36
- data/lib/textus/gate/auth.rb +0 -227
- data/lib/textus/gate.rb +0 -116
- data/lib/textus/jobs/base.rb +0 -23
- data/lib/textus/jobs/materialize.rb +0 -20
- data/lib/textus/jobs/plan.rb +0 -9
- data/lib/textus/jobs/planner.rb +0 -101
- data/lib/textus/jobs/retention.rb +0 -48
- data/lib/textus/jobs/sweep.rb +0 -27
- data/lib/textus/jobs/worker.rb +0 -67
- data/lib/textus/layout.rb +0 -91
- data/lib/textus/ports/job_store/job.rb +0 -65
- data/lib/textus/ports/job_store.rb +0 -123
- data/lib/textus/ports/raw_index.rb +0 -61
- data/lib/textus/ports/storage/file_store.rb +0 -26
- data/lib/textus/role.rb +0 -36
- data/lib/textus/schemas.rb +0 -54
- data/lib/textus/session.rb +0 -35
- data/lib/textus/surfaces/cli/verb/put.rb +0 -30
- data/lib/textus/surfaces/mcp/catalog.rb +0 -111
- data/lib/textus/surfaces/role_scope.rb +0 -34
- data/lib/textus/types.rb +0 -15
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module Textus
|
|
2
|
+
class Manifest
|
|
3
|
+
class Policy
|
|
4
|
+
module Predicates
|
|
5
|
+
class SchemaValid
|
|
6
|
+
def self.call(manifest:, actor:, action:, key:, schemas: nil, envelope: nil, extra: {})
|
|
7
|
+
return { pass: true } unless envelope
|
|
8
|
+
return { pass: true } if key.nil?
|
|
9
|
+
|
|
10
|
+
mentry = manifest.resolver.resolve(key).entry
|
|
11
|
+
schema_ref = mentry.schema
|
|
12
|
+
return { pass: true } unless schema_ref
|
|
13
|
+
return { pass: true } unless schemas
|
|
14
|
+
|
|
15
|
+
schema = schemas.fetch_or_nil(schema_ref)
|
|
16
|
+
return { pass: true } unless schema
|
|
17
|
+
|
|
18
|
+
frontmatter = envelope.meta&.dig("_meta") || envelope.meta || {}
|
|
19
|
+
begin
|
|
20
|
+
schema.validate!(frontmatter)
|
|
21
|
+
{ pass: true }
|
|
22
|
+
rescue Textus::SchemaViolation => e
|
|
23
|
+
{ pass: false, reason: schema_reason(e) }
|
|
24
|
+
end
|
|
25
|
+
rescue Textus::UnknownKey
|
|
26
|
+
{ pass: true }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.schema_reason(err)
|
|
30
|
+
d = err.details
|
|
31
|
+
return err.message.dup unless d.is_a?(Hash)
|
|
32
|
+
return "missing required fields: #{Array(d["missing"]).join(", ")}" if d["missing"]
|
|
33
|
+
return "field '#{d["field"]}': #{d["reason"]}" if d["field"]
|
|
34
|
+
|
|
35
|
+
err.message.dup
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Textus
|
|
2
|
+
class Manifest
|
|
3
|
+
class Policy
|
|
4
|
+
module Predicates
|
|
5
|
+
class TargetIsCanon
|
|
6
|
+
def self.call(manifest:, actor:, action:, key:, schemas: nil, envelope: nil, extra: {})
|
|
7
|
+
return { pass: true } if key.nil?
|
|
8
|
+
|
|
9
|
+
mentry = manifest.resolver.resolve(key).entry
|
|
10
|
+
kind = manifest.policy.declared_kind(mentry.lane.to_s)
|
|
11
|
+
pass = kind == :canon
|
|
12
|
+
{ pass:, reason: pass ? nil : "target lane '#{mentry.lane}' is not canon (kind: #{kind})" }
|
|
13
|
+
rescue Textus::UnknownKey
|
|
14
|
+
{ pass: true }
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
module Textus
|
|
2
|
+
class Manifest
|
|
3
|
+
class Policy
|
|
4
|
+
module Predicates
|
|
5
|
+
FLOOR = {
|
|
6
|
+
put: %w[lane_writable_by raw_lane_ingest_only],
|
|
7
|
+
key_delete: %w[lane_deletable_by],
|
|
8
|
+
key_mv: %w[lane_writable_by raw_lane_ingest_only],
|
|
9
|
+
accept: %w[author_held],
|
|
10
|
+
reject: %w[author_held],
|
|
11
|
+
propose: %w[lane_writable_by raw_lane_ingest_only],
|
|
12
|
+
key_mv_prefix: %w[lane_writable_by raw_lane_ingest_only],
|
|
13
|
+
key_delete_prefix: %w[lane_writable_by raw_lane_ingest_only],
|
|
14
|
+
ingest: %w[lane_writable_by raw_write_once],
|
|
15
|
+
}.freeze
|
|
16
|
+
|
|
17
|
+
CLASSES = {
|
|
18
|
+
"lane_writable_by" => "LaneWritableBy",
|
|
19
|
+
"author_held" => "AuthorHeld",
|
|
20
|
+
"target_is_canon" => "TargetIsCanon",
|
|
21
|
+
"etag_match" => "EtagMatch",
|
|
22
|
+
"schema_valid" => "SchemaValid",
|
|
23
|
+
"fresh_within" => "FreshWithin",
|
|
24
|
+
"raw_lane_ingest_only" => "RawLaneIngestOnly",
|
|
25
|
+
"raw_write_once" => "RawWriteOnce",
|
|
26
|
+
"lane_deletable_by" => "LaneDeletableBy",
|
|
27
|
+
}.freeze
|
|
28
|
+
|
|
29
|
+
module_function
|
|
30
|
+
|
|
31
|
+
def by_name(name)
|
|
32
|
+
short = CLASSES.fetch(name.to_s) do
|
|
33
|
+
raise Textus::UsageError.new("unknown predicate '#{name}'")
|
|
34
|
+
end
|
|
35
|
+
const_get(short)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def evaluate(manifest:, action:, actor:, key:, schemas: nil, envelope: nil, extra: {}, rule_predicates: [])
|
|
39
|
+
failures = []
|
|
40
|
+
(FLOOR.fetch(action, []) + rule_predicates).uniq.each do |pred_name|
|
|
41
|
+
result = by_name(pred_name).call(
|
|
42
|
+
manifest:, schemas:, actor:, action:, key:, envelope:, extra:,
|
|
43
|
+
)
|
|
44
|
+
next if result[:pass]
|
|
45
|
+
raise result[:error] if result[:error]
|
|
46
|
+
|
|
47
|
+
failures << [pred_name, result[:reason]]
|
|
48
|
+
end
|
|
49
|
+
raise Textus::GuardFailed.new(failures) unless failures.empty?
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -21,7 +21,7 @@ module Textus
|
|
|
21
21
|
raise Textus::BadManifest.new("retention action must be one of #{ACTIONS.join("|")}, got #{raw["action"].inspect}")
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
def ttl_seconds = Textus::
|
|
24
|
+
def ttl_seconds = Textus::Value::Duration.seconds(@ttl)
|
|
25
25
|
def destructive? = true
|
|
26
26
|
end
|
|
27
27
|
end
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
|
@@ -0,0 +1,125 @@
|
|
|
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
|
|
@@ -0,0 +1,83 @@
|
|
|
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,230 +1,25 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "semantics/invariants"
|
|
4
|
+
require_relative "semantics/migration"
|
|
5
|
+
require_relative "semantics/cross_field"
|
|
6
|
+
|
|
3
7
|
module Textus
|
|
4
8
|
class Manifest
|
|
5
9
|
module Schema
|
|
6
10
|
# Cross-field rules and ADR migration hints. Called by Validator.validate!
|
|
7
11
|
# AFTER the structural dry-schema Contract passes. Operates on the raw hash.
|
|
8
12
|
module Semantics
|
|
13
|
+
extend Invariants
|
|
14
|
+
extend Migration
|
|
15
|
+
extend CrossField
|
|
16
|
+
|
|
9
17
|
module_function
|
|
10
18
|
|
|
11
19
|
def check!(raw)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
check_owners!(raw["lanes"], raw["entries"])
|
|
16
|
-
check_rules!(raw["rules"])
|
|
17
|
-
check_single_queue!(raw)
|
|
18
|
-
check_single_machine!(raw)
|
|
19
|
-
check_lane_kind_consistency!(raw)
|
|
20
|
-
walk(raw["audit"], AUDIT_KEYS, "$.audit") if raw["audit"].is_a?(Hash)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def check_roles!(roles)
|
|
24
|
-
return if roles.nil?
|
|
25
|
-
|
|
26
|
-
roles.each_with_index do |r, i|
|
|
27
|
-
path = "$.roles[#{i}]"
|
|
28
|
-
name = r["name"]
|
|
29
|
-
unless Textus::Role::NAMES.include?(name)
|
|
30
|
-
raise BadManifest.new(
|
|
31
|
-
"unknown role name '#{name}' at '#{path}' (allowed: #{Textus::Role::NAMES.join(", ")})",
|
|
32
|
-
)
|
|
33
|
-
end
|
|
34
|
-
Array(r["can"]).each do |verb|
|
|
35
|
-
next if CAPABILITIES.include?(verb)
|
|
36
|
-
|
|
37
|
-
hint = %w[ingest fetch].include?(verb) ? " — the quarantine capability folded into 'converge' (ADR 0090)" : ""
|
|
38
|
-
raise BadManifest.new(
|
|
39
|
-
"unknown capability '#{verb}' for role '#{name}' at '#{path}' " \
|
|
40
|
-
"(known: #{CAPABILITIES.join(", ")})#{hint}",
|
|
41
|
-
)
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
author_holders = roles.count { |r| Array(r["can"]).include?("author") }
|
|
46
|
-
return if author_holders <= 1
|
|
47
|
-
|
|
48
|
-
raise BadManifest.new(
|
|
49
|
-
"manifest declares #{author_holders} roles with the author capability; at most one is allowed",
|
|
50
|
-
)
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def check_lanes!(lanes)
|
|
54
|
-
Array(lanes).each_with_index do |z, i|
|
|
55
|
-
walk(z, LANE_KEYS, "$.lanes[#{i}]")
|
|
56
|
-
next unless %w[quarantine derived].include?(z["kind"])
|
|
57
|
-
|
|
58
|
-
raise BadManifest.new(
|
|
59
|
-
"lane kind '#{z["kind"]}' at '$.lanes[#{i}]' was folded into 'machine' (ADR 0091) — " \
|
|
60
|
-
"use `kind: machine`",
|
|
61
|
-
)
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def check_entries!(entries)
|
|
66
|
-
Array(entries).each_with_index do |e, i|
|
|
67
|
-
path = "$.entries[#{i}]"
|
|
68
|
-
check_retired_publish_keys!(e, path)
|
|
69
|
-
check_retired_render_keys!(e, path)
|
|
70
|
-
walk(e, ENTRY_KEYS, path)
|
|
71
|
-
check_publish_block!(e, path)
|
|
72
|
-
walk(e["source"], SOURCE_KEYS, "#{path}.source") if e.is_a?(Hash) && e["source"].is_a?(Hash)
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def check_retired_publish_keys!(entry, path)
|
|
77
|
-
return unless entry.is_a?(Hash)
|
|
78
|
-
|
|
79
|
-
if entry.key?("publish_each")
|
|
80
|
-
raise BadManifest.new(
|
|
81
|
-
"publish_each was removed in 0.42.0 (ADR 0051) at '#{path}' — " \
|
|
82
|
-
"mirror the subtree with `publish: { tree: \"...\" }`.",
|
|
83
|
-
)
|
|
84
|
-
end
|
|
85
|
-
if entry.key?("publish_to")
|
|
86
|
-
raise BadManifest.new(
|
|
87
|
-
"publish_to was replaced by the publish: block in 0.43.0 (ADR 0052) at '#{path}' — " \
|
|
88
|
-
"use `publish: { to: [...] }`.",
|
|
89
|
-
)
|
|
90
|
-
end
|
|
91
|
-
if entry.key?("publish_tree")
|
|
92
|
-
raise BadManifest.new(
|
|
93
|
-
"publish_tree was replaced by the publish: block in 0.43.0 (ADR 0052) at '#{path}' — " \
|
|
94
|
-
"use `publish: { tree: \"...\" }`.",
|
|
95
|
-
)
|
|
96
|
-
end
|
|
97
|
-
return unless entry.key?("index_filename")
|
|
98
|
-
|
|
99
|
-
raise BadManifest.new(
|
|
100
|
-
"index_filename was removed in 0.43.0 (ADR 0053) at '#{path}'.",
|
|
101
|
-
)
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
def check_retired_render_keys!(entry, path)
|
|
105
|
-
return unless entry.is_a?(Hash)
|
|
106
|
-
|
|
107
|
-
if entry.key?("template")
|
|
108
|
-
raise BadManifest.new(
|
|
109
|
-
"entry-level `template:` was removed at '#{path}' (ADR 0094): rendering is a " \
|
|
110
|
-
"publish concern — `publish: [{ to:, template: }]`.",
|
|
111
|
-
)
|
|
112
|
-
end
|
|
113
|
-
if entry.key?("inject_boot")
|
|
114
|
-
raise BadManifest.new(
|
|
115
|
-
"entry-level `inject_boot:` was removed at '#{path}' (ADR 0094).",
|
|
116
|
-
)
|
|
117
|
-
end
|
|
118
|
-
return unless entry.key?("provenance")
|
|
119
|
-
|
|
120
|
-
raise BadManifest.new("entry-level `provenance:` was removed at '#{path}' (ADR 0094).")
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
def check_publish_block!(entry, path)
|
|
124
|
-
return unless entry.is_a?(Hash) && entry.key?("publish")
|
|
125
|
-
|
|
126
|
-
block = entry["publish"]
|
|
127
|
-
if block.is_a?(Hash)
|
|
128
|
-
raise BadManifest.new(
|
|
129
|
-
"publish: at '#{path}.publish' must be a list of targets (ADR 0094); the map form was retired.",
|
|
130
|
-
)
|
|
131
|
-
end
|
|
132
|
-
raise BadManifest.new("publish: must be a list of targets at '#{path}.publish'") unless block.is_a?(Array)
|
|
133
|
-
|
|
134
|
-
block.each_with_index do |t, i|
|
|
135
|
-
raise BadManifest.new("publish target ##{i} must be a mapping at '#{path}.publish'") unless t.is_a?(Hash)
|
|
136
|
-
|
|
137
|
-
walk(t, %w[to tree template inject_boot], "#{path}.publish[#{i}]")
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
def check_owners!(lanes, entries)
|
|
142
|
-
Array(lanes).each_with_index { |z, i| check_owner!(z["owner"], "$.lanes[#{i}]") }
|
|
143
|
-
Array(entries).each_with_index { |e, i| check_owner!(e["owner"], "$.entries[#{i}]") }
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
def check_owner!(owner, path)
|
|
147
|
-
return if owner.nil?
|
|
148
|
-
return if valid_owner?(owner)
|
|
149
|
-
|
|
150
|
-
raise BadManifest.new(
|
|
151
|
-
"invalid owner '#{owner}' at '#{path}' " \
|
|
152
|
-
"(expected <archetype> or <archetype>:<subject>, archetype one of: #{Textus::Role::NAMES.join(", ")})",
|
|
153
|
-
)
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
def valid_owner?(token)
|
|
157
|
-
return false unless token.is_a?(String) && !token.empty?
|
|
158
|
-
|
|
159
|
-
archetype, subject = token.split(":", 2)
|
|
160
|
-
return false unless Textus::Role::NAMES.include?(archetype)
|
|
161
|
-
return true if subject.nil?
|
|
162
|
-
|
|
163
|
-
OWNER_SUBJECT_PATTERN.match?(subject)
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
def check_rules!(rules)
|
|
167
|
-
Array(rules).each_with_index do |r, i|
|
|
168
|
-
path = "$.rules[#{i}]"
|
|
169
|
-
# Check retired keys BEFORE the generic walk so specific hints fire first.
|
|
170
|
-
{ "lifecycle" => "age GC moved to `retention:` rule", "materialize" => "removed (ADR 0093)" }
|
|
171
|
-
.each do |old, hint|
|
|
172
|
-
next unless r.is_a?(Hash) && r.key?(old)
|
|
173
|
-
|
|
174
|
-
raise BadManifest.new("`#{old}:` was removed at '#{path}' (ADR 0093) — #{hint}.")
|
|
175
|
-
end
|
|
176
|
-
if r.is_a?(Hash) && r.key?("upkeep")
|
|
177
|
-
raise BadManifest.new(
|
|
178
|
-
"rule key `upkeep:` was removed (ADR 0093): move age-GC to `retention:` " \
|
|
179
|
-
"and production to the entry's `source:`",
|
|
180
|
-
)
|
|
181
|
-
end
|
|
182
|
-
walk(r, RULE_KEYS, path)
|
|
183
|
-
FIELD_REGISTRY.each_value do |meta|
|
|
184
|
-
next unless meta[:sub_keys]
|
|
185
|
-
|
|
186
|
-
value = r.is_a?(Hash) ? r[meta[:yaml_key]] : nil
|
|
187
|
-
walk(value, meta[:sub_keys], "#{path}.#{meta[:yaml_key]}") if value.is_a?(Hash)
|
|
188
|
-
end
|
|
189
|
-
end
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
def check_single_queue!(raw)
|
|
193
|
-
queues = Array(raw["lanes"]).select { |z| z["kind"] == "queue" }.map { |z| z["name"] }
|
|
194
|
-
return if queues.size <= 1
|
|
195
|
-
|
|
196
|
-
raise BadManifest.new("at most one lane may declare kind: queue (found: #{queues.join(", ")})")
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
def check_single_machine!(raw)
|
|
200
|
-
machines = Array(raw["lanes"]).select { |z| z["kind"] == "machine" }.map { |z| z["name"] }
|
|
201
|
-
return if machines.size <= 1
|
|
202
|
-
|
|
203
|
-
raise BadManifest.new("at most one lane may declare kind: machine (found: #{machines.join(", ")})")
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
def check_lane_kind_consistency!(raw)
|
|
207
|
-
held = Capabilities.resolve(raw["roles"]).values.flatten.uniq
|
|
208
|
-
|
|
209
|
-
Array(raw["lanes"]).each_with_index do |z, i|
|
|
210
|
-
verb = KIND_REQUIRES_VERB[z["kind"]]
|
|
211
|
-
next if verb.nil? || held.include?(verb)
|
|
212
|
-
|
|
213
|
-
raise BadManifest.new(
|
|
214
|
-
"lane '#{z["name"]}' (#{z["kind"]}) at '$.lanes[#{i}]' " \
|
|
215
|
-
"needs a role with capability '#{verb}'; none declared",
|
|
216
|
-
)
|
|
217
|
-
end
|
|
218
|
-
end
|
|
219
|
-
|
|
220
|
-
def walk(hash, allowed, path)
|
|
221
|
-
return unless hash.is_a?(Hash)
|
|
222
|
-
|
|
223
|
-
hash.each_key do |k|
|
|
224
|
-
next if allowed.include?(k)
|
|
225
|
-
|
|
226
|
-
raise BadManifest.new("unknown key '#{k}' at '#{path}'")
|
|
227
|
-
end
|
|
20
|
+
check_migration!(raw)
|
|
21
|
+
check_invariants!(raw)
|
|
22
|
+
check_cross_field!(raw)
|
|
228
23
|
end
|
|
229
24
|
end
|
|
230
25
|
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
module Textus
|
|
2
|
+
class Orchestration
|
|
3
|
+
ListKeysQuery = Data.define(:prefix, :lane)
|
|
4
|
+
MoveKeyCommand = Data.define(:old_key, :new_key, :if_etag, :dry_run)
|
|
5
|
+
DeleteKeyCommand = Data.define(:key, :if_etag)
|
|
6
|
+
AuditQuery = Data.define(:seq_since, :key, :lane, :role, :verb, :since, :correlation_id, :limit)
|
|
7
|
+
|
|
8
|
+
def initialize(list_keys:, move_key:, delete_key:, audit_entries:)
|
|
9
|
+
@list_keys = list_keys
|
|
10
|
+
@move_key = move_key
|
|
11
|
+
@delete_key = delete_key
|
|
12
|
+
@audit_entries = audit_entries
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def list_keys(prefix:, lane:, call:)
|
|
16
|
+
query = ListKeysQuery.new(prefix: prefix, lane: lane)
|
|
17
|
+
normalize(@list_keys.call(query, call), key: "rows")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def move_key(old_key:, new_key:, call:, if_etag: nil, dry_run: false)
|
|
21
|
+
command = MoveKeyCommand.new(old_key: old_key, new_key: new_key, if_etag: if_etag, dry_run: dry_run)
|
|
22
|
+
normalize(@move_key.call(command, call), key: "move")
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def delete_key(key:, call:, if_etag: nil)
|
|
26
|
+
command = DeleteKeyCommand.new(key: key, if_etag: if_etag)
|
|
27
|
+
normalize(@delete_key.call(command, call), key: "delete")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# rubocop:disable Metrics/ParameterLists
|
|
31
|
+
def audit_entries(call:, seq_since: nil, key: nil, lane: nil, role: nil, verb: nil, since: nil, correlation_id: nil, limit: nil)
|
|
32
|
+
query = AuditQuery.new(
|
|
33
|
+
seq_since: seq_since,
|
|
34
|
+
key: key,
|
|
35
|
+
lane: lane,
|
|
36
|
+
role: role,
|
|
37
|
+
verb: verb,
|
|
38
|
+
since: since,
|
|
39
|
+
correlation_id: correlation_id,
|
|
40
|
+
limit: limit,
|
|
41
|
+
)
|
|
42
|
+
normalize(@audit_entries.call(query, call), key: "rows")
|
|
43
|
+
end
|
|
44
|
+
# rubocop:enable Metrics/ParameterLists
|
|
45
|
+
|
|
46
|
+
private
|
|
47
|
+
|
|
48
|
+
def normalize(result, key:)
|
|
49
|
+
return result unless result.is_a?(Value::Result)
|
|
50
|
+
return result if result.failure?
|
|
51
|
+
|
|
52
|
+
Value::Result.success({ key => result.value })
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|