@intentius/chant-lexicon-cedar 0.44.8 → 0.44.10
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/README.md +106 -2
- package/dist/agentcore/embed.d.ts +189 -0
- package/dist/agentcore/embed.d.ts.map +1 -0
- package/dist/agentcore/enforcement.d.ts +76 -0
- package/dist/agentcore/enforcement.d.ts.map +1 -0
- package/dist/agentcore/scan.d.ts +46 -0
- package/dist/agentcore/scan.d.ts.map +1 -0
- package/dist/codegen/docs-dogwood.d.ts +21 -0
- package/dist/codegen/docs-dogwood.d.ts.map +1 -0
- package/dist/codegen/docs.d.ts.map +1 -1
- package/dist/codegen/package.d.ts.map +1 -1
- package/dist/config.d.ts +25 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/dogwood/cli.d.ts +247 -0
- package/dist/dogwood/cli.d.ts.map +1 -0
- package/dist/dogwood/event-schema.d.ts +161 -0
- package/dist/dogwood/event-schema.d.ts.map +1 -0
- package/dist/dogwood/index.d.ts +39 -0
- package/dist/dogwood/index.d.ts.map +1 -0
- package/dist/dogwood/macros.d.ts +96 -0
- package/dist/dogwood/macros.d.ts.map +1 -0
- package/dist/dogwood/policy.d.ts +120 -0
- package/dist/dogwood/policy.d.ts.map +1 -0
- package/dist/dogwood/replay-activity.d.ts +196 -0
- package/dist/dogwood/replay-activity.d.ts.map +1 -0
- package/dist/dogwood/replay-op.d.ts +165 -0
- package/dist/dogwood/replay-op.d.ts.map +1 -0
- package/dist/dogwood/scan.d.ts +109 -0
- package/dist/dogwood/scan.d.ts.map +1 -0
- package/dist/dogwood/serialize.d.ts +66 -0
- package/dist/dogwood/serialize.d.ts.map +1 -0
- package/dist/dogwood/temporal.d.ts +259 -0
- package/dist/dogwood/temporal.d.ts.map +1 -0
- package/dist/dogwood/trace.d.ts +215 -0
- package/dist/dogwood/trace.d.ts.map +1 -0
- package/dist/dogwood/upstream.d.ts +41 -0
- package/dist/dogwood/upstream.d.ts.map +1 -0
- package/dist/dogwood/window.d.ts +73 -0
- package/dist/dogwood/window.d.ts.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/integrity.json +15 -3
- package/dist/lint/audit-catalog.d.ts.map +1 -1
- package/dist/lint/post-synth/dogwood-helpers.d.ts +63 -0
- package/dist/lint/post-synth/dogwood-helpers.d.ts.map +1 -0
- package/dist/lint/post-synth/dwdc010.d.ts +25 -0
- package/dist/lint/post-synth/dwdc010.d.ts.map +1 -0
- package/dist/lint/post-synth/dwdc011.d.ts +19 -0
- package/dist/lint/post-synth/dwdc011.d.ts.map +1 -0
- package/dist/lint/post-synth/dwdc012.d.ts +21 -0
- package/dist/lint/post-synth/dwdc012.d.ts.map +1 -0
- package/dist/lint/post-synth/dwdc013.d.ts +33 -0
- package/dist/lint/post-synth/dwdc013.d.ts.map +1 -0
- package/dist/lint/post-synth/dwde010.d.ts +32 -0
- package/dist/lint/post-synth/dwde010.d.ts.map +1 -0
- package/dist/lint/post-synth/dwde011.d.ts +33 -0
- package/dist/lint/post-synth/dwde011.d.ts.map +1 -0
- package/dist/lint/post-synth/dwds010.d.ts +24 -0
- package/dist/lint/post-synth/dwds010.d.ts.map +1 -0
- package/dist/lint/post-synth/index.d.ts.map +1 -1
- package/dist/manifest.json +1 -1
- package/dist/okf/index.md +7 -0
- package/dist/okf/rules/DWDC010.md +11 -0
- package/dist/okf/rules/DWDC011.md +11 -0
- package/dist/okf/rules/DWDC012.md +11 -0
- package/dist/okf/rules/DWDC013.md +15 -0
- package/dist/okf/rules/DWDE010.md +11 -0
- package/dist/okf/rules/DWDE011.md +11 -0
- package/dist/okf/rules/DWDS010.md +11 -0
- package/dist/okf/types/Policy.md +1 -0
- package/dist/op/activities/index.d.ts +18 -0
- package/dist/op/activities/index.d.ts.map +1 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/policy-text.d.ts +53 -0
- package/dist/policy-text.d.ts.map +1 -0
- package/dist/rules/dogwood-helpers.ts +139 -0
- package/dist/rules/dwdc010.ts +62 -0
- package/dist/rules/dwdc011.ts +61 -0
- package/dist/rules/dwdc012.ts +46 -0
- package/dist/rules/dwdc013.ts +64 -0
- package/dist/rules/dwde010.ts +130 -0
- package/dist/rules/dwde011.ts +108 -0
- package/dist/rules/dwds010.ts +46 -0
- package/dist/serializer.d.ts +10 -18
- package/dist/serializer.d.ts.map +1 -1
- package/dist/skills/chant-cedar-authoring.md +180 -0
- package/dist/skills/chant-cedar-avp-embedding.md +125 -0
- package/dist/skills/chant-cedar-dogwood.md +327 -0
- package/dist/skills/chant-cedar-meta-policy.md +119 -0
- package/package.json +7 -2
- package/src/agentcore/embed.test.ts +254 -0
- package/src/agentcore/embed.ts +399 -0
- package/src/agentcore/enforcement.test.ts +43 -0
- package/src/agentcore/enforcement.ts +92 -0
- package/src/agentcore/scan.ts +119 -0
- package/src/codegen/docs-dogwood.ts +1119 -0
- package/src/codegen/docs.ts +66 -1
- package/src/codegen/package.ts +3 -2
- package/src/config.test.ts +12 -0
- package/src/config.ts +28 -0
- package/src/dogwood/cli.test.ts +513 -0
- package/src/dogwood/cli.ts +666 -0
- package/src/dogwood/event-schema.test.ts +218 -0
- package/src/dogwood/event-schema.ts +318 -0
- package/src/dogwood/index.ts +271 -0
- package/src/dogwood/macros.test.ts +104 -0
- package/src/dogwood/macros.ts +229 -0
- package/src/dogwood/policy.test.ts +94 -0
- package/src/dogwood/policy.ts +141 -0
- package/src/dogwood/replay-activity.test.ts +481 -0
- package/src/dogwood/replay-activity.ts +506 -0
- package/src/dogwood/replay-op.ts +242 -0
- package/src/dogwood/scan.ts +287 -0
- package/src/dogwood/serialize.test.ts +331 -0
- package/src/dogwood/serialize.ts +246 -0
- package/src/dogwood/temporal.test.ts +272 -0
- package/src/dogwood/temporal.ts +592 -0
- package/src/dogwood/testdata/custom-kinds.dwschema +17 -0
- package/src/dogwood/testdata/default-macros.dw +23 -0
- package/src/dogwood/testdata/lowered-read-after-login.json +13 -0
- package/src/dogwood/testdata/max-window-raised.dwschema +25 -0
- package/src/dogwood/testdata/pinned.dwschema +31 -0
- package/src/dogwood/testdata/read-after-login.cedarschema +20 -0
- package/src/dogwood/testdata/read-after-login.dw +17 -0
- package/src/dogwood/testdata/temporal-policies.dw +53 -0
- package/src/dogwood/trace.test.ts +231 -0
- package/src/dogwood/trace.ts +471 -0
- package/src/dogwood/upstream.ts +41 -0
- package/src/dogwood/window.ts +124 -0
- package/src/index.ts +76 -0
- package/src/lint/audit-catalog.ts +64 -0
- package/src/lint/post-synth/dogwood-helpers.ts +139 -0
- package/src/lint/post-synth/dwd-post-synth.test.ts +374 -0
- package/src/lint/post-synth/dwdc010.ts +62 -0
- package/src/lint/post-synth/dwdc011.ts +61 -0
- package/src/lint/post-synth/dwdc012.ts +46 -0
- package/src/lint/post-synth/dwdc013.ts +64 -0
- package/src/lint/post-synth/dwde-post-synth.test.ts +368 -0
- package/src/lint/post-synth/dwde010.ts +130 -0
- package/src/lint/post-synth/dwde011.ts +108 -0
- package/src/lint/post-synth/dwds010.ts +46 -0
- package/src/lint/post-synth/index.ts +14 -0
- package/src/lint/post-synth/post-synth.test.ts +7 -3
- package/src/op/activities/index.ts +27 -0
- package/src/plugin.test.ts +3 -2
- package/src/plugin.ts +30 -0
- package/src/policy-text.ts +128 -0
- package/src/serializer.ts +71 -109
- package/src/skills/chant-cedar-dogwood.md +327 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `.dw` serializer leg.
|
|
3
|
+
*
|
|
4
|
+
* Runs inside the cedar serializer, not beside it: `serializeDogwood` is
|
|
5
|
+
* called once the cedar policies have been rendered, and its files land in the
|
|
6
|
+
* same `SerializerResult`. That is the whole point of shipping dogwood as a
|
|
7
|
+
* dialect — a `.dw` file stripped of Cedar semantics is meaningless, and a
|
|
8
|
+
* project's temporal policies and its plain Cedar policies are one policy set
|
|
9
|
+
* with two halves.
|
|
10
|
+
*
|
|
11
|
+
* Nothing here re-implements Cedar rendering. The policy head comes from
|
|
12
|
+
* `../serializer`'s `renderPolicyHead`, the scope forms from its
|
|
13
|
+
* `renderScope`, and the `when`/`unless` bodies from its `conditionStrings`,
|
|
14
|
+
* so a change to how a scope is written moves both outputs at once.
|
|
15
|
+
*/
|
|
16
|
+
import type { Declarable } from "@intentius/chant/declarable";
|
|
17
|
+
/** Files ending in this carry dogwood policy text. */
|
|
18
|
+
export declare const DOGWOOD_POLICY_SUFFIX = ".dw";
|
|
19
|
+
/** Files ending in this carry an event schema. */
|
|
20
|
+
export declare const DOGWOOD_EVENT_SCHEMA_SUFFIX = ".dwschema";
|
|
21
|
+
/** What the leg produced: files to write, and anything the build should say out loud. */
|
|
22
|
+
export interface DogwoodSerializeResult {
|
|
23
|
+
files: Record<string, string>;
|
|
24
|
+
warnings: string[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* One policy, in `.dw` surface syntax.
|
|
28
|
+
*
|
|
29
|
+
* Clause order is fixed rather than authored: every `when` form, then every
|
|
30
|
+
* `unless` form. Cedar evaluates a policy's conditions as a conjunction, and
|
|
31
|
+
* so does dogwood, so the order carries no meaning — fixing it means a policy
|
|
32
|
+
* that gains a temporal clause does not reshuffle the ones already there.
|
|
33
|
+
*/
|
|
34
|
+
export declare function renderTemporalPolicyText(id: string, props: Record<string, unknown>): string;
|
|
35
|
+
/**
|
|
36
|
+
* Render every dogwood entity in the build.
|
|
37
|
+
*
|
|
38
|
+
* Returns `undefined` when the build holds no temporal policies, event schemas
|
|
39
|
+
* or macro libraries at all — a cedar-only project sees no `.dw` output and no
|
|
40
|
+
* behaviour change.
|
|
41
|
+
*
|
|
42
|
+
* Ids come from `resolvePolicyId`, the same rule `cedarPolicyRecords` uses, so
|
|
43
|
+
* a policy's `@id` does not depend on which leg rendered it.
|
|
44
|
+
*/
|
|
45
|
+
export declare function serializeDogwood(entities: Map<string, Declarable>): DogwoodSerializeResult | undefined;
|
|
46
|
+
/** One declared temporal policy, resolved: chant name, policy id, walked props. */
|
|
47
|
+
export interface DogwoodPolicyRecord {
|
|
48
|
+
/** The chant entity name — the export name on the `*.ts` file. */
|
|
49
|
+
name: string;
|
|
50
|
+
/** The policy id, as it appears in `@id(…)`. */
|
|
51
|
+
id: string;
|
|
52
|
+
/** Props with references resolved, ready for `renderTemporalPolicyText`. */
|
|
53
|
+
props: Record<string, unknown>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Every `Dogwood::TemporalPolicy` in a build, with references walked and ids
|
|
57
|
+
* resolved — the temporal counterpart of `cedarPolicyRecords` (#1660).
|
|
58
|
+
*
|
|
59
|
+
* `serializeDogwood` above renders whole *files*; the AgentCore embedding needs
|
|
60
|
+
* the policies one at a time, because `AWS::BedrockAgentCore::Policy` carries a
|
|
61
|
+
* single statement and `EnforcementMode` is set per policy. Both paths walk
|
|
62
|
+
* references through the same visitor, so a scope that names another declared
|
|
63
|
+
* entity resolves identically whichever one rendered it.
|
|
64
|
+
*/
|
|
65
|
+
export declare function dogwoodPolicyRecords(entities: Map<string, Declarable>): DogwoodPolicyRecord[];
|
|
66
|
+
//# sourceMappingURL=serialize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/dogwood/serialize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAgB9D,sDAAsD;AACtD,eAAO,MAAM,qBAAqB,QAAQ,CAAC;AAE3C,kDAAkD;AAClD,eAAO,MAAM,2BAA2B,cAAc,CAAC;AAEvD,yFAAyF;AACzF,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAUD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAgB3F;AA0BD;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,sBAAsB,GAAG,SAAS,CAgGtG;AAED,mFAAmF;AACnF,MAAM,WAAW,mBAAmB;IAClC,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,EAAE,EAAE,MAAM,CAAC;IACX,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,mBAAmB,EAAE,CAe7F"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed builders for dogwood's temporal sub-language.
|
|
3
|
+
*
|
|
4
|
+
* These target the **parser primitives**, not the named aggregates. The #1657
|
|
5
|
+
* verification (and the correction comment on epic #1646) is explicit about
|
|
6
|
+
* why: `formerly`, `previous`, `since`, `exists`, `tp()`, `count for … where`
|
|
7
|
+
* and `sum … for … where` are the only temporal keywords in upstream's
|
|
8
|
+
* `extension/temporal/grammar.pest`. `count_within`, `sum_within`,
|
|
9
|
+
* `count_distinct_within` and `bind` are macros in `default_macros.dw` — a
|
|
10
|
+
* swappable standard library that a caller passing `--macros` replaces
|
|
11
|
+
* wholesale — and `once` is not even in that library, only in the examples.
|
|
12
|
+
*
|
|
13
|
+
* So the aggregates are expressible here as macro *calls* ({@link call}, and
|
|
14
|
+
* the convenience wrappers in `./macros.ts`), never as first-class operators.
|
|
15
|
+
* A call that resolves to nothing at the other end is a missing macro, which
|
|
16
|
+
* is a comprehensible failure; a first-class builder that silently emits a
|
|
17
|
+
* name the callee's library does not define is not.
|
|
18
|
+
*
|
|
19
|
+
* Everything below renders to the surface syntax the pest grammar accepts.
|
|
20
|
+
* Where the grammar's precedence would bind differently from the tree the
|
|
21
|
+
* author built, the renderer parenthesises — it never relies on the reader
|
|
22
|
+
* knowing that `!` binds tighter than `since`, or that an aggregate's `where`
|
|
23
|
+
* body is greedy.
|
|
24
|
+
*/
|
|
25
|
+
import { type TemporalWindow, type WindowLike, type WindowParam, type WindowValue } from "./window.js";
|
|
26
|
+
/** What the three past-only operators accept: a window, or a macro's `?w`. */
|
|
27
|
+
export type WindowArgument = WindowLike | WindowParam;
|
|
28
|
+
/**
|
|
29
|
+
* A binder position: a plain identifier, or a macro sigil.
|
|
30
|
+
*
|
|
31
|
+
* The sigils are legal only inside a macro body; upstream's well-formedness
|
|
32
|
+
* pass rejects them elsewhere. `./macros.ts` is where they belong, and it is
|
|
33
|
+
* what carries that warning to the author.
|
|
34
|
+
*/
|
|
35
|
+
export declare function binderName(value: string): string;
|
|
36
|
+
/** `(x: T)` — a declaration site in an `exists` or a `for` list. */
|
|
37
|
+
export interface TypedBinder {
|
|
38
|
+
readonly name: string;
|
|
39
|
+
readonly type: string;
|
|
40
|
+
}
|
|
41
|
+
/** `(t: Timepoint)`, `(amount: Long)`, `($t: Timepoint)` inside a macro. */
|
|
42
|
+
export declare function typedBinder(name: string, type: string): TypedBinder;
|
|
43
|
+
/** Anything that renders in term position. */
|
|
44
|
+
export type TemporalTerm = TermText | ArrayTerm | CountTerm | SumTerm | CallNode;
|
|
45
|
+
/** A leaf term already in its surface form (a literal, a path, an entity UID). */
|
|
46
|
+
export interface TermText {
|
|
47
|
+
readonly op: "term";
|
|
48
|
+
readonly text: string;
|
|
49
|
+
}
|
|
50
|
+
/** `[a, b, c]`. */
|
|
51
|
+
export interface ArrayTerm {
|
|
52
|
+
readonly op: "array";
|
|
53
|
+
readonly items: readonly TemporalTerm[];
|
|
54
|
+
}
|
|
55
|
+
/** `count for (t: Timepoint). where φ`. */
|
|
56
|
+
export interface CountTerm {
|
|
57
|
+
readonly op: "count";
|
|
58
|
+
readonly binders: readonly TypedBinder[];
|
|
59
|
+
readonly where: TemporalCondition;
|
|
60
|
+
}
|
|
61
|
+
/** `sum a for (a: Long), (t: Timepoint). where φ`. */
|
|
62
|
+
export interface SumTerm {
|
|
63
|
+
readonly op: "sum";
|
|
64
|
+
readonly over: string;
|
|
65
|
+
readonly binders: readonly TypedBinder[];
|
|
66
|
+
readonly where: TemporalCondition;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* What a builder accepts in term position.
|
|
70
|
+
*
|
|
71
|
+
* Numbers and booleans lift to literals because there is only one thing they
|
|
72
|
+
* can mean. A bare `string` deliberately does not: `"alice"` is a Cedar string
|
|
73
|
+
* literal and `alice` is a binder reference, and guessing which one the author
|
|
74
|
+
* meant is how a policy silently stops matching. Say which with {@link str},
|
|
75
|
+
* {@link varRef}, {@link ctx} or {@link entityUid}.
|
|
76
|
+
*/
|
|
77
|
+
export type TermInput = TemporalTerm | number | boolean;
|
|
78
|
+
/** A raw term, emitted verbatim. The escape hatch for a shape not modelled here. */
|
|
79
|
+
export declare function term(text: string): TermText;
|
|
80
|
+
/** A Cedar string literal: `"alice"`. */
|
|
81
|
+
export declare function str(value: string): TermText;
|
|
82
|
+
/** An integer literal. Upstream's grammar admits a leading `-`. */
|
|
83
|
+
export declare function int(value: number): TermText;
|
|
84
|
+
/** `true` / `false`. */
|
|
85
|
+
export declare function bool(value: boolean): TermText;
|
|
86
|
+
/** `decimal("1.50")` — Cedar's decimal constructor, which dogwood admits as a term. */
|
|
87
|
+
export declare function decimalOf(value: string): TermText;
|
|
88
|
+
/** `context.input.user` — a field of the request context record. */
|
|
89
|
+
export declare function ctx(path: string): TermText;
|
|
90
|
+
/** `principal`, `resource`, `principal.dept` — the request scope entities. */
|
|
91
|
+
export declare function scopeRef(root: "principal" | "resource", ...attrs: string[]): TermText;
|
|
92
|
+
/** `Drupe::OAuthUser::"alice"` — an entity UID literal. */
|
|
93
|
+
export declare function entityUid(uid: string): TermText;
|
|
94
|
+
/** A bare binder reference — a `for`-declared variable, or a macro sigil. */
|
|
95
|
+
export declare function varRef(name: string): TermText;
|
|
96
|
+
/** `*` — the grammar's wildcard term. */
|
|
97
|
+
export declare function wildcard(): TermText;
|
|
98
|
+
/** `[a, b]`. */
|
|
99
|
+
export declare function arrayOf(...items: TermInput[]): ArrayTerm;
|
|
100
|
+
/**
|
|
101
|
+
* `count for (t: Timepoint). where φ` — the primitive behind `count_within`.
|
|
102
|
+
*
|
|
103
|
+
* The `for` list is the aggregation domain and is mandatory in the grammar,
|
|
104
|
+
* so it is a required argument here too.
|
|
105
|
+
*/
|
|
106
|
+
export declare function count(binders: TypedBinder[], where: TemporalCondition): CountTerm;
|
|
107
|
+
/** `sum a for (a: Long), (t: Timepoint). where φ` — the primitive behind `sum_within`. */
|
|
108
|
+
export declare function sum(over: string, binders: TypedBinder[], where: TemporalCondition): SumTerm;
|
|
109
|
+
/** Anything that renders in condition position. */
|
|
110
|
+
export type TemporalCondition = PredicateNode | FormerlyNode | PreviousNode | SinceNode | ExistsNode | TpNode | AndNode | NotNode | ComparisonNode | CallNode | SigilCondition | RawCondition;
|
|
111
|
+
/** `Drupe::Action::"Login"::response{ input.user: context.input.user }`. */
|
|
112
|
+
export interface PredicateNode {
|
|
113
|
+
readonly op: "predicate";
|
|
114
|
+
readonly action: string;
|
|
115
|
+
readonly kind: string;
|
|
116
|
+
readonly args: ReadonlyArray<{
|
|
117
|
+
readonly path: string;
|
|
118
|
+
readonly value: TemporalTerm;
|
|
119
|
+
}>;
|
|
120
|
+
}
|
|
121
|
+
/** `formerly within 1h φ`. */
|
|
122
|
+
export interface FormerlyNode {
|
|
123
|
+
readonly op: "formerly";
|
|
124
|
+
readonly window: WindowValue;
|
|
125
|
+
readonly body: TemporalCondition;
|
|
126
|
+
}
|
|
127
|
+
/** `previous within 30s φ`. */
|
|
128
|
+
export interface PreviousNode {
|
|
129
|
+
readonly op: "previous";
|
|
130
|
+
readonly window: WindowValue;
|
|
131
|
+
readonly body: TemporalCondition;
|
|
132
|
+
}
|
|
133
|
+
/** `φ since within 1h ψ` — infix, with the window on the operator. */
|
|
134
|
+
export interface SinceNode {
|
|
135
|
+
readonly op: "since";
|
|
136
|
+
readonly left: TemporalCondition;
|
|
137
|
+
readonly window: WindowValue;
|
|
138
|
+
readonly right: TemporalCondition;
|
|
139
|
+
}
|
|
140
|
+
/** `exists (total: Long). φ`. */
|
|
141
|
+
export interface ExistsNode {
|
|
142
|
+
readonly op: "exists";
|
|
143
|
+
readonly binder: TypedBinder;
|
|
144
|
+
readonly body: TemporalCondition;
|
|
145
|
+
}
|
|
146
|
+
/** `tp(t)` — binds the timepoint under evaluation. */
|
|
147
|
+
export interface TpNode {
|
|
148
|
+
readonly op: "tp";
|
|
149
|
+
readonly binder: string;
|
|
150
|
+
}
|
|
151
|
+
/** `φ && ψ`. */
|
|
152
|
+
export interface AndNode {
|
|
153
|
+
readonly op: "and";
|
|
154
|
+
readonly operands: readonly TemporalCondition[];
|
|
155
|
+
}
|
|
156
|
+
/** `!φ`. */
|
|
157
|
+
export interface NotNode {
|
|
158
|
+
readonly op: "not";
|
|
159
|
+
readonly body: TemporalCondition;
|
|
160
|
+
}
|
|
161
|
+
/** `a == b`, `0 < count …`. */
|
|
162
|
+
export interface ComparisonNode {
|
|
163
|
+
readonly op: "compare";
|
|
164
|
+
readonly left: TemporalTerm;
|
|
165
|
+
readonly operator: ComparisonOperator;
|
|
166
|
+
readonly right: TemporalTerm;
|
|
167
|
+
}
|
|
168
|
+
/** The six operators `cmp_op` admits. */
|
|
169
|
+
export type ComparisonOperator = "==" | "!=" | "<" | "<=" | ">" | ">=";
|
|
170
|
+
/** A macro invocation — `once(1h, φ)`. Legal in both condition and term position. */
|
|
171
|
+
export interface CallNode {
|
|
172
|
+
readonly op: "call";
|
|
173
|
+
readonly name: string;
|
|
174
|
+
readonly args: readonly MacroArg[];
|
|
175
|
+
}
|
|
176
|
+
/** `1h` as a macro-call argument — bare, with no `within` keyword. */
|
|
177
|
+
export interface IntervalArg {
|
|
178
|
+
readonly op: "interval";
|
|
179
|
+
readonly window: TemporalWindow;
|
|
180
|
+
}
|
|
181
|
+
/** What a macro call takes: an interval, a condition, or a term. */
|
|
182
|
+
export type MacroArg = IntervalArg | TemporalCondition | TemporalTerm;
|
|
183
|
+
/**
|
|
184
|
+
* Temporal source text emitted verbatim.
|
|
185
|
+
*
|
|
186
|
+
* The one builder that can produce something the walls exist to catch — a
|
|
187
|
+
* `formerly` with no window, an event kind the schema never declared. That is
|
|
188
|
+
* deliberate: an escape hatch nobody can reach makes the walls untestable, and
|
|
189
|
+
* DWDC012 reads the serialized text precisely because this exists.
|
|
190
|
+
*/
|
|
191
|
+
export interface RawCondition {
|
|
192
|
+
readonly op: "raw";
|
|
193
|
+
readonly text: string;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* `?s` — a macro parameter standing for an entire condition.
|
|
197
|
+
*
|
|
198
|
+
* Its own node rather than a {@link RawCondition} because the grammar treats
|
|
199
|
+
* it as an atom (`refinable = (predicate | sigil_cond) ~ field_block*`), so
|
|
200
|
+
* `formerly within ?w ?s` needs no parentheses where arbitrary raw text would.
|
|
201
|
+
* Build one with `macroCondition()` in `./macros.ts`, which is where the rule
|
|
202
|
+
* that sigils are legal only inside a macro body is documented.
|
|
203
|
+
*/
|
|
204
|
+
export interface SigilCondition {
|
|
205
|
+
readonly op: "sigil";
|
|
206
|
+
readonly param: string;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* `Ns::Action::"Name"::kind{ field: term, … }`.
|
|
210
|
+
*
|
|
211
|
+
* The event kind is mandatory in the grammar and author-defined in practice —
|
|
212
|
+
* `request`/`response`/`error` are the conventional kinds the default event
|
|
213
|
+
* schema declares, not a fixed set. Which kinds are legal for a given policy
|
|
214
|
+
* set is the emitted `.dwschema`'s business, and DWDC010's.
|
|
215
|
+
*/
|
|
216
|
+
export declare function predicate(action: string, kind: string, args?: Record<string, TermInput>): PredicateNode;
|
|
217
|
+
/** `formerly within <w> φ` — held at some point in the window. */
|
|
218
|
+
export declare function formerly(w: WindowArgument, body: TemporalCondition): FormerlyNode;
|
|
219
|
+
/** `previous within <w> φ` — held at the immediately preceding timepoint in the window. */
|
|
220
|
+
export declare function previous(w: WindowArgument, body: TemporalCondition): PreviousNode;
|
|
221
|
+
/** `φ since within <w> ψ` — φ has held continuously since ψ, inside the window. */
|
|
222
|
+
export declare function since(left: TemporalCondition, w: WindowArgument, right: TemporalCondition): SinceNode;
|
|
223
|
+
/** `exists (name: Type). φ`. */
|
|
224
|
+
export declare function exists(binder: TypedBinder, body: TemporalCondition): ExistsNode;
|
|
225
|
+
/** `tp(t)`. */
|
|
226
|
+
export declare function tp(binder: string): TpNode;
|
|
227
|
+
/** `φ && ψ && …`. A single operand collapses to itself. */
|
|
228
|
+
export declare function and(...operands: TemporalCondition[]): TemporalCondition;
|
|
229
|
+
/** `!φ`. */
|
|
230
|
+
export declare function not(body: TemporalCondition): NotNode;
|
|
231
|
+
/** `a <op> b`. */
|
|
232
|
+
export declare function compare(left: TermInput, operator: ComparisonOperator, right: TermInput): ComparisonNode;
|
|
233
|
+
/**
|
|
234
|
+
* A macro invocation.
|
|
235
|
+
*
|
|
236
|
+
* Nothing here checks that the macro exists: the library is `--macros`, chosen
|
|
237
|
+
* by whoever runs `dogwood validate`, and chant is not that. `./macros.ts`
|
|
238
|
+
* carries typed wrappers for the four the default library ships.
|
|
239
|
+
*/
|
|
240
|
+
export declare function call(name: string, args?: MacroArg[]): CallNode;
|
|
241
|
+
/** `1h` in macro-call argument position — the interval without the `within`. */
|
|
242
|
+
export declare function interval(w: WindowLike): IntervalArg;
|
|
243
|
+
/** Temporal source text, passed through untouched. See {@link RawCondition}. */
|
|
244
|
+
export declare function raw(text: string): RawCondition;
|
|
245
|
+
/** `?s` in condition position. See {@link SigilCondition}. */
|
|
246
|
+
export declare function sigilCondition(param: string): SigilCondition;
|
|
247
|
+
/** Render a term. */
|
|
248
|
+
export declare function renderTerm(t: TemporalTerm): string;
|
|
249
|
+
/** Render a temporal condition to the surface syntax the pest grammar accepts. */
|
|
250
|
+
export declare function renderCondition(node: TemporalCondition): string;
|
|
251
|
+
/**
|
|
252
|
+
* `temporal { … }` — the extension marker.
|
|
253
|
+
*
|
|
254
|
+
* It is a `primary` in the Cedar expression grammar as well as a clause tag,
|
|
255
|
+
* so this is also how a temporal condition is embedded mid-expression:
|
|
256
|
+
* `when { is_small(context.input.shares) && temporal { once(1h, …) } }`.
|
|
257
|
+
*/
|
|
258
|
+
export declare function temporalMarker(condition: TemporalCondition): string;
|
|
259
|
+
//# sourceMappingURL=temporal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"temporal.d.ts","sourceRoot":"","sources":["../../src/dogwood/temporal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,EAKL,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,WAAW,EACjB,MAAM,UAAU,CAAC;AAElB,8EAA8E;AAC9E,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,WAAW,CAAC;AAoBtD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKhD;AAID,oEAAoE;AACpE,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,4EAA4E;AAC5E,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,WAAW,CAEnE;AAED,8CAA8C;AAC9C,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEjF,kFAAkF;AAClF,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,EAAE,EAAE,MAA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
* Typed construction of dogwood replay traces (#1661, epic #1646).
|
|
3
|
+
*
|
|
4
|
+
* A trace is one event per line, and the line grammar recorded by the #1657
|
|
5
|
+
* verification (§6, read from `dogwood-language/src/interpreter/log_parse.rs`
|
|
6
|
+
* at the pinned SHA) is:
|
|
7
|
+
*
|
|
8
|
+
* ```
|
|
9
|
+
* @<timestamp> [scope(principal: <uid>, resource: <uid>)]
|
|
10
|
+
* [entities(<uid>: { <attrs> } [in [<uid>, …]], …)]
|
|
11
|
+
* [request_context(<group>: { … }, …)]
|
|
12
|
+
* <Ns>::Action::"<Name>"::<kind>(<field>: <value>, …)
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* The three envelopes are optional and must appear in that order; the trailing
|
|
16
|
+
* group is the logged record. There is no comment syntax — a `//` is an
|
|
17
|
+
* ordinary part of a value, so URLs survive — blank lines are skipped, and a
|
|
18
|
+
* leading BOM is stripped.
|
|
19
|
+
*
|
|
20
|
+
* Two things in that format silently weaken a replay rather than failing it,
|
|
21
|
+
* and both are what this module exists to make hard:
|
|
22
|
+
*
|
|
23
|
+
* 1. **`request_context(…)` and the logged record are different bags.** The
|
|
24
|
+
* Cedar request is built from the first; temporal predicates match against
|
|
25
|
+
* the second. A field needed by both and supplied to only one weakens
|
|
26
|
+
* either the Cedar check or the temporal check, and the replay still exits
|
|
27
|
+
* 0 with a verdict that looks authoritative. So {@link traceEvent} writes a
|
|
28
|
+
* `context` group into *both* bags by default, and dropping one is an
|
|
29
|
+
* explicit per-event `bags` opt-out that has to be typed out.
|
|
30
|
+
* 2. **Actions must be fully qualified.** `Drupe::Action::"Transfer"`, never
|
|
31
|
+
* `Transfer` — a short name leaves the temporal predicate unmatched while
|
|
32
|
+
* Cedar still authorizes. {@link traceEvent} rejects anything that is not
|
|
33
|
+
* `Ns::…::"Name"` at construction.
|
|
34
|
+
*
|
|
35
|
+
* {@link auditTrace} is the same two checks applied to a trace this module did
|
|
36
|
+
* not build — the AgentCore session history #1661 leaves to the aws lexicon,
|
|
37
|
+
* or a `.log` recorded by hand. A trace is a trace, wherever it came from.
|
|
38
|
+
*/
|
|
39
|
+
/** `Ns::Type::"id"` in value position. */
|
|
40
|
+
export interface TraceEntityRef {
|
|
41
|
+
readonly traceValue: "entity";
|
|
42
|
+
readonly uid: string;
|
|
43
|
+
}
|
|
44
|
+
/** `1.50` — Cedar's decimal surface form, which a JS number cannot carry. */
|
|
45
|
+
export interface TraceDecimal {
|
|
46
|
+
readonly traceValue: "decimal";
|
|
47
|
+
readonly text: string;
|
|
48
|
+
}
|
|
49
|
+
/** Surface text passed through untouched — the escape hatch, used sparingly. */
|
|
50
|
+
export interface TraceRaw {
|
|
51
|
+
readonly traceValue: "raw";
|
|
52
|
+
readonly text: string;
|
|
53
|
+
}
|
|
54
|
+
/** A tagged value: one this module renders specially rather than by JS type. */
|
|
55
|
+
export type TraceTagged = TraceEntityRef | TraceDecimal | TraceRaw;
|
|
56
|
+
/** Anything that can sit in a trace field, in Cedar surface forms. */
|
|
57
|
+
export type TraceValue = string | number | boolean | TraceTagged | readonly TraceValue[] | {
|
|
58
|
+
readonly [key: string]: TraceValue;
|
|
59
|
+
};
|
|
60
|
+
/** A named group of fields — what one `request_context` envelope entry holds. */
|
|
61
|
+
export type TraceFields = {
|
|
62
|
+
readonly [key: string]: TraceValue;
|
|
63
|
+
};
|
|
64
|
+
/** `Ns::Type::"id"`. Validated at construction, so a short name cannot slip through. */
|
|
65
|
+
export declare function entityRef(uid: string): TraceEntityRef;
|
|
66
|
+
/** A Cedar decimal, written as it should appear (`"1.50"`). */
|
|
67
|
+
export declare function decimalValue(text: string): TraceDecimal;
|
|
68
|
+
/** Surface text, rendered verbatim. For values this module has no shape for. */
|
|
69
|
+
export declare function rawValue(text: string): TraceRaw;
|
|
70
|
+
/** Render one value in the Cedar surface form the trace parser reads. */
|
|
71
|
+
export declare function renderTraceValue(value: TraceValue): string;
|
|
72
|
+
/** `{ a: 1, b: "x" }` — a record body, braces included. */
|
|
73
|
+
export declare function renderTraceFields(fields: TraceFields): string;
|
|
74
|
+
/** The `scope(principal: …, resource: …)` envelope. Both are entity uids. */
|
|
75
|
+
export interface TraceScope {
|
|
76
|
+
readonly principal: string;
|
|
77
|
+
readonly resource: string;
|
|
78
|
+
}
|
|
79
|
+
/** One `entities(…)` entry: a uid, its attributes, and its parents. */
|
|
80
|
+
export interface TraceEntityDecl {
|
|
81
|
+
readonly uid: string;
|
|
82
|
+
readonly attrs?: TraceFields;
|
|
83
|
+
/** `in [<uid>, …]` — the entity's parents in the hierarchy. */
|
|
84
|
+
readonly parents?: readonly string[];
|
|
85
|
+
}
|
|
86
|
+
/** `Ns::Type::"id": { … } in [ … ]`. */
|
|
87
|
+
export declare function traceEntity(uid: string, attrs?: TraceFields, parents?: readonly string[]): TraceEntityDecl;
|
|
88
|
+
/**
|
|
89
|
+
* One trace line, fully resolved: every envelope decided, both bags settled.
|
|
90
|
+
*
|
|
91
|
+
* Built by {@link traceEvent} rather than by hand — the constructor is where
|
|
92
|
+
* the both-bags default and the qualified-action check live. The type stays
|
|
93
|
+
* public because a trace fetched from somewhere else (an AgentCore session
|
|
94
|
+
* history, a recorded `.log`) is normalized into it and then handed to
|
|
95
|
+
* {@link auditTrace}.
|
|
96
|
+
*/
|
|
97
|
+
export interface TraceEvent {
|
|
98
|
+
/** The `i64` after `@`. */
|
|
99
|
+
readonly timestamp: number;
|
|
100
|
+
/** Fully qualified: `Ns::Action::"Name"`. */
|
|
101
|
+
readonly action: string;
|
|
102
|
+
/** `request`, `response`, `error` conventionally — author-defined in truth. */
|
|
103
|
+
readonly kind: string;
|
|
104
|
+
/** The trailing logged record — what temporal predicates match against. */
|
|
105
|
+
readonly record: TraceFields;
|
|
106
|
+
/** The `request_context(…)` envelope — what the Cedar request is built from. */
|
|
107
|
+
readonly requestContext?: TraceFields;
|
|
108
|
+
readonly scope?: TraceScope;
|
|
109
|
+
readonly entities?: readonly TraceEntityDecl[];
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Which bags a `context` group lands in.
|
|
113
|
+
*
|
|
114
|
+
* `both` is the default and the only one that keeps a replay honest. The other
|
|
115
|
+
* two exist so a test can *demonstrate* the weakening rather than only
|
|
116
|
+
* describe it, and so a trace that genuinely has no Cedar-side counterpart for
|
|
117
|
+
* a field can say so out loud instead of by omission.
|
|
118
|
+
*/
|
|
119
|
+
export type TraceBags = "both" | "record-only" | "context-only";
|
|
120
|
+
/** What {@link traceEvent} takes. */
|
|
121
|
+
export interface TraceEventInput {
|
|
122
|
+
readonly timestamp: number;
|
|
123
|
+
/** Fully qualified: `Ns::Action::"Name"`. A short name throws. */
|
|
124
|
+
readonly action: string;
|
|
125
|
+
/** Default `request` — the only kind the default event schema decides on. */
|
|
126
|
+
readonly kind?: string;
|
|
127
|
+
/**
|
|
128
|
+
* Named field groups (`input`, `output`, …). Each lands in **both** the
|
|
129
|
+
* `request_context` envelope and the logged record unless {@link bags} says
|
|
130
|
+
* otherwise.
|
|
131
|
+
*/
|
|
132
|
+
readonly context?: {
|
|
133
|
+
readonly [group: string]: TraceFields;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Fields that belong to the logged record only — `callerPrincipal`,
|
|
137
|
+
* `callerResource`, `requestId`, `sessionId` and the rest of the event
|
|
138
|
+
* schema's own injections. These are never part of the Cedar request.
|
|
139
|
+
*/
|
|
140
|
+
readonly record?: TraceFields;
|
|
141
|
+
readonly scope?: TraceScope;
|
|
142
|
+
readonly entities?: readonly TraceEntityDecl[];
|
|
143
|
+
/** Explicit opt-out of both-bag population. See {@link TraceBags}. */
|
|
144
|
+
readonly bags?: TraceBags;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Build one trace event with both bags populated.
|
|
148
|
+
*
|
|
149
|
+
* Every `context` group is written to the `request_context` envelope *and*
|
|
150
|
+
* merged into the logged record, because that is the only combination in which
|
|
151
|
+
* the Cedar check and the temporal check both see the field. Dropping one is a
|
|
152
|
+
* typed decision (`bags`), not an omission.
|
|
153
|
+
*/
|
|
154
|
+
export declare function traceEvent(input: TraceEventInput): TraceEvent;
|
|
155
|
+
/** One event as the single line the trace parser reads. Never ends in a newline. */
|
|
156
|
+
export declare function renderTraceLine(event: TraceEvent): string;
|
|
157
|
+
/** A whole trace, one event per line, newline-terminated. */
|
|
158
|
+
export declare function renderTrace(events: readonly TraceEvent[]): string;
|
|
159
|
+
/** What {@link auditTrace} can find. */
|
|
160
|
+
export type TraceIssueKind = "single-bag" | "no-request-context" | "empty-record" | "out-of-order";
|
|
161
|
+
/** One finding against a trace, indexed by its position in the event list. */
|
|
162
|
+
export interface TraceIssue {
|
|
163
|
+
readonly kind: TraceIssueKind;
|
|
164
|
+
/** 0-based position in the event list — a trace has no line numbers of its own. */
|
|
165
|
+
readonly index: number;
|
|
166
|
+
readonly timestamp: number;
|
|
167
|
+
readonly message: string;
|
|
168
|
+
}
|
|
169
|
+
/** Options for {@link auditTrace} and {@link traceFixture}. */
|
|
170
|
+
export interface TraceAuditOptions {
|
|
171
|
+
/**
|
|
172
|
+
* Event kinds that produce a decision, and so build a Cedar request.
|
|
173
|
+
*
|
|
174
|
+
* Default `["request"]`, which is the convention the default event schema
|
|
175
|
+
* follows — the truth is whichever kinds the project's `.dwschema` marks
|
|
176
|
+
* `decision`, and that file is not visible from here. A history-only event
|
|
177
|
+
* never becomes a Cedar request, so an absent `request_context` on one is
|
|
178
|
+
* not a weakening and is not reported.
|
|
179
|
+
*/
|
|
180
|
+
readonly decisionKinds?: readonly string[];
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* The both-bags and ordering checks, applied to any trace.
|
|
184
|
+
*
|
|
185
|
+
* Every finding here is something that makes a replay *weaker* rather than
|
|
186
|
+
* something that makes it fail — which is exactly the class a green replay run
|
|
187
|
+
* hides. A trace built by {@link traceEvent} produces none of them unless a
|
|
188
|
+
* `bags` opt-out was taken deliberately.
|
|
189
|
+
*/
|
|
190
|
+
export declare function auditTrace(events: readonly TraceEvent[], options?: TraceAuditOptions): TraceIssue[];
|
|
191
|
+
/** Options for {@link traceFixture}. */
|
|
192
|
+
export interface TraceFixtureOptions extends TraceAuditOptions {
|
|
193
|
+
/**
|
|
194
|
+
* Issue kinds to tolerate. Empty by default: a fixture that weakens its own
|
|
195
|
+
* replay throws at build time rather than producing a green run that proves
|
|
196
|
+
* nothing.
|
|
197
|
+
*/
|
|
198
|
+
readonly allow?: readonly TraceIssueKind[];
|
|
199
|
+
}
|
|
200
|
+
/** A built trace: the events, the text, and whatever the audit tolerated. */
|
|
201
|
+
export interface TraceFixture {
|
|
202
|
+
readonly events: readonly TraceEvent[];
|
|
203
|
+
readonly text: string;
|
|
204
|
+
readonly issues: readonly TraceIssue[];
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Assemble events into trace text, refusing to produce a weakened one.
|
|
208
|
+
*
|
|
209
|
+
* The inversion of the trap: the default is a trace that populates both bags,
|
|
210
|
+
* and every way of getting a weaker one — a `bags` opt-out on an event, a
|
|
211
|
+
* hand-normalized event with an empty record — has to be named in `allow`
|
|
212
|
+
* before this will hand it back.
|
|
213
|
+
*/
|
|
214
|
+
export declare function traceFixture(events: readonly TraceEvent[], options?: TraceFixtureOptions): TraceFixture;
|
|
215
|
+
//# sourceMappingURL=trace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../src/dogwood/trace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAyBH,0CAA0C;AAC1C,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,6EAA6E;AAC7E,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACv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,CAAC;CACxC;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,SAAS,UAAU,EAAE,EAC7B,OAAO,GAAE,mBAAwB,GAChC,YAAY,CAcd"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The dogwood upstream pin.
|
|
3
|
+
*
|
|
4
|
+
* Not a `upstreamPin` on the plugin: that slot belongs to the cedar grammar
|
|
5
|
+
* (`@cedar-policy/cedar-wasm`, see `../spec/pin.ts`), and self-upgrade tooling
|
|
6
|
+
* bumps exactly one thing per lexicon. Dogwood's pin is a git SHA recorded by
|
|
7
|
+
* #1657, because upstream has no version to key off — zero tags, zero
|
|
8
|
+
* releases, and a workspace version of `1.0.0` that is an Amazon-internal
|
|
9
|
+
* package artifact every future sync will also report.
|
|
10
|
+
*
|
|
11
|
+
* The blob hashes are the narrow content pin the #1657 report recommends. The
|
|
12
|
+
* whole tree hash moves on every sync including docs-only ones, which makes it
|
|
13
|
+
* too noisy to gate on; these seven files are the surface chant actually
|
|
14
|
+
* depends on. The three `.pest` grammars pin the language, `default_macros.dw`
|
|
15
|
+
* pins the standard aggregate library (which is a file a sync can edit and a
|
|
16
|
+
* caller can replace with `--macros`), and the three `dogwood-cli/src` files
|
|
17
|
+
* pin the JSON report structs that are #1659's integration surface.
|
|
18
|
+
*
|
|
19
|
+
* Movement risk is structural, not incidental: content arrives as squashed
|
|
20
|
+
* "Sync from internal source" commits from a publish bot, against a repository
|
|
21
|
+
* nobody outside Amazon can see, with no changelog and no version bump.
|
|
22
|
+
*/
|
|
23
|
+
/** The pinned upstream revision and the files chant's surface is built against. */
|
|
24
|
+
export declare const DOGWOOD_UPSTREAM: {
|
|
25
|
+
readonly owner: "dogwood-policy";
|
|
26
|
+
readonly repo: "dogwood";
|
|
27
|
+
/** Default-branch SHA verified in #1657 (committed 2026-08-06). */
|
|
28
|
+
readonly revision: "5063bcc2d6d6cf5024d1b0498e6cc8ef52cbcf0c";
|
|
29
|
+
readonly license: "Apache-2.0";
|
|
30
|
+
/** Git blob hashes at {@link revision} — the narrow content pin. */
|
|
31
|
+
readonly contents: {
|
|
32
|
+
readonly "dogwood-language/src/parser/grammar.pest": "adb0801303ee1b735585fe22a5d85175ecf6772c";
|
|
33
|
+
readonly "dogwood-language/src/extension/temporal/grammar.pest": "dc31fe1634b5c37173f0a999619e9834069b7a22";
|
|
34
|
+
readonly "dogwood-language/src/event_schema/grammar.pest": "bd3b064447dc0d09cc2f8eb28a7c657e746cc8a2";
|
|
35
|
+
readonly "dogwood-language/configuration/default_macros.dw": "ecd67e5edcd566aa66b05ad51bc472afbaf22a7a";
|
|
36
|
+
readonly "dogwood-cli/src/ops.rs": "2924c7eb0e569a745ff19c2d84cbba782fc56502";
|
|
37
|
+
readonly "dogwood-cli/src/main.rs": "bfd68c9ff05883ed48e5738f658b5925542d817d";
|
|
38
|
+
readonly "dogwood-cli/src/error.rs": "43f12afbbf25ad94e25130c83227eefd86f8d516";
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=upstream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upstream.d.ts","sourceRoot":"","sources":["../../src/dogwood/upstream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,mFAAmF;AACnF,eAAO,MAAM,gBAAgB;;;IAG3B,mEAAmE;;;IAGnE,oEAAoE;;;;;;;;;;CAU5D,CAAC"}
|