@effected/github-actions 0.1.0 → 0.2.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.
@@ -0,0 +1,281 @@
1
+ import { Effect, Option, Result, Schema } from "effect";
2
+ import { CommentStyle, SectionDialect, SectionDocument, SectionId } from "@effected/templates";
3
+
4
+ //#region src/ManagedDocument.ts
5
+ /**
6
+ * The grammar shared by a document's `namespace`, its `key` and every region
7
+ * key.
8
+ *
9
+ * @remarks
10
+ * Letters, digits, dashes and underscores, starting alphanumeric. Dots are
11
+ * excluded deliberately: the three parts are joined with `.` into the marker
12
+ * key written to the wire (`namespace.key.region`), and a dot inside a part
13
+ * would make two different documents spell the same marker.
14
+ */
15
+ const NamePart = Schema.String.check(Schema.isPattern(/^[A-Za-z0-9][A-Za-z0-9_-]*$/));
16
+ /**
17
+ * The marker vocabulary every managed document is written with: HTML comments
18
+ * — the one comment style GitHub renders invisibly — and a phrase distinct
19
+ * from `@effected/templates`' default, so a document that also carries
20
+ * ordinary `MANAGED SECTION` blocks never has them mistaken for regions.
21
+ */
22
+ const REGION_DIALECT = SectionDialect.make({
23
+ phrase: "MANAGED REGION",
24
+ styles: [CommentStyle.html]
25
+ });
26
+ /**
27
+ * Raised when a managed document cannot be read or regenerated without
28
+ * guessing.
29
+ *
30
+ * @remarks
31
+ * The four structural kinds (`unterminatedRegion`, `orphanedEnd`,
32
+ * `overlappingRegions`, `duplicateRegion`) surface at parse time and name an
33
+ * ambiguity whose silent resolution would corrupt content a human wrote by
34
+ * hand. The two declaration kinds surface when regions are applied:
35
+ * `markerInContent` refuses region content that itself contains a line the
36
+ * scanner would read as a region marker, and `duplicateDeclaration` refuses
37
+ * one call that states two intentions for the same region.
38
+ *
39
+ * @public
40
+ */
41
+ var ManagedDocumentError = class extends Schema.TaggedErrorClass()("ManagedDocumentError", {
42
+ /** Which ambiguity or refusal was found. */
43
+ kind: Schema.Literals([
44
+ "unterminatedRegion",
45
+ "orphanedEnd",
46
+ "overlappingRegions",
47
+ "duplicateRegion",
48
+ "markerInContent",
49
+ "duplicateDeclaration"
50
+ ]),
51
+ /** 1-based line of the offending marker, for the structural kinds. */
52
+ line: Schema.optionalKey(Schema.Number),
53
+ /** The region key involved, when the failure names one. */
54
+ key: Schema.optionalKey(Schema.String)
55
+ }) {
56
+ get message() {
57
+ const which = this.key === void 0 ? "" : ` for region "${this.key}"`;
58
+ const where = this.line === void 0 ? "" : ` at line ${this.line}`;
59
+ return `${KIND_PROSE[this.kind]}${which}${where}`;
60
+ }
61
+ };
62
+ const KIND_PROSE = {
63
+ unterminatedRegion: "Managed region is never closed",
64
+ orphanedEnd: "Region end marker closes no open region",
65
+ overlappingRegions: "Managed region opens inside another",
66
+ duplicateRegion: "Managed region appears twice",
67
+ markerInContent: "Region content contains a managed-region marker",
68
+ duplicateDeclaration: "Region was declared twice in one call"
69
+ };
70
+ /** Map a templates scan failure onto this surface's vocabulary. */
71
+ const STRUCTURAL_KIND = {
72
+ unterminatedSection: "unterminatedRegion",
73
+ orphanedEnd: "orphanedEnd",
74
+ overlappingSections: "overlappingRegions",
75
+ duplicateSection: "duplicateRegion"
76
+ };
77
+ /**
78
+ * A marker-delimited document: named regions a tool owns, inside text a human
79
+ * may also edit.
80
+ *
81
+ * @remarks
82
+ * The one primitive behind both the sticky PR comment and the managed PR
83
+ * description. A sentinel HTML comment (`<!-- namespace:key -->`) identifies
84
+ * the document; each region is delimited by HTML-comment markers keyed
85
+ * `namespace.key.region`; and everything outside the managed regions is
86
+ * preserved byte-for-byte on regeneration. Regions are **replaced from
87
+ * current state, never appended** — applying the same region twice yields one
88
+ * region carrying the latest content, which is what makes a check that
89
+ * resolves many times safe to re-render.
90
+ *
91
+ * The region engine is `@effected/templates`' pure `SectionDocument` —
92
+ * reused, not reinvented — fixed to the HTML comment style and a
93
+ * region-specific phrase. Everything here is string → string; the GitHub
94
+ * write path composes this with `PullRequestComment` (whose `CommentMarker`
95
+ * renders the *same* sentinel for the same namespace and key) or a PR-body
96
+ * update in `@effected/github`.
97
+ *
98
+ * Construct with {@link ManagedDocument.parseResult} — create-or-update in
99
+ * one call, so the consumer never branches on whether the document exists
100
+ * yet. `ManagedDocument.make` is the raw schema constructor and performs no
101
+ * structural validation.
102
+ *
103
+ * @example
104
+ * ```ts
105
+ * import { ManagedDocument } from "@effected/github-actions";
106
+ * import { Result } from "effect";
107
+ *
108
+ * const doc = ManagedDocument.parseResult({ namespace: "my-action", key: "release", text: fetched });
109
+ * if (Result.isSuccess(doc)) {
110
+ * const next = doc.success.withRegionsResult([
111
+ * ["header", "## Validating Release"],
112
+ * ["footer", "generated by my-action"],
113
+ * ]);
114
+ * }
115
+ * ```
116
+ *
117
+ * @public
118
+ */
119
+ var ManagedDocument = class ManagedDocument extends Schema.Class("ManagedDocument")({
120
+ /** Whose document this is. */
121
+ namespace: NamePart,
122
+ /** Which document, within that namespace. */
123
+ key: NamePart,
124
+ /** The document's full text, sentinel and regions included. */
125
+ text: Schema.String
126
+ }) {
127
+ /**
128
+ * Read a document out of existing text, or begin a fresh one.
129
+ *
130
+ * @remarks
131
+ * The synchronous primitive; {@link ManagedDocument.parse} derives from it.
132
+ * Absent text, empty text and text that carries no sentinel are all legal —
133
+ * the sentinel and regions are added by the first
134
+ * {@link ManagedDocument.withRegionsResult}. Only a *structurally corrupt*
135
+ * region layout fails, because every structural ambiguity is a case where
136
+ * a silent choice would destroy content a human wrote.
137
+ */
138
+ static parseResult(source) {
139
+ const text = source.text ?? "";
140
+ const scanned = SectionDocument.parseResult(text, REGION_DIALECT);
141
+ if (Result.isFailure(scanned)) {
142
+ const failure = scanned.failure;
143
+ return Result.fail(new ManagedDocumentError({
144
+ kind: STRUCTURAL_KIND[failure.reason],
145
+ line: failure.line,
146
+ ...failure.key === void 0 ? {} : { key: failure.key }
147
+ }));
148
+ }
149
+ return Result.succeed(ManagedDocument.make({
150
+ namespace: source.namespace,
151
+ key: source.key,
152
+ text
153
+ }));
154
+ }
155
+ /**
156
+ * Read a document out of existing text, in `Effect`.
157
+ *
158
+ * @remarks
159
+ * Defined in terms of {@link ManagedDocument.parseResult} — synchronous
160
+ * callers can use that variant directly.
161
+ */
162
+ static parse = Effect.fn("ManagedDocument.parse")((source) => Effect.fromResult(ManagedDocument.parseResult(source)));
163
+ /** The HTML comment identifying this document, `<!-- namespace:key -->`. */
164
+ get sentinel() {
165
+ return `<!-- ${this.namespace}:${this.key} -->`;
166
+ }
167
+ /** Does this text carry the document's sentinel? */
168
+ matches(text) {
169
+ return text.includes(this.sentinel);
170
+ }
171
+ /** The content of one region, if the document carries it. */
172
+ region(key) {
173
+ const found = this.ownRegions().find((entry) => entry.key === key);
174
+ return found === void 0 ? Option.none() : Option.some(found.content);
175
+ }
176
+ /** Every region this document carries, in document order. */
177
+ get regions() {
178
+ return this.ownRegions();
179
+ }
180
+ /**
181
+ * The document with these regions replaced from current state.
182
+ *
183
+ * @remarks
184
+ * The synchronous primitive; {@link ManagedDocument.withRegions} derives
185
+ * from it. Each entry pairs a region key with its full new content. A
186
+ * region already present is **replaced in place**; a region not present
187
+ * yet is added; regions not named are left exactly as they are; and every
188
+ * byte outside a managed region survives untouched. Applying entries that
189
+ * change nothing returns byte-identical text, which is what lets a caller
190
+ * compare-and-skip instead of issuing a write.
191
+ *
192
+ * Region keys share the name grammar `namespace` and `key` obey; a key
193
+ * outside it is a wiring error and throws at construction rather than
194
+ * surfacing in the typed channel.
195
+ */
196
+ withRegionsResult(entries) {
197
+ const parsed = SectionDocument.parseResult(this.text, REGION_DIALECT);
198
+ if (Result.isFailure(parsed)) {
199
+ const failure = parsed.failure;
200
+ return Result.fail(new ManagedDocumentError({
201
+ kind: STRUCTURAL_KIND[failure.reason],
202
+ line: failure.line,
203
+ ...failure.key === void 0 ? {} : { key: failure.key }
204
+ }));
205
+ }
206
+ const declared = entries.map(([key, content]) => SectionId.make({
207
+ key: this.wireKey(key),
208
+ commentStyle: CommentStyle.html
209
+ }).section(content));
210
+ const reconciled = parsed.success.reconcile(declared);
211
+ if (Result.isFailure(reconciled)) {
212
+ const failure = reconciled.failure;
213
+ if (failure.reason === "unknownCommentStyle") throw new Error("ManagedDocument: the region dialect rejected its own comment style");
214
+ return Result.fail(new ManagedDocumentError({
215
+ kind: failure.reason,
216
+ key: this.regionKeyOf(failure.key)
217
+ }));
218
+ }
219
+ const withSentinel = this.ensureSentinel(reconciled.success.text, parsed.success.eol);
220
+ return Result.succeed(ManagedDocument.make({
221
+ namespace: this.namespace,
222
+ key: this.key,
223
+ text: withSentinel
224
+ }));
225
+ }
226
+ /**
227
+ * The document with these regions replaced, in `Effect`.
228
+ *
229
+ * @remarks
230
+ * Defined in terms of {@link ManagedDocument.withRegionsResult} —
231
+ * synchronous callers can use that variant directly.
232
+ */
233
+ withRegions(entries) {
234
+ return Effect.fromResult(this.withRegionsResult(entries));
235
+ }
236
+ /** The marker key a region is written under: `namespace.key.region`. */
237
+ wireKey(region) {
238
+ return `${this.namespace}.${this.key}.${region}`;
239
+ }
240
+ /** The region key back out of a wire key, for error reporting. */
241
+ regionKeyOf(wireKey) {
242
+ const prefix = `${this.namespace}.${this.key}.`;
243
+ return wireKey.startsWith(prefix) ? wireKey.slice(prefix.length) : wireKey;
244
+ }
245
+ /**
246
+ * This document's own regions, in document order.
247
+ *
248
+ * @remarks
249
+ * A document a human already edited can be structurally corrupt, and a
250
+ * read has no error channel worth having — a corrupt document simply has
251
+ * no readable regions; {@link ManagedDocument.parseResult} is where
252
+ * corruption fails typed. Regions belonging to a *different* document in
253
+ * the same text (another namespace or key) are not this document's and are
254
+ * never reported.
255
+ */
256
+ ownRegions() {
257
+ const parsed = SectionDocument.parseResult(this.text, REGION_DIALECT);
258
+ if (Result.isFailure(parsed)) return [];
259
+ const prefix = `${this.namespace}.${this.key}.`;
260
+ return parsed.success.sections.filter((placed) => placed.section.key.startsWith(prefix)).map((placed) => ({
261
+ key: placed.section.key.slice(prefix.length),
262
+ content: placed.section.content
263
+ }));
264
+ }
265
+ /**
266
+ * Append the sentinel when the text does not carry it yet.
267
+ *
268
+ * @remarks
269
+ * Appended at the end — the same position `PullRequestComment.upsert`
270
+ * writes its marker to — so a document rendered here and a comment written
271
+ * there agree about where the identity line lives.
272
+ */
273
+ ensureSentinel(text, eol) {
274
+ if (text.includes(this.sentinel)) return text;
275
+ if (text.trim() === "") return `${this.sentinel}${eol}`;
276
+ return `${text.replace(/(?:\r?\n)+$/, "")}${eol}${eol}${this.sentinel}${eol}`;
277
+ }
278
+ };
279
+
280
+ //#endregion
281
+ export { ManagedDocument, ManagedDocumentError };
package/README.md ADDED
@@ -0,0 +1,241 @@
1
+ # @effected/github-actions
2
+
3
+ [![npm](https://img.shields.io/npm/v/@effected%2Fgithub-actions?label=npm&color=cb3837)](https://www.npmjs.com/package/@effected/github-actions)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-4caf50.svg)](https://opensource.org/licenses/MIT)
5
+ [![Node.js %3E%3D24.11.0](https://img.shields.io/badge/Node.js-%3E%3D24.11.0-5fa04e.svg)](https://nodejs.org/)
6
+ [![TypeScript 7.0](https://img.shields.io/badge/TypeScript-7.0-3178c6.svg)](https://www.typescriptlang.org/)
7
+
8
+ The GitHub Actions runtime for [Effect](https://effect.website) v4: the services an action needs to talk to the runner it is executing inside. `Action.run` composes the runtime, runs your program, renders a failure as an `::error::` annotation and sets the exit code. `ActionInput` reads workflow inputs as typed `Config` values — string, boolean, integer, redacted secret, multiline list, `key=value` pairs, or a schema-decoded JSON blob — with one absence rule shared by every accessor: unset and `""` are both missing data. `ActionOutputs`, `ActionState`, `ActionLogger` and a fiber-local `ActionEnvironment` round out the runner surface, alongside `ActionCache`, `Artifact`, a metadata-carrying `BlobStore` (S3-compatible or the runner's own cache), `OidcTokenIssuer` and `ToolInstaller` for the heavier protocols. A reporting suite — `GitHubMarkdown`, `ManagedDocument`, `CheckState` and `CheckDocument` — covers the other direction: rendering what a run did onto a pull request comment, a check run or the job summary. No `@actions/*` dependency anywhere — the cache, artifact and tool-cache protocols are implemented directly against their HTTP APIs.
9
+
10
+ > **Pre-release.** This package is part of the `@effected/*` kit, in pre-`1.0.0`
11
+ > development against a single pinned Effect v4 beta. Packages graduate to
12
+ > `1.0.0` once Effect `4.0.0` ships. To hold your own `effect` versions at
13
+ > exactly the ones the kit is built and tested against, install
14
+ > [`@effected/pnpm-plugin-effect`](https://www.npmjs.com/package/@effected/pnpm-plugin-effect).
15
+ >
16
+ > **Stability: unstable.** This package's API surface is not yet considered
17
+ > complete and may change across `0.x` releases. Pin an exact version — even a
18
+ > package marked *stable* before `1.0.0` can introduce a breaking change by
19
+ > accident, and an exact pin turns that into a type-check error rather than a
20
+ > runtime surprise. Full policy: [release strategy](https://github.com/spencerbeggs/effected#release-strategy).
21
+
22
+ ## Why @effected/github-actions
23
+
24
+ `@actions/core` and its siblings (`@actions/cache`, `@actions/artifact`, `@actions/tool-cache`) are the standard way to write an action, and each one owns its own ad hoc contract: inputs are read with `getInput`, which returns `""` for both "unset" and "set to empty" with no way to tell them apart at the type level; outputs, masking and workflow commands are separate globals; and the cache and artifact clients bring their own HTTP stacks. This package answers the same questions as one coherent set of Effect services instead, with the absence rule stated once (`Config.withDefault` is the idiom for every optional input) and every mutation running through the same `R`-typed services a test can swap out.
25
+
26
+ It is also the **one place in the kit** where `@effect/platform-node` is a required peer, deliberately: a GitHub Action always compiles into a Node process on a GitHub-provided runner, so there is no second platform to abstract over. Everything that *can* go through a core contract still does — `ToolInstaller` downloads over `HttpClient` and extracts over `ChildProcessSpawner`, `CacheKey` reads over `FileSystem` — and the four sanctioned `node:` imports (`node:crypto` for digests, `process.kill` for reaping a bare pid, `node:child_process` for a detached spawn, and `node:zlib`/`node:stream` in the cache and artifact codecs) cover exactly what core cannot do yet.
27
+
28
+ The line against [`@effected/github`](https://www.npmjs.com/package/@effected/github) is exact: that package talks to the GitHub API, this one talks to the runner. They meet at two seams — the token bridge (`GitHubToken`) and the `Logger` that maps `Effect.log*` onto workflow commands — and nothing here reads `process.env.GITHUB_REPOSITORY` on `github`'s behalf.
29
+
30
+ ## Install
31
+
32
+ ```bash
33
+ npm install @effected/github-actions effect @effect/platform-node
34
+ ```
35
+
36
+ ```bash
37
+ pnpm add @effected/github-actions effect @effect/platform-node
38
+ ```
39
+
40
+ Requires Node.js >=24.11.0. `effect` v4 and `@effect/platform-node` are both peer dependencies.
41
+
42
+ All `@effected/*` packages are ESM-only: the exports maps publish only `import` conditions, so `require()` — including tools that resolve in CJS mode — fails with Node's `ERR_PACKAGE_PATH_NOT_EXPORTED` rather than loading a CJS build that does not exist. Import from an ES module.
43
+
44
+ ## Quick start
45
+
46
+ ```ts
47
+ import { Action, ActionInput, ActionOutputs } from "@effected/github-actions";
48
+ import { Config, Effect } from "effect";
49
+
50
+ const program = Effect.gen(function* () {
51
+ const name = yield* ActionInput.string("name").pipe(Config.withDefault("world"));
52
+ const outputs = yield* ActionOutputs;
53
+ yield* outputs.set("greeting", `Hello, ${name}!`);
54
+ });
55
+
56
+ await Action.run(program);
57
+ // exit code reflects success/failure; failures render as an ::error:: annotation
58
+ ```
59
+
60
+ `Action.run` provides `ActionServices` (environment, logger, outputs, state, the Node platform and an `HttpClient`) by default. A capability with a heavier dependency — the cache, artifacts, the blob store — is one extra line: `Action.run(program, { layer: ActionCache.layer })`.
61
+
62
+ ## Reading inputs
63
+
64
+ Every accessor shares one absence rule: the runner writes `""` for an input the workflow omitted, and this package reads that the same as unset — **missing data**, not an empty value. An optional input needs `Config.withDefault` (or `Config.option`) at the call site:
65
+
66
+ ```ts
67
+ import { ActionInput } from "@effected/github-actions";
68
+ import { Config, Effect } from "effect";
69
+
70
+ const program = Effect.gen(function* () {
71
+ const dryRun = yield* ActionInput.boolean("dry-run").pipe(Config.withDefault(false));
72
+ const paths = yield* ActionInput.list("paths").pipe(Config.withDefault([]));
73
+ return { dryRun, paths };
74
+ });
75
+ // dryRun: boolean; paths: readonly string[] — [] when the input was omitted
76
+ ```
77
+
78
+ `list` accepts a JSON array, a bullet list, or comma- and newline-separated values, with full-line `#` comments dropped — whichever shape a workflow author reaches for first. A **present but malformed** value (`dry-run: yes` instead of a YAML 1.2 boolean) is a different class from an absent one: it fails carrying its `actual` and is never silently swallowed by a default.
79
+
80
+ ## The token bridge
81
+
82
+ `GitHubToken` shapes GitHub App authentication like the three-phase workflow it runs inside: mint in `pre`, use in `main`, revoke in `post`. Nothing survives between phases except what `GITHUB_STATE` carries, so an installation token — which lives about an hour — is persisted rather than held in a `Scope`:
83
+
84
+ ```ts
85
+ import { GitHubToken } from "@effected/github-actions";
86
+ import { Effect, Redacted } from "effect";
87
+
88
+ // pre:
89
+ const pre = GitHubToken.provision({
90
+ appId: "123456",
91
+ privateKey: Redacted.make(process.env.APP_PRIVATE_KEY as string),
92
+ owner: "acme",
93
+ required: { contents: "write", pull_requests: "write" },
94
+ });
95
+
96
+ // main: bind once — layers memoize by reference
97
+ const ClientLayer = GitHubToken.clientLayer();
98
+
99
+ // post:
100
+ const post = GitHubToken.dispose();
101
+ ```
102
+
103
+ `GitHubToken.read` fails typed with `reason: "expired"` rather than handing back a token GitHub will answer with a bare 401 — the credential that could re-mint one is the app's private key, and persisting that through a plaintext `GITHUB_STATE` file would trade a one-hour token for a permanent one.
104
+
105
+ ## Secrets
106
+
107
+ `Secret` is the only place in this package a `Redacted` value becomes a plain string, and masking and declassification are the same call — every member registers the value with the runner's `::add-mask::` filter *before* returning plaintext:
108
+
109
+ ```ts
110
+ import { Secret } from "@effected/github-actions";
111
+ import { Effect } from "effect";
112
+
113
+ declare const token: import("effect/Redacted").Redacted<string>;
114
+
115
+ const program = Effect.gen(function* () {
116
+ const env = yield* Secret.forChildEnv({ MY_TOKEN: token });
117
+ // every value in `env` is already masked in the runner log
118
+ return env;
119
+ });
120
+ ```
121
+
122
+ ## The runner's cache, artifacts and OIDC
123
+
124
+ `ActionCache` and `Artifact` speak the Actions Twirp v2 protocol directly — no `@actions/cache` or `@actions/artifact` dependency, and both are excluded from `ActionRuntime.layer` on purpose, so a consumer that only sets an output never links `@azure/storage-blob`:
125
+
126
+ ```ts
127
+ import { ActionCache, CacheKey } from "@effected/github-actions";
128
+ import { Effect, Option } from "effect";
129
+
130
+ const program = Effect.gen(function* () {
131
+ const cache = yield* ActionCache;
132
+ const key = CacheKey.of("Linux", "pnpm-store", "abc123");
133
+ const hit = yield* cache.restore(["~/.pnpm-store"], key);
134
+ if (Option.isNone(hit)) {
135
+ yield* cache.save(["~/.pnpm-store"], key);
136
+ }
137
+ });
138
+
139
+ await Action.run(program, { layer: ActionCache.layer });
140
+ ```
141
+
142
+ `CacheKey.hashFiles` is byte-compatible with `@actions/glob`'s `hashFiles`, and `OidcTokenIssuer.claims` decodes the runner's OIDC token for a SLSA provenance predicate without verifying its signature — the token arrived over TLS from the runner's own token service, so the transport is the trust boundary and nothing here branches on the claims for authorization.
143
+
144
+ `ActionsProvenance.capture` turns those claims into an `@effected/sbom` `SlsaProvenance` predicate, and `ActionsIdentityToken.layer` serves that package's narrow `IdentityToken` contract from the same issuer — the inversion that keeps the Actions runtime out of every consumer that only wants to emit an SBOM:
145
+
146
+ ```ts
147
+ import { ActionsIdentityToken, ActionsProvenance, OidcTokenIssuer } from "@effected/github-actions";
148
+ import { SigstoreSigner } from "@effected/sbom";
149
+ import { Effect, Layer } from "effect";
150
+
151
+ const program = Effect.gen(function* () {
152
+ const provenance = yield* ActionsProvenance.capture();
153
+ return provenance.runDetails.builder.id;
154
+ });
155
+ // the builder id, derived from the workflow ref in the runner's own claims
156
+
157
+ const SigningLayer = SigstoreSigner.layer.pipe(
158
+ Layer.provide(ActionsIdentityToken.layer),
159
+ Layer.provide(OidcTokenIssuer.layer),
160
+ );
161
+ ```
162
+
163
+ An `OidcTokenError` passes through `capture` untouched: whether an unattested publish is allowed is the action's policy, not this package's. `reason: "unavailable"` almost always means the workflow is missing `permissions: id-token: write`.
164
+
165
+ ## Reporting on GitHub surfaces
166
+
167
+ The other half of an action's job is saying what happened — on a pull request comment, a check-run summary or the job summary. `GitHubMarkdown` writes those bodies. Every member takes pre-rendered markdown and returns a string, but the structure around it goes through `@effected/markdown`'s serializer rather than string joining, so a cell carrying `>=1 || <2` escapes its pipes instead of shifting every column after it. `tableFor` goes further and takes the table's whole shape from a row schema:
168
+
169
+ ```ts
170
+ import { GitHubMarkdown } from "@effected/github-actions";
171
+ import { Schema } from "effect";
172
+
173
+ const Row = Schema.Struct({
174
+ name: Schema.String.annotate({ title: "Check" }),
175
+ detail: Schema.String,
176
+ });
177
+
178
+ console.log(GitHubMarkdown.tableFor(Row).render([{ name: "build", detail: "clean" }]));
179
+ // | Check | detail |
180
+ // | --- | --- |
181
+ // | build | clean |
182
+ ```
183
+
184
+ Column order is field declaration order, each header is the field's `title` annotation, and each cell is the field's encoded form — so a typed field projects through its own codec, and a row cannot transpose columns because it is an object rather than a positional array.
185
+
186
+ `ManagedDocument` owns named regions inside text a human also edits: a sentinel HTML comment identifies the document, marker comments delimit each region, and everything outside them survives byte-for-byte. Regions are replaced from current state rather than appended, which is what makes a sticky comment safe to re-render. `CheckDocument` puts a debounced reconciler on top — report a check as its state changes, and a background fiber projects the registry onto the document and writes it through a narrow sink:
187
+
188
+ ```ts
189
+ import { CheckDocument, CheckReport } from "@effected/github-actions";
190
+ import { Effect } from "effect";
191
+
192
+ const program = Effect.gen(function* () {
193
+ const doc = yield* CheckDocument;
194
+ yield* doc.report("build", CheckReport.make({ state: "running" }));
195
+ yield* doc.report("build", CheckReport.make({ state: "pass", outcome: "clean" }));
196
+ yield* doc.flush;
197
+ });
198
+ // one write carrying the final state; a render byte-identical to the last one writes nothing
199
+ ```
200
+
201
+ The debounce is trailing with a max-wait, so a burst of reports coalesces into one write carrying the *final* state while a steady stream still surfaces progress. `CheckState` is the vocabulary both of them speak, and it is deliberately wider than GitHub's conclusion set — `running` is a state rather than the absence of one, and `user_interaction_required` names a pipeline waiting on a human. `projectCheckState` maps each onto the wire form GitHub wants, as a status plus a conclusion exactly when the status is `completed`.
202
+
203
+ ## Testing
204
+
205
+ Every service ships `makeTest(overrides?)` and `layerTest(overrides?)`, with unstubbed members dying loudly and naming themselves — three recorded exceptions state why they default instead: `ActionEnvironment.makeTest` seeds the twelve `GITHUB_*`/`RUNNER_*` variables, `ActionLogger.makeTest` defaults to silent, and `DryRun.makeTest` defaults to rehearsing, the safe direction:
206
+
207
+ ```ts
208
+ import { ActionOutputs } from "@effected/github-actions";
209
+ import { Effect } from "effect";
210
+
211
+ const TestOutputs = ActionOutputs.layerTest({
212
+ set: () => Effect.void,
213
+ });
214
+ ```
215
+
216
+ `OidcTokenIssuer.layerFor(claims)` returns a real decodable unsigned JWT built from the same claims `claims()` reports, and `BlobStore.layerMemory` runs the real envelope framing — both exist because a synthetic double previously made the provenance path structurally untestable.
217
+
218
+ ## Features
219
+
220
+ - `Action.run` / `ActionRuntime.layer` — the entry point and default runtime: environment, logger, outputs, state, the Node platform and an `HttpClient`.
221
+ - `ActionInput` — typed input accessors (`string`, `boolean`, `integer`, `redacted`, `lines`, `list`, `pairs`, `schema`) sharing one absence rule, plus the `INPUT_`-aware `ConfigProvider` `Action.run` installs by default.
222
+ - `ActionOutputs` — step outputs, JSON outputs, the job summary, exported variables, `PATH` additions, failure annotations and log masking.
223
+ - `ActionState` / `ActionEnvironment` — persisted `pre`/`main`/`post` state, and the fiber-local `GITHUB_*`/`RUNNER_*` context read once from `process.env`.
224
+ - `ActionLogger` — collapsible groups, buffered step transcripts (`withBuffer({ onSuccess: "discard" })` keeps a green log to one line per step, while a failure, defect or interruption still flushes), `::notice::` annotations, and the `Logger` that renders every `Effect.log*` as a workflow command.
225
+ - `DryRun` — the rehearsal guard every mutation goes through, driven by the `dry-run` input by default.
226
+ - `Secret` — the one declassification seam between a `Redacted` value and a plain string, masking before it returns plaintext.
227
+ - `GitHubToken` — the App-token lifecycle shaped like the `pre`/`main`/`post` workflow: mint, verify scopes, persist, read, revoke.
228
+ - `ActionCache` / `Artifact` — the runner's cache and artifact protocols over Twirp v2, excluded from the default runtime so a consumer that skips them never links Azure.
229
+ - `CacheKey` — cache keys and their restore-key ladder, plus `hashFiles`/`matchingFiles`/`hashMatching` byte-compatible with `@actions/glob`.
230
+ - `OidcTokenIssuer` — the runner's OIDC token service, with unverified claim decoding for provenance predicates.
231
+ - `ActionsIdentityToken` / `ActionsProvenance` — the `@effected/sbom` seam: `layer` serves that package's `IdentityToken` contract from the runner's issuer, and `capture` builds a `SlsaProvenance` predicate out of the runner's OIDC claims.
232
+ - `GitHubMarkdown` — the escaping-safe writer for GitHub surfaces: `table`, `tableFor(schema)`, `heading`, `link`, `code`, `codeBlock`, `list`, `details` and `raw`, and the package's only importer of `@effected/markdown`.
233
+ - `ManagedDocument` — marker-delimited named regions in text a human also edits, for a sticky comment or a managed pull request description; content outside the regions survives byte-for-byte.
234
+ - `CheckState` / `projectCheckState` — the kit's check vocabulary, wider than GitHub's conclusions, and its projection onto the check-run wire form.
235
+ - `CheckDocument` — the debounced check-to-document reconciler: report states as they change, and one write lands carrying the final one.
236
+ - `ToolInstaller` — download, extract and cache a toolchain in the runner's tool cache, with no `@actions/tool-cache` dependency.
237
+ - `BlobStore` — durable `get`/`put`/`has` over bytes plus a metadata channel, backed by `layerS3` (SigV4-signed, no `@aws-sdk/*` dependency) or `GitHubCacheBlobStore.layer` (the runner's own cache); `layerMemory` runs the real envelope framing for tests.
238
+
239
+ ## License
240
+
241
+ [MIT](LICENSE)
package/Secret.js CHANGED
@@ -81,6 +81,19 @@ var Secret = class Secret {
81
81
  * over a `Redacted`, so a signing key has to become a string somewhere, and
82
82
  * the point of this module is that "somewhere" is here and nowhere else.
83
83
  *
84
+ * Signing named the member; it does not gate it. **Any in-process use that
85
+ * needs the raw value without writing it to a runner file is this
86
+ * operation** — handing a key to a library that takes a plain string. The
87
+ * dividing line is where the value goes, not what it is for: a value
88
+ * crossing into a **child's** environment is {@link Secret.forChildEnv},
89
+ * one written to `GITHUB_STATE` or `GITHUB_OUTPUT` is
90
+ * {@link Secret.forRunnerFile}, and one that stays in this process is this
91
+ * member. A third-party SDK that reads only the ambient environment is the
92
+ * hard case: this package never mutates `process.env` (reads are seeded
93
+ * once through `ActionEnvironment`), so if a consumer chooses that bridge,
94
+ * the mutation — and its restore discipline — lives in consumer code as
95
+ * the consumer's own tradeoff, not as a pattern this member recommends.
96
+ *
84
97
  * It masks even though the value is never *written* anywhere, and that is
85
98
  * deliberate rather than superstitious: a signing key that leaks does so
86
99
  * through something nobody audited — a debug log of outgoing headers, a