textus 0.29.0 → 0.30.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/ARCHITECTURE.md +8 -2
- data/CHANGELOG.md +56 -0
- data/README.md +9 -9
- data/SPEC.md +32 -8
- data/lib/textus/boot.rb +4 -2
- data/lib/textus/cli/verb/hook_run.rb +2 -6
- data/lib/textus/cli/verb/put.rb +4 -13
- data/lib/textus/cli/verb/retain.rb +19 -0
- data/lib/textus/cli/verb/rule_list.rb +1 -1
- data/lib/textus/cli.rb +19 -16
- data/lib/textus/dispatcher.rb +8 -0
- data/lib/textus/doctor/check.rb +8 -5
- data/lib/textus/domain/duration.rb +22 -0
- data/lib/textus/domain/policy/refresh.rb +1 -15
- data/lib/textus/domain/policy/retention.rb +26 -0
- data/lib/textus/domain/retention.rb +44 -0
- data/lib/textus/envelope/io/reader.rb +4 -0
- data/lib/textus/envelope/io/writer.rb +8 -0
- data/lib/textus/hooks/event_bus.rb +8 -20
- data/lib/textus/hooks/rpc_registry.rb +9 -35
- data/lib/textus/hooks/signature.rb +31 -0
- data/lib/textus/init.rb +7 -6
- data/lib/textus/manifest/data.rb +5 -1
- data/lib/textus/manifest/entry/base.rb +2 -2
- data/lib/textus/manifest/policy.rb +34 -7
- data/lib/textus/manifest/rules.rb +10 -1
- data/lib/textus/manifest/schema.rb +54 -4
- data/lib/textus/manifest.rb +3 -2
- data/lib/textus/mcp/server.rb +1 -9
- data/lib/textus/mcp/session.rb +7 -23
- data/lib/textus/read/policy_explain.rb +5 -0
- data/lib/textus/read/retainable.rb +17 -0
- data/lib/textus/role_scope.rb +3 -2
- data/lib/textus/version.rb +1 -1
- data/lib/textus/write/delete.rb +1 -15
- data/lib/textus/write/intake_fetch.rb +23 -0
- data/lib/textus/write/mv.rb +2 -12
- data/lib/textus/write/put.rb +1 -15
- data/lib/textus/write/refresh_worker.rb +2 -16
- data/lib/textus/write/retention_sweep.rb +55 -0
- metadata +9 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
require "fileutils"
|
|
2
|
+
|
|
3
|
+
module Textus
|
|
4
|
+
module Write
|
|
5
|
+
# Applies retention actions reported by Read::Retainable. `expire` deletes
|
|
6
|
+
# the leaf through the role gate; `archive` copies it to
|
|
7
|
+
# <root>/archive/<relative-path> first, then deletes. Rows whose zone the
|
|
8
|
+
# caller's role cannot write surface in `failed` rather than aborting.
|
|
9
|
+
class RetentionSweep
|
|
10
|
+
def initialize(container:, call:)
|
|
11
|
+
@container = container
|
|
12
|
+
@call = call
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def call(prefix: nil, zone: nil)
|
|
16
|
+
rows = Textus::Read::Retainable.new(container: @container, call: @call)
|
|
17
|
+
.call(prefix: prefix, zone: zone)
|
|
18
|
+
delete_op = Textus::Write::Delete.new(container: @container, call: @call)
|
|
19
|
+
expired = []
|
|
20
|
+
archived = []
|
|
21
|
+
failed = []
|
|
22
|
+
|
|
23
|
+
rows.each do |row|
|
|
24
|
+
key = row["key"]
|
|
25
|
+
begin
|
|
26
|
+
archive_leaf(row) if row["action"] == "archive"
|
|
27
|
+
delete_op.call(key)
|
|
28
|
+
(row["action"] == "archive" ? archived : expired) << key
|
|
29
|
+
rescue Textus::Error => e
|
|
30
|
+
failed << { "key" => key, "error" => e.message }
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
{
|
|
35
|
+
"protocol" => Textus::PROTOCOL,
|
|
36
|
+
"ok" => failed.empty?,
|
|
37
|
+
"expired" => expired,
|
|
38
|
+
"archived" => archived,
|
|
39
|
+
"failed" => failed,
|
|
40
|
+
}
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
private
|
|
44
|
+
|
|
45
|
+
def archive_leaf(row)
|
|
46
|
+
src = row["path"]
|
|
47
|
+
root = @container.root.to_s
|
|
48
|
+
rel = src.delete_prefix("#{root}/")
|
|
49
|
+
dest = File.join(root, "archive", rel)
|
|
50
|
+
FileUtils.mkdir_p(File.dirname(dest))
|
|
51
|
+
FileUtils.cp(src, dest)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: textus
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.30.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Patrick
|
|
@@ -152,6 +152,7 @@ files:
|
|
|
152
152
|
- lib/textus/cli/verb/refresh.rb
|
|
153
153
|
- lib/textus/cli/verb/refresh_stale.rb
|
|
154
154
|
- lib/textus/cli/verb/reject.rb
|
|
155
|
+
- lib/textus/cli/verb/retain.rb
|
|
155
156
|
- lib/textus/cli/verb/rule_explain.rb
|
|
156
157
|
- lib/textus/cli/verb/rule_lint.rb
|
|
157
158
|
- lib/textus/cli/verb/rule_list.rb
|
|
@@ -183,6 +184,7 @@ files:
|
|
|
183
184
|
- lib/textus/doctor/check/unowned_schema_fields.rb
|
|
184
185
|
- lib/textus/domain/action.rb
|
|
185
186
|
- lib/textus/domain/authorizer.rb
|
|
187
|
+
- lib/textus/domain/duration.rb
|
|
186
188
|
- lib/textus/domain/freshness.rb
|
|
187
189
|
- lib/textus/domain/freshness/evaluator.rb
|
|
188
190
|
- lib/textus/domain/freshness/policy.rb
|
|
@@ -196,6 +198,8 @@ files:
|
|
|
196
198
|
- lib/textus/domain/policy/promote.rb
|
|
197
199
|
- lib/textus/domain/policy/promotion.rb
|
|
198
200
|
- lib/textus/domain/policy/refresh.rb
|
|
201
|
+
- lib/textus/domain/policy/retention.rb
|
|
202
|
+
- lib/textus/domain/retention.rb
|
|
199
203
|
- lib/textus/domain/sentinel.rb
|
|
200
204
|
- lib/textus/domain/staleness.rb
|
|
201
205
|
- lib/textus/domain/staleness/generator_check.rb
|
|
@@ -218,6 +222,7 @@ files:
|
|
|
218
222
|
- lib/textus/hooks/fire_report.rb
|
|
219
223
|
- lib/textus/hooks/loader.rb
|
|
220
224
|
- lib/textus/hooks/rpc_registry.rb
|
|
225
|
+
- lib/textus/hooks/signature.rb
|
|
221
226
|
- lib/textus/init.rb
|
|
222
227
|
- lib/textus/key/distance.rb
|
|
223
228
|
- lib/textus/key/grammar.rb
|
|
@@ -279,6 +284,7 @@ files:
|
|
|
279
284
|
- lib/textus/read/published.rb
|
|
280
285
|
- lib/textus/read/pulse.rb
|
|
281
286
|
- lib/textus/read/rdeps.rb
|
|
287
|
+
- lib/textus/read/retainable.rb
|
|
282
288
|
- lib/textus/read/schema_envelope.rb
|
|
283
289
|
- lib/textus/read/stale.rb
|
|
284
290
|
- lib/textus/read/uid.rb
|
|
@@ -296,6 +302,7 @@ files:
|
|
|
296
302
|
- lib/textus/write/accept.rb
|
|
297
303
|
- lib/textus/write/authority_gate.rb
|
|
298
304
|
- lib/textus/write/delete.rb
|
|
305
|
+
- lib/textus/write/intake_fetch.rb
|
|
299
306
|
- lib/textus/write/materializer.rb
|
|
300
307
|
- lib/textus/write/mv.rb
|
|
301
308
|
- lib/textus/write/publish.rb
|
|
@@ -304,6 +311,7 @@ files:
|
|
|
304
311
|
- lib/textus/write/refresh_orchestrator.rb
|
|
305
312
|
- lib/textus/write/refresh_worker.rb
|
|
306
313
|
- lib/textus/write/reject.rb
|
|
314
|
+
- lib/textus/write/retention_sweep.rb
|
|
307
315
|
homepage: https://github.com/patrick204nqh/textus
|
|
308
316
|
licenses:
|
|
309
317
|
- MIT
|