@oxface/modular-monolith-patterns 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (2026-11-28)
4
+
5
+
6
+ ### Features
7
+
8
+ * add durable scheduling and projection capabilities ([7010274](https://github.com/oxface/gloaming/commit/7010274fe1e3884323df0fcec93e2502257a4170))
9
+ * gloaming library audit ([329ecee](https://github.com/oxface/gloaming/commit/329ecee56f178f8d111af71acde7c0e10188649e))
10
+ * gloaming library audit merge ([329ecee](https://github.com/oxface/gloaming/commit/329ecee56f178f8d111af71acde7c0e10188649e))
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,100 @@
1
- # Temporary Holding Version
1
+ # Modular monolith patterns
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Apply these documents to a consuming application's repository. They describe a preferred
4
+ structure and implementation process, not a generated template or required Gloaming runtime.
5
+ The documents can be read in place or copied as one folder; implementation instructions
6
+ use sibling documents and public library contracts.
7
+
8
+ ## Install the skill
9
+
10
+ The npm distribution is `@oxface/modular-monolith-patterns`; its first planned public version
11
+ is 0.1.0. Select an actually published version, then run from the consuming repository:
12
+
13
+ ```sh
14
+ npx --yes @oxface/modular-monolith-patterns@VERSION install --dry-run
15
+ npx --yes @oxface/modular-monolith-patterns@VERSION install
16
+ ```
17
+
18
+ Installation creates `.agents/skills/modular-monolith-patterns/` with `SKILL.md` and all
19
+ supporting documents. `--target PATH` selects another explicit skill directory. `--update`
20
+ replaces an unchanged managed installation after review; edited, unmanaged or additional files
21
+ are preserved through a conflict. Symlink destinations/ancestors are rejected. Dry runs create
22
+ no destination folders. The installer changes no project manifests, agent instructions or
23
+ Git index. Reload the consuming agent's skill discovery when needed.
24
+
25
+ The bundle is built from these source documents, with repository links pinned to its source
26
+ revision. Installation performs no network fetch; npm obtains the package first. Node24 is
27
+ the supported runtime, and the packed-package installation proofs currently run on Linux.
28
+ See [release delivery](https://github.com/oxface/gloaming/blob/main/docs/releases.md) for
29
+ publication and [local checks](#develop-the-distribution) before a public version exists.
30
+
31
+ A request can be as small as:
32
+
33
+ > Explore the documentation in /modular-monolith-patterns and apply it to this repository.
34
+ > Start with modules X (AggregateA, AggregateB) and Y (AggregateE with event sourcing).
35
+
36
+ ## Start here
37
+
38
+ 1. Inspect the target repository's instructions, solution, tooling, existing architecture and
39
+ working changes. Establish the application name, requested modules/aggregate roots, persistence
40
+ choice per aggregate and the first behavior to prove. Preserve unrelated work.
41
+ 2. Read [structure](structure.md). Adapt an existing application toward the boundaries; keep
42
+ working public behavior and current project conventions unless the request changes them.
43
+ 3. For initialization or missing host infrastructure, follow [bootstrap](bootstrap.md).
44
+ For a selected .NET/React/Vite browser application, also follow the
45
+ [stack profile](dotnet-react-vite.md); API and worker applications use the general steps.
46
+ For requested modules/aggregates, follow [modules](modules.md) and the relevant persistence
47
+ branch. Follow [messaging](messaging.md) when durable handoff or command receipts are selected. For Kafka transport adoption, use the
48
+ [native Kafka recipe](kafka.md).
49
+ 4. Resolve [library integration](gloaming.md) against the package versions actually being used.
50
+ Essential contracts remain with each library. Implement one runnable path through the selected
51
+ modules, native persistence and host.
52
+ 5. Complete [verification](verification.md). Record the resulting module map, infrastructure and
53
+ transaction ownership in the target application's architecture documentation.
54
+
55
+ For a first protected state-stored module, follow the [first-module walkthrough](first-module.md).
56
+ It connects package selection, HTTP context, native persistence, audit and the first acceptance
57
+ checks using existing executable examples.
58
+
59
+ The target repository's instructions and explicit user decisions take precedence over these
60
+ defaults. Ask for missing decisions that change business meaning or require credentials; continue
61
+ independent setup while those answers are pending. State ordinary technical assumptions clearly.
62
+
63
+ ## Interpret the request
64
+
65
+ The example selects two modules, not three projects for three aggregates:
66
+
67
+ | Module | Aggregate roots | Persistence |
68
+ | ------ | ---------------------- | -------------------------------------------------- |
69
+ | X | AggregateA, AggregateB | Native state-stored EF by default |
70
+ | Y | AggregateE | Event-sourced aggregate with required inline state |
71
+
72
+ Each module owns a context, schema, migrations and named connection. Aggregate boundaries stay
73
+ inside their module; another module calls its Contracts. A module can mix persistence styles
74
+ when explicitly required. API style is an application choice; match the existing style, using
75
+ minimal APIs for a new HTTP host unless requested otherwise.
76
+
77
+ When only aggregate names are supplied, establish the named boundaries and a minimal labelled
78
+ create/load example. Keep business invariants and additional process stages tied to actual
79
+ requirements. A timer, saga, broker or cross-module write is not implied by having two modules.
80
+
81
+ ## Completion
82
+
83
+ The requested modules are registered and reachable through real application operations.
84
+ Chosen persistence and migrations work; required identity/tenant context is established; tests
85
+ prove accepted/rejected work, isolation and rollback. The report names commands actually run,
86
+ remaining configuration and unsupported behavior. An empty project graph alone is not completion.
87
+ The browser stack profile adds tooling, generated-client and isolated browser acceptance checks;
88
+ these documents remain implementation guidance, not an installable template.
89
+
90
+ ## Develop the distribution
91
+
92
+ ```sh
93
+ npm ci --prefix modular-monolith-patterns --ignore-scripts
94
+ npm --prefix modular-monolith-patterns run check
95
+ ```
96
+
97
+ Run from the Gloaming checkout. The checks compile the installer, build the reference bundle,
98
+ pack an actual tarball, and install/test that tarball in separate temporary consumer repositories.
99
+ The package contains no runtime npm dependencies or install lifecycle hooks. Local bundles
100
+ record dirty-source status; hosted release preparation requires clean committed tag inputs.
package/SKILL.md ADDED
@@ -0,0 +1,29 @@
1
+ ---
2
+ name: modular-monolith-patterns
3
+ description: Initialize or adapt a .NET modular monolith, add business modules and aggregates, or wire durable handoff using consumer-owned Contracts, persistence and native hosts.
4
+ ---
5
+
6
+ Use these application patterns for the requested module map and behavior. The target
7
+ repository's instructions and explicit user choices take precedence over the defaults.
8
+
9
+ Start with [the application workflow](README.md#start-here) and
10
+ [module ownership](structure.md). Inspect the existing solution and working changes before
11
+ choosing projects or dependencies. Establish the requested business boundaries and persistence
12
+ choice per aggregate; additional process stages require application requirements.
13
+
14
+ Read only the branches needed for the requested change:
15
+
16
+ - Host initialization: [bootstrap](bootstrap.md), plus the
17
+ [.NET/React/Vite profile](dotnet-react-vite.md) when that browser stack is selected.
18
+ - Module or aggregate work: [modules](modules.md). For a first protected state-stored
19
+ operation, use [the first-module walkthrough](first-module.md).
20
+ - Durable cross-module work: [messaging](messaging.md). Select the
21
+ [Kafka recipe](kafka.md), [entity-work exclusion](entity-work.md) or
22
+ [PostgreSQL wakeups](postgres-wakeups.md) when their protocols are needed.
23
+ - Gloaming adoption: [library integration](gloaming.md), checked against the package
24
+ versions actually consumed. Application structure and business policy remain consumer-owned.
25
+
26
+ Complete [verification](verification.md) for the selected path. Deliver an executable
27
+ consumer operation, relevant failure proofs and an application architecture record identifying
28
+ module, schema, credential and transaction ownership. Report executed checks, remaining
29
+ configuration and supported limits; project scaffolding alone does not establish working behavior.
package/bootstrap.md ADDED
@@ -0,0 +1,117 @@
1
+ # Initialize or adapt an application
2
+
3
+ Read [structure](structure.md) first. Use native .NET/Aspire tools and the target repository's
4
+ existing package/tool manifests. This task establishes runnable composition and the first
5
+ requested behavior; it does not copy Gloaming sources into the application.
6
+
7
+ ## 1. Establish tooling and package consumption
8
+
9
+ Choose a solution/application name and compatible .NET target, then pin the SDK and central
10
+ package versions. Match existing nullable, analyzer and test-runner conventions. Add ordinary
11
+ build/test commands, formatting and CI appropriate to the selected projects.
12
+ Supply pinned tool manifests, editor configuration, generated-file policies and root commands
13
+ together. The initial handwritten scaffold must pass its own formatting and analyzer checks.
14
+ Hooks check reviewed staged content without formatting or re-staging the index. The
15
+ [browser stack profile](dotnet-react-vite.md) supplies the selected frontend/tooling defaults.
16
+
17
+ Consume selected Gloaming packages through ordinary PackageReferences.
18
+ [Library integration](gloaming.md) describes hosted package selection and capability integration.
19
+ Inspect package framework/API compatibility before copying a snippet from another version.
20
+ Account for the [distribution boundary](gloaming.md#distribution-boundary): pin published
21
+ versions, retain locks and verify clean consumer restore and application acceptance.
22
+
23
+ Done: restore/build uses the intended SDK and selected package versions, without source
24
+ ProjectReferences back into the Gloaming checkout.
25
+
26
+ ## 2. Compose native hosts
27
+
28
+ Create or adapt:
29
+
30
+ - Server: native ASP.NET Core entry point, endpoints, authentication/authorization, module
31
+ registration and selected operational health/telemetry.
32
+ - Migrator: finite executable that applies the requested module migrations/provisioning,
33
+ reports failure and exits. It uses setup credentials and does not serve application traffic.
34
+ - Worker: native host for explicitly selected background roles. Add work only for an actual
35
+ requirement; name its roles and establish a fresh operation scope for each turn.
36
+ - AppHost: local resource graph and references for the application, database, optional identity
37
+ provider, migrator and selected workers.
38
+ - ServiceDefaults: consumer-owned shared native telemetry/health setup when useful to these hosts.
39
+
40
+ Prefer C# SDK-style AppHost projects under `orchestration/local`, included in the main solution
41
+ for project-aware editing and solution restore/build. Keep existing working orchestration when
42
+ adapting another stack. Use explicit runnable project references; mark shared orchestration
43
+ library references with `IsAspireProjectResource="false"`. Create sibling E2E or publishing hosts
44
+ when their behavior is needed, sharing application wiring while keeping lifecycle/data ownership
45
+ separate. Preserve secret identities, volume names and public endpoints during host conversions.
46
+
47
+ Use separate named connection options per module and per restricted role. Runtime startup
48
+ registers services; it does not silently migrate, seed or grant database privileges.
49
+ Development example data is a separately selected finite operation.
50
+ The finite Migrator invokes explicit module setup entry points; each module owns its migrations
51
+ and schema-specific grants. Hosts own infrastructure provisioning. Readiness probes use actual
52
+ runtime connections/credentials; migration completion and tests separately prove schema setup.
53
+
54
+ Done: each selected executable builds and has one clear role. Startup failures are visible.
55
+ Database-dependent hosts wait for required resources and successful migration completion in
56
+ local orchestration.
57
+
58
+ ## 3. Wire identity and tenant admission
59
+
60
+ Use native ASP.NET Core authentication, including cookie/OIDC when a browser login is requested.
61
+ Authority, client IDs, redirect/logout URIs, trust and secrets are application configuration.
62
+ Store secrets through the target's chosen secret mechanism.
63
+
64
+ Map authenticated identity explicitly into application identity/actor context.
65
+ Choose tenantless or selected-tenant execution deliberately. Tenant membership/admission and
66
+ resource permissions belong to the application; a tenant key is not permission.
67
+ Treat the route/header tenant as a candidate until admission succeeds. Gloaming tenant keys
68
+ are opaque; GUID requirements, slug lookup and membership rules are application policy.
69
+
70
+ When first login creates an application user, key external identity by the validated issuer
71
+ and subject, with a native unique constraint. Concurrent registration must recover the same
72
+ account from fresh state after a conflicting transaction. When registration is audited, stage
73
+ that audit in the same transaction so only the accepted registration's audit remains.
74
+ Establish request account state once and guard reads until establishment is complete. Keep this
75
+ pre-admission registry separate from tenant-owned business persistence.
76
+
77
+ Read the selected [HTTP/context contracts](gloaming.md) for ordering. Authentication and effective
78
+ policy evaluation precede actor completion; tenant admission is completed before protected
79
+ module work. The module owns late resource checks. Configure native authorization and
80
+ antiforgery for the chosen HTTP interaction.
81
+ Module operations check current authority for direct Contracts callers as well as HTTP callers.
82
+ Membership suspension can revoke one organization's access while preserving the signed-in
83
+ global account and other memberships; use the application's actual revocation policy.
84
+
85
+ For browser cookies, configure persistent native Data Protection and prove a restart preserves
86
+ the session. Replicas of one application/environment share the intended keyring and discriminator;
87
+ independently trusted hosts/environments have separate rings. The
88
+ [browser security recipe](dotnet-react-vite.md#browser-authentication-and-serving) covers local
89
+ storage, OIDC logout and proxy composition; production storage/access/key protection stay explicit.
90
+
91
+ If the actual issuer or account/membership model is undecided, expose the configuration seam
92
+ and record the missing decision. Protected business operations require a real admitted context;
93
+ a placeholder identity must not silently authorize production work.
94
+
95
+ Done: tests prove authorized/unauthorized paths and context establishment. When an actual local
96
+ OIDC provider is configured, prove login/callback, one protected operation and logout with that
97
+ provider through the chosen frontend origin.
98
+
99
+ ## 4. Add the requested modules
100
+
101
+ Follow [modules](modules.md). Register every module explicitly in Server and the appropriate
102
+ Worker/Migrator. The host supplies native options; a module does not discover other modules,
103
+ choose global transport or configure the application's authentication provider.
104
+
105
+ The [first-module walkthrough](first-module.md) connects these steps for one protected
106
+ state-stored operation with transactional audit.
107
+
108
+ Wire the first real endpoint/operation for each requested module. Keep sample aggregate behavior
109
+ minimal when the request supplies only names.
110
+
111
+ Done: the first requested create/load path reaches native module persistence through Contracts.
112
+
113
+ ## 5. Complete application verification
114
+
115
+ Follow [verification](verification.md). Exercise migration failure/startup ordering, native
116
+ rollback and required tenant isolation. Use real infrastructure for guarantees that depend on it.
117
+ Document exact local setup and selected production integration obligations.
package/dist/cli.js ADDED
@@ -0,0 +1,137 @@
1
+ #!/usr/bin/env node
2
+ import assert from "node:assert/strict";
3
+ import { createHash } from "node:crypto";
4
+ import { existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync, } from "node:fs";
5
+ import { basename, dirname, join, resolve } from "node:path";
6
+ import { parseArgs } from "node:util";
7
+ const name = "@oxface/modular-monolith-patterns";
8
+ const marker = ".gloaming-skill.json";
9
+ const source = resolve(import.meta.dirname, "skill");
10
+ const hash = (bytes) => createHash("sha256").update(bytes).digest("hex");
11
+ function requireBundle(value) {
12
+ const bundle = value;
13
+ assert(bundle && bundle.schemaVersion === 1 && bundle.name === name, "Unrecognized managed skill bundle.");
14
+ assert(typeof bundle.version === "string" &&
15
+ /^\d+\.\d+\.\d+(?:-[a-z0-9.-]+)?$/.test(bundle.version));
16
+ assert(bundle.files &&
17
+ !Array.isArray(bundle.files) &&
18
+ typeof bundle.files === "object");
19
+ const files = Object.entries(bundle.files);
20
+ assert(files.length > 0 && files.length <= 100 && bundle.files["SKILL.md"]);
21
+ for (const [file, digest] of files) {
22
+ assert(/^[A-Za-z0-9][A-Za-z0-9-]*\.md$/.test(file), "Managed paths must be sibling Markdown files.");
23
+ assert(typeof digest === "string" && /^[a-f0-9]{64}$/.test(digest));
24
+ }
25
+ }
26
+ function rejectSymlinks(path) {
27
+ for (let selected = resolve(path);; selected = dirname(selected)) {
28
+ const entry = lstatSync(selected, { throwIfNoEntry: false });
29
+ assert(!entry?.isSymbolicLink(), `Refuse symbolic-link destination: ${selected}`);
30
+ if (dirname(selected) === selected)
31
+ break;
32
+ }
33
+ }
34
+ function readFiles(directory, bundle) {
35
+ const files = new Map();
36
+ for (const [file, digest] of Object.entries(bundle.files)) {
37
+ const path = join(directory, file);
38
+ const entry = lstatSync(path);
39
+ assert(entry.isFile() && !entry.isSymbolicLink(), `Refuse non-file skill input: ${file}`);
40
+ const bytes = readFileSync(path);
41
+ assert.equal(hash(bytes), digest, `Skill file differs from managed content: ${file}`);
42
+ files.set(file, bytes);
43
+ }
44
+ return files;
45
+ }
46
+ function install(target, dryRun, update) {
47
+ const bundle = JSON.parse(readFileSync(join(source, "bundle.json"), "utf8"));
48
+ requireBundle(bundle);
49
+ const files = readFiles(source, bundle);
50
+ rejectSymlinks(target);
51
+ const destination = resolve(target);
52
+ let existing;
53
+ if (existsSync(destination)) {
54
+ assert(lstatSync(destination).isDirectory(), "The destination must be a skill directory.");
55
+ const manifest = join(destination, marker);
56
+ assert(existsSync(manifest) && !lstatSync(manifest).isSymbolicLink(), "Refuse to replace an unmanaged skill directory.");
57
+ const managed = JSON.parse(readFileSync(manifest, "utf8"));
58
+ requireBundle(managed);
59
+ readFiles(destination, managed);
60
+ assert.deepEqual(readdirSync(destination).sort(), [...Object.keys(managed.files), marker].sort(), "Preserve additional user files; choose another destination.");
61
+ if (JSON.stringify(managed.files) === JSON.stringify(bundle.files) &&
62
+ managed.version === bundle.version) {
63
+ console.log(`Already installed ${name}@${bundle.version}: ${destination}`);
64
+ return;
65
+ }
66
+ assert(update, "A different managed version exists. Use --update after reviewing the change.");
67
+ existing = managed;
68
+ }
69
+ console.log(`${dryRun ? "Would install" : "Installing"} ${name}@${bundle.version}: ${destination}`);
70
+ if (dryRun)
71
+ return;
72
+ mkdirSync(dirname(destination), { recursive: true });
73
+ rejectSymlinks(destination);
74
+ const temporary = mkdtempSync(join(dirname(destination), `.${basename(destination)}-`));
75
+ const previous = join(temporary, "previous");
76
+ let moved = false;
77
+ let installed = false;
78
+ try {
79
+ const staged = join(temporary, "skill");
80
+ mkdirSync(staged);
81
+ for (const [file, bytes] of files)
82
+ writeFileSync(join(staged, file), bytes, { flag: "wx" });
83
+ writeFileSync(join(staged, marker), JSON.stringify(bundle, null, 2) + "\n", { flag: "wx" });
84
+ if (existing) {
85
+ rejectSymlinks(destination);
86
+ readFiles(destination, existing);
87
+ assert.deepEqual(readdirSync(destination).sort(), [...Object.keys(existing.files), marker].sort(), "The installed skill changed during preparation.");
88
+ renameSync(destination, previous);
89
+ moved = true;
90
+ }
91
+ else
92
+ assert(!existsSync(destination), "The destination appeared during preparation; preserve it.");
93
+ renameSync(staged, destination);
94
+ installed = true;
95
+ }
96
+ catch (error) {
97
+ if (moved && !existsSync(destination)) {
98
+ renameSync(previous, destination);
99
+ moved = false;
100
+ }
101
+ throw error;
102
+ }
103
+ finally {
104
+ // Preserve the recovery copy if restoring an interrupted update itself failed.
105
+ if (installed || !moved)
106
+ rmSync(temporary, { recursive: true, force: true });
107
+ }
108
+ console.log(`Installed ${files.size} documents. Reload the agent's skill discovery if needed.`);
109
+ }
110
+ try {
111
+ const { values, positionals } = parseArgs({
112
+ options: {
113
+ target: { type: "string" },
114
+ "dry-run": { type: "boolean" },
115
+ update: { type: "boolean" },
116
+ version: { type: "boolean" },
117
+ help: { type: "boolean" },
118
+ },
119
+ allowPositionals: true,
120
+ });
121
+ if (values.version) {
122
+ const bundle = JSON.parse(readFileSync(join(source, "bundle.json"), "utf8"));
123
+ requireBundle(bundle);
124
+ console.log(`${name}@${bundle.version}`);
125
+ }
126
+ else if (values.help || positionals.length === 0) {
127
+ console.log("Usage: modular-monolith-patterns install [--target PATH] [--dry-run] [--update]\nDefault: .agents/skills/modular-monolith-patterns in the current project. Existing edits are preserved.");
128
+ }
129
+ else {
130
+ assert.deepEqual(positionals, ["install"], "Choose the install command.");
131
+ install(values.target ?? ".agents/skills/modular-monolith-patterns", values["dry-run"] ?? false, values.update ?? false);
132
+ }
133
+ }
134
+ catch (error) {
135
+ console.error(error instanceof Error ? error.message : "Skill installation failed.");
136
+ process.exitCode = 1;
137
+ }
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (2026-11-28)
4
+
5
+
6
+ ### Features
7
+
8
+ * add durable scheduling and projection capabilities ([7010274](https://github.com/oxface/gloaming/commit/7010274fe1e3884323df0fcec93e2502257a4170))
9
+ * gloaming library audit ([329ecee](https://github.com/oxface/gloaming/commit/329ecee56f178f8d111af71acde7c0e10188649e))
10
+ * gloaming library audit merge ([329ecee](https://github.com/oxface/gloaming/commit/329ecee56f178f8d111af71acde7c0e10188649e))