@cloudhal/agent-runtime 0.5.0 → 0.6.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.
- package/dist/src/modes.d.ts +11 -2
- package/dist/src/modes.js +30 -18
- package/package.json +3 -3
package/dist/src/modes.d.ts
CHANGED
|
@@ -27,7 +27,12 @@ export type AutoCheckCode = "low-risk" | "removes-content" | "nothing" | "struct
|
|
|
27
27
|
/** RFC-0008 §10.7 (D9): the release would run after the key's window (elevation end or 24 h). */
|
|
28
28
|
| "outside-window"
|
|
29
29
|
/** RFC-0019 §2.4: an article gains a correction, an editorial statement a person signs off. */
|
|
30
|
-
| "correction"
|
|
30
|
+
| "correction"
|
|
31
|
+
/**
|
|
32
|
+
* RFC-0042 §3.5: a live article gains a derived gate (its collection's expiry) or an earlier one,
|
|
33
|
+
* which removes content at a set time, like `schedule_unpublish`.
|
|
34
|
+
*/
|
|
35
|
+
| "expires";
|
|
31
36
|
/** The `auto`-mode check behind a publish (stored on audit rows and approvals, ADR-0015). */
|
|
32
37
|
export interface AutoCheck {
|
|
33
38
|
/** `low-risk-release`: the same check applied to a release's items (RFC-0008 §10.3). */
|
|
@@ -51,7 +56,8 @@ export declare function describeAutoCheck(check: AutoCheck): string;
|
|
|
51
56
|
* not count toward the limit. Any other asset change is `media` and waits for a person.
|
|
52
57
|
*
|
|
53
58
|
* Corrections (RFC-0019 §2.4): an entry in `corrections` (it adds a correction to its live
|
|
54
|
-
* version; the store decides) makes the publish wait for a person.
|
|
59
|
+
* version; the store decides) makes the publish wait for a person. So does an entry in `expiries`
|
|
60
|
+
* (RFC-0042 §3.5: it adds or advances a live entry's derived gate; core-ts `expiringEntries`).
|
|
55
61
|
*/
|
|
56
62
|
export declare function checkAutoPublish(diff: {
|
|
57
63
|
added: PendingChange[];
|
|
@@ -62,6 +68,7 @@ export declare function checkAutoPublish(diff: {
|
|
|
62
68
|
}, options?: {
|
|
63
69
|
ridingAssets?: ReadonlySet<string>;
|
|
64
70
|
corrections?: ReadonlySet<string>;
|
|
71
|
+
expiries?: ReadonlySet<string>;
|
|
65
72
|
}): AutoCheck;
|
|
66
73
|
/**
|
|
67
74
|
* Time-boxed elevation (ADR-0016): the owner lets a key work in a more autonomous mode until
|
|
@@ -109,6 +116,8 @@ export interface ReleaseItemRisk {
|
|
|
109
116
|
deps?: readonly string[];
|
|
110
117
|
/** RFC-0019 §2.4: the target adds a correction to the live version. */
|
|
111
118
|
corrects?: boolean;
|
|
119
|
+
/** RFC-0042 §3.5: the target adds or advances the live version's derived gate. */
|
|
120
|
+
expires?: boolean;
|
|
112
121
|
}
|
|
113
122
|
/**
|
|
114
123
|
* `checkAutoPublish` applied to a release (RFC-0008 §10.3): articles only, nothing removed, at most
|
package/dist/src/modes.js
CHANGED
|
@@ -68,7 +68,12 @@ export const AUTO_PUBLISH_LIMIT = 20;
|
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
72
77
|
|
|
73
78
|
/** The `auto`-mode check behind a publish (stored on audit rows and approvals, ADR-0015). */
|
|
74
79
|
|
|
@@ -92,6 +97,7 @@ const AUTO_CHECK_TEXT = {
|
|
|
92
97
|
"outside-window": () =>
|
|
93
98
|
"it would run after your autonomy ends (the elevation's end, or 24 hours from now)",
|
|
94
99
|
correction: () => "it adds a correction to a published article",
|
|
100
|
+
expires: () => "it makes a published article expire sooner (its collection's expiry rule)",
|
|
95
101
|
};
|
|
96
102
|
|
|
97
103
|
/** English wording of a check, for agents and audit reasons. */
|
|
@@ -109,7 +115,8 @@ export function describeAutoCheck(check ) {
|
|
|
109
115
|
* not count toward the limit. Any other asset change is `media` and waits for a person.
|
|
110
116
|
*
|
|
111
117
|
* Corrections (RFC-0019 §2.4): an entry in `corrections` (it adds a correction to its live
|
|
112
|
-
* version; the store decides) makes the publish wait for a person.
|
|
118
|
+
* version; the store decides) makes the publish wait for a person. So does an entry in `expiries`
|
|
119
|
+
* (RFC-0042 §3.5: it adds or advances a live entry's derived gate; core-ts `expiringEntries`).
|
|
113
120
|
*/
|
|
114
121
|
export function checkAutoPublish(
|
|
115
122
|
diff
|
|
@@ -117,10 +124,15 @@ export function checkAutoPublish(
|
|
|
117
124
|
|
|
118
125
|
|
|
119
126
|
,
|
|
120
|
-
options
|
|
127
|
+
options
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
= {},
|
|
121
132
|
) {
|
|
122
133
|
const riding = options.ridingAssets ?? new Set ();
|
|
123
134
|
const corrects = options.corrections ?? new Set ();
|
|
135
|
+
const expires = options.expiries ?? new Set ();
|
|
124
136
|
const rides = (n ) => n.kind === "asset" && riding.has(n.id);
|
|
125
137
|
const added = diff.added.filter((n) => !rides(n));
|
|
126
138
|
const touched = [...added, ...diff.changed.map((c) => c.after)];
|
|
@@ -129,21 +141,18 @@ export function checkAutoPublish(
|
|
|
129
141
|
changes: touched.length + diff.removed.length,
|
|
130
142
|
limit: AUTO_PUBLISH_LIMIT,
|
|
131
143
|
};
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
: touched.length > AUTO_PUBLISH_LIMIT
|
|
145
|
-
? "too-many"
|
|
146
|
-
: "low-risk";
|
|
144
|
+
const any = (test ) => touched.some(test);
|
|
145
|
+
// The first rule that holds decides, in this order; none: low risk.
|
|
146
|
+
const rules = [
|
|
147
|
+
["removes-content", () => diff.removed.length > 0],
|
|
148
|
+
["nothing", () => touched.length === 0],
|
|
149
|
+
["structure", () => any((n) => n.kind !== "contentEntry" && n.kind !== "asset")],
|
|
150
|
+
["media", () => any((n) => n.kind === "asset")],
|
|
151
|
+
["correction", () => any((n) => corrects.has(n.id))],
|
|
152
|
+
["expires", () => any((n) => expires.has(n.id))],
|
|
153
|
+
["too-many", () => touched.length > AUTO_PUBLISH_LIMIT],
|
|
154
|
+
];
|
|
155
|
+
const code = rules.find(([, holds]) => holds())?.[0] ?? "low-risk";
|
|
147
156
|
return { ...base, code, lowRisk: code === "low-risk" };
|
|
148
157
|
}
|
|
149
158
|
|
|
@@ -235,6 +244,8 @@ export const AUTO_RELEASE_WINDOW_HOURS = 24;
|
|
|
235
244
|
|
|
236
245
|
|
|
237
246
|
|
|
247
|
+
|
|
248
|
+
|
|
238
249
|
|
|
239
250
|
|
|
240
251
|
/**
|
|
@@ -262,6 +273,7 @@ export function checkAutoRelease(items ) {
|
|
|
262
273
|
.map((i) => i.nodeId),
|
|
263
274
|
),
|
|
264
275
|
corrections: new Set(set.filter((i) => i.corrects).map((i) => i.nodeId)),
|
|
276
|
+
expiries: new Set(set.filter((i) => i.expires).map((i) => i.nodeId)),
|
|
265
277
|
},
|
|
266
278
|
);
|
|
267
279
|
return { ...check, rule: "low-risk-release" };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudhal/agent-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Cloudhal agent runtime: policy engine (actors, scopes, approvals), skill loader, audit log",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://cloudhal.dev",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"README.md"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@cloudhal/core-contracts": "0.
|
|
28
|
-
"@cloudhal/storage": "0.
|
|
27
|
+
"@cloudhal/core-contracts": "0.6.0",
|
|
28
|
+
"@cloudhal/storage": "0.6.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^26.6.5",
|