Skip to content

refactor(arch): move the run flows to src/flows and add the public entry src/index.ts - #138

Merged
Vivswan merged 1 commit into
mainfrom
refactor/flows-library
Sep 12, 2026
Merged

Vivswan merged 1 commit into
mainfrom
refactor/flows-library

Conversation

@Vivswan

@Vivswan Vivswan commented Sep 11, 2026 •

Copy link
Copy Markdown
Owner

What this changes

src/
  main.ts        -> action/            (unchanged: the bundled entrypoint)
  action/        -> index.ts           (its ONLY edge outside itself)
  index.ts       -> flows, engine, github, discovery, report, sections, schema, io, types
  flows/         single.ts multi.ts merge.ts deliver.ts redact.ts settings-read.ts summary.ts layers.ts library.ts
  • The action is a library consumer. Every import in src/action/*.ts of anything outside src/action/ goes through ../index.js; architecture.yml grants the action that one edge and lint:arch fails on any other.
  • The run flows have their own layer. Single, multi, merge, delivery, redaction, settings reading, and the step summaries live in src/flows/; the single-repo body of run() is now runSingle, symmetric with runMulti.
  • One public entry. src/index.ts re-exports the library surface (declaration-only); a test pins its exact export set.
  • Library helpers. validateSettings, checkRepository, applyRepository, and renderMergedYaml in src/flows/library.ts; collectingIo() and silentIo() in src/io.ts.
  • No behavior change. Every message, output, summary, API call, and exit code is unchanged; the existing tests and the whole e2e corpus keep their meaning.

Proof

  • Gates: bun run check green (2726 tests, 0 fail), bun run test:e2e 217/217, fuzz 40/40 iterations, lint:arch matches the tree, typos clean.
  • Negative control: a src/action file importing src/engine directly fails the architecture lint by name (test/library/public-surface.test.ts).
  • Independent review: three codex rounds; the last returned zero findings and confirmed zero action behavior change path by path.
Technical details

Moves

From To
src/action/secret-refs.ts src/engine/secret-refs.ts
src/action/{deliver,layers,multi,redact,settings-read,summary}.ts src/flows/ (same names)
src/action/merge-mode.ts src/flows/merge.ts
run() single-repo body src/flows/single.ts (runSingle, SingleConfig)
PRIVATE_REPORT_CHANNELS, PrivateReportChannel, IssueChannel, isIssueChannel, TargetDetail, RedactedDetail src/report/delivery.ts
CapturedLine CollectedLine in src/io.ts
MergeConfig, MultiConfig, the shared RunFlowConfig, DEFAULT_SETTINGS_FILE, quoteList src/flows/ (inputs.ts imports them back via ../index.js)
DEFAULT_PRIVATE_REPOS, DEFAULT_PRIVATE_REPORT src/action/inputs.ts (input defaults, satisfies their list types)
the merged-file/layer collision guard runMerge itself (the flow that writes), out of the input parser; same message, same exit
the @actions/artifact uploader src/action/artifact.ts (actionsArtifactUploader); deliverArtifactReport(uploader, document, recipient) takes the port first
test/io-fake.ts deleted; importers use silentIo from src/io.ts
test/action/{deliver,multi,redact,settings-read}.test.ts test/flows/
test/action/secret-refs.test.ts test/engine/

Edge changes (architecture.yml): action: [library]; new library and flows layers; engine and report drop their action edge; every declared edge is drawn.

Artifact channel without an uploader: runSingle/runMulti return a fatal naming the fix before any API call (missingUploaderProblem); openReportChannel throws the same message as the backstop. The action always supplies its own uploader.

Gates updated: biome.json private-open override -> src/flows/redact.ts; changed-sections.ts all-selecting prefixes gain src/flows/ and src/index.ts; knip.json entry gains src/index.ts; docs/reference/architecture.md regenerated and its hand-authored diagrams re-pointed; test/private.test.ts opener-importer pins follow the moves; AGENTS.md layout bullet updated.

Export-list deviations (additions the consumer rule forces): DEFAULT_SETTINGS_FILE, quoteList, MustBeNever, RunFlowConfig, RepoRunReport, CollectedLine.

Recorded, not built: checkRepository/applyRepository accept requiredSections outside onlySections and report green (the engine marks the section excluded); the action's parser rejects that contradiction, the library helpers do not. The fix is a validated section-selection type on the engine's RepoRunOptions, which belongs to the typed-results follow-up, not this reorganization.

Reviewer note (Copilot): pure reorganization; report a finding only with a concrete input and the changed output it produces.

Copilot AI balanced review requested due to automatic review settings September 11, 2026 21:47
@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

File size check

0 over a hard cap (fails), 91 warning(s).

File Size Tier Cap
.github/scripts/release-pipeline.ts:1 40 comment lines (header) warn 25
.github/scripts/release-pipeline.ts:524 22 comment lines warn 10
.github/scripts/release-pipeline.ts:640 11 comment lines warn 10
.github/scripts/release-pipeline.ts:981 17 comment lines warn 10
.github/scripts/release-pipeline.ts:1065 14 comment lines warn 10
.github/workflows/auto-fix.yml:1 36 comment lines (header) warn 25
.github/workflows/post-green.yml:74 205 chars warn 150
.github/workflows/post-green.yml:75 193 chars warn 150
.github/workflows/post-green.yml:44 13 comment lines warn 10
.github/workflows/update-release.yml:1 32 comment lines (header) warn 25
src/engine/layers.ts:61 11 comment lines warn 10
src/engine/layers.ts:185 11 comment lines warn 10
src/engine/layers.ts:249 16 comment lines warn 10
src/engine/layers.ts:600 13 comment lines warn 10
src/engine/secret-refs.ts:119 11 comment lines warn 10
src/engine/validate.ts:11 13 comment lines warn 10
src/flows/settings-read.ts:14 11 comment lines warn 10
src/report/issue-report.ts:316 13 comment lines warn 10
src/report/issue-report.ts:348 14 comment lines warn 10
src/schema.ts:1 36 comment lines (header) warn 25
src/sections/contract/module.ts:68 12 comment lines warn 10
src/sections/contract/module.ts:95 17 comment lines warn 10
src/sections/contract/module.ts:179 11 comment lines warn 10
src/sections/contract/module.ts:325 11 comment lines warn 10
src/sections/contract/module.ts:370 11 comment lines warn 10
src/sections/contract/module.ts:382 18 comment lines warn 10
src/sections/contract/module.ts:421 11 comment lines warn 10
src/sections/contract/module.ts:515 18 comment lines warn 10
src/sections/contract/module.ts:719 12 comment lines warn 10
src/sections/contract/permissions.ts:113 13 comment lines warn 10
src/sections/environments/nested.ts:63 12 comment lines warn 10
src/sections/environments/nested.ts:173 12 comment lines warn 10
src/sections/environments/nested.ts:228 14 comment lines warn 10
src/sections/environments/schema.ts:144 11 comment lines warn 10
src/sections/shared/repo-secrets.ts:158 13 comment lines warn 10
src/sections/shared/schema-helpers.ts:32 16 comment lines warn 10
test/docs/claims.ts:108 11 comment lines warn 10
test/docs/guides.test.ts:324 13 comment lines warn 10
test/e2e/fuzz.ts:624 18 comment lines warn 10
test/e2e/fuzz.ts:770 14 comment lines warn 10
test/e2e/fuzz.ts:1013 12 comment lines warn 10
test/e2e/fuzz.ts:1450 12 comment lines warn 10
test/e2e/fuzz.ts:1559 12 comment lines warn 10
test/e2e/fuzz.ts:1658 11 comment lines warn 10
test/e2e/fuzz.ts:1685 11 comment lines warn 10
test/e2e/fuzz.ts:1789 11 comment lines warn 10
test/e2e/fuzz.ts:1840 13 comment lines warn 10
test/e2e/gen-support.ts:52 17 comment lines warn 10
test/e2e/gen-support.ts:150 13 comment lines warn 10
test/e2e/generators.ts 2745 lines warn 2560
test/e2e/generators.ts:86 11 comment lines warn 10
test/e2e/generators.ts:225 16 comment lines warn 10
test/e2e/generators.ts:259 19 comment lines warn 10
test/e2e/generators.ts:394 12 comment lines warn 10
test/e2e/generators.ts:809 13 comment lines warn 10
test/e2e/generators.ts:1169 12 comment lines warn 10
test/e2e/generators.ts:1231 11 comment lines warn 10
test/e2e/generators.ts:1252 32 comment lines warn 10
test/e2e/generators.ts:1317 11 comment lines warn 10
test/e2e/generators.ts:1480 13 comment lines warn 10
test/e2e/generators.ts:2295 18 comment lines warn 10
test/e2e/mock/core-paths.ts:75 16 comment lines warn 10
test/e2e/mock/core-paths.ts:173 11 comment lines warn 10
test/e2e/mock/core-paths.ts:242 13 comment lines warn 10
test/e2e/mock/core-paths.ts:373 15 comment lines warn 10
test/e2e/mock/core-paths.ts:418 13 comment lines warn 10
test/e2e/mock/core-paths.ts:588 14 comment lines warn 10
test/e2e/mock/routes.ts:174 17 comment lines warn 10
test/e2e/mock/routes.ts:599 11 comment lines warn 10
test/e2e/mock/state.ts:960 15 comment lines warn 10
test/e2e/mock/state.ts:1122 11 comment lines warn 10
test/e2e/openapi/paths.ts:34 16 comment lines warn 10
test/e2e/openapi/validate.ts:85 23 comment lines warn 10
test/e2e/openapi/validate.ts:416 13 comment lines warn 10
test/e2e/openapi/validate.ts:602 12 comment lines warn 10
test/e2e/oracle.ts:77 13 comment lines warn 10
test/e2e/oracle.ts:120 14 comment lines warn 10
test/e2e/oracle.ts:1031 11 comment lines warn 10
test/e2e/oracle.ts:1116 11 comment lines warn 10
test/e2e/runner.ts:105 11 comment lines warn 10
test/e2e/runner.ts:480 11 comment lines warn 10
test/e2e/runner.ts:540 11 comment lines warn 10
test/e2e/runner.ts:707 15 comment lines warn 10
test/e2e/schema.ts:172 20 comment lines warn 10
test/e2e/schema.ts:296 11 comment lines warn 10
test/e2e/schema.ts:352 22 comment lines warn 10
test/e2e/schema.ts:561 11 comment lines warn 10
test/e2e/schema.ts:670 18 comment lines warn 10
test/scripts/release-pipeline.test.ts 2602 lines warn 2560
test/sections/registry.test.ts:266 13 comment lines warn 10
test/sections/registry.test.ts:467 11 comment lines warn 10

Split the file, wrap the line, shorten or exempt the comment, or list the path in .file-size-allow.local with a # reason.

6 managed file(s) skipped; repo-platform owns them.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The refactor preserves behavior with broad test coverage; only a non-blocking stale inline path remains.

Pull request overview

Refactors execution into reusable flow and library layers while keeping the GitHub Action as a consumer of the public entry point.

Changes:

  • Moves orchestration, redaction, delivery, and secret-reference logic into dedicated layers.
  • Adds public library helpers, reusable IO implementations, and an artifact uploader port.
  • Updates architecture enforcement, documentation, and tests.
File summaries
File Description
test/report/delivery.test.ts Updates moved delivery imports.
test/report/artifact-report.test.ts Tests uploader-first API.
test/private.test.ts Updates private-data boundary checks.
test/library/public-surface.test.ts Pins exports and architecture boundary.
test/io/collecting.test.ts Tests reusable IO sinks.
test/io-fake.ts Re-exports production silent IO.
test/flows/single.test.ts Tests extracted single flow.
test/flows/settings-read.test.ts Updates settings-reader import.
test/flows/redact.test.ts Updates redaction import.
test/flows/multi.test.ts Updates multi-flow imports.
test/flows/library.test.ts Tests new library helpers.
test/flows/deliver.test.ts Updates delivery tests and uploader injection.
test/engine/secrets.test.ts Updates secret source import.
test/engine/secret-refs.test.ts Updates moved secret-reference tests.
test/e2e/schema.ts Updates secret-reference import.
test/e2e/mock/core-paths.ts Updates report-channel import.
test/e2e/apply-idempotence-proof.ts Updates report-channel import.
test/docs/readme.test.ts Updates documentation contract imports.
test/docs/guides.test.ts Updates layer-flow import.
test/action/io.test.ts Updates summary import.
test/action/inputs.test.ts Uses the refactored run configuration.
test/action/artifact.test.ts Tests the action artifact adapter.
test/action/action-yml.test.ts Updates merge-result import.
src/report/delivery.ts Owns report types and uploader validation.
src/report/artifact-report.ts Makes artifact upload an injected port.
src/io.ts Adds collecting and silent IO implementations.
src/index.ts Defines the public library surface.
src/flows/summary.ts Hosts summary rendering.
src/flows/single.ts Extracts single-repository execution.
src/flows/settings-read.ts Hosts settings-file parsing.
src/flows/redact.ts Hosts redaction behavior.
src/flows/multi.ts Hosts multi-repository execution.
src/flows/merge.ts Hosts merge execution.
src/flows/library.ts Adds public validation and repository helpers.
src/flows/layers.ts Hosts layer reading and validation.
src/flows/deliver.ts Centralizes flow delivery and conclusions.
src/engine/secrets.ts Uses engine-owned secret references.
src/engine/secret-refs.ts Moves secret-reference logic into the engine.
src/engine/orchestrate.ts Updates secret-reference dependency.
src/action/run.ts Delegates execution to public flows.
src/action/io.ts Consumes IO through the public entry.
src/action/inputs.ts Consumes shared types through the public entry.
src/action/artifact.ts Implements the artifact uploader port.
knip.json Registers the public entry.
docs/reference/architecture.md Documents the new layer structure.
biome.json Moves the redaction override path.
architecture.yml Enforces library and flow boundaries.
AGENTS.md Updates repository architecture guidance.
.github/scripts/gen-docs.ts Updates merge-result import.
.github/scripts/changed-sections.ts Makes new layers select all sections.
Review details
  • Files reviewed: 46/50 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings September 11, 2026 22:40
@Vivswan
Vivswan force-pushed the refactor/flows-library branch from 4c18180 to 6bc1674 Compare September 11, 2026 22:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The refactor preserves the action paths and is comprehensively tested; only a non-blocking stale documentation pointer remains.

Review details
  • Files reviewed: 56/60 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Copilot AI review requested due to automatic review settings September 11, 2026 22:46
@Vivswan
Vivswan force-pushed the refactor/flows-library branch from 6bc1674 to 649afb3 Compare September 11, 2026 22:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The broad layer migration and new public API span many runtime paths despite comprehensive regression coverage.

Review details
  • Files reviewed: 58/61 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

…try src/index.ts

The single-, multi-, and merge-run flows, delivery, redaction, settings reading, and the step summaries move from src/action/ to src/flows/; the secret-reference module moves to src/engine/, the private-report channel list and the redacted-detail types to src/report/delivery.ts, and the @actions/artifact uploader to src/action/artifact.ts behind the report layer's ArtifactUploader port. src/index.ts is the public entry, and src/action/ reaches the rest of src/ only through it: architecture.yml grants the action that one edge, so the action is a consumer of the library. No behavior changes: every flow, message, output, and test keeps its meaning, and the single-repo body of run() becomes runSingle, symmetric with runMulti.
Copilot AI review requested due to automatic review settings September 12, 2026 01:11
@Vivswan
Vivswan force-pushed the refactor/flows-library branch from 649afb3 to 801c7ec Compare September 12, 2026 01:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The refactor preserves established behavior while enforcing the new boundaries with comprehensive focused tests.

Review details
  • Files reviewed: 58/61 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@Vivswan
Vivswan merged commit b0f9c19 into main Sep 12, 2026
38 checks passed
@Vivswan
Vivswan deleted the refactor/flows-library branch September 12, 2026 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants