Skip to content

Commit d55f292

Browse files
committed
docs: update CONTRIBUTING guidelines for branching strategy and project structure
1 parent b4e9ea5 commit d55f292

File tree

1 file changed

+23
-95
lines changed

1 file changed

+23
-95
lines changed

CONTRIBUTING.md

Lines changed: 23 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -37,44 +37,26 @@ Compilers are detected in the following order:
3737
3838
## Branching Strategy
3939
40-
This is basically a Git Flow with some adjustment to fit the NPM release process:
41-
42-
| Branch | Release | Created From | Merge To |
43-
| ---------------- | ----------------- | ------------ | -------------------- |
44-
| `develop` | | | `release` |
45-
| `feature-<name>` | | `develop` | `develop` |
46-
| `main` | `#.#.#` | | |
47-
| `release` | `#.#.#-release.#` | `main` | `main` and `develop` |
48-
49-
## Project Structure
50-
51-
The project is structured as follows:
52-
53-
```plaintext
54-
├── 📁 source
55-
│ ├── 📁 algorithms
56-
│ │ └── 📁 [algorithm]
57-
│ ├── 📁 shared
58-
│ ├── 📁 key-encryption
59-
│ ├── command.ts. # entrypoint for CLI
60-
│ └── entry-point.ts # package public exports only
61-
├── 📁 scripts
62-
└── 📁 build
63-
```
40+
This repository follows a simple [GitHub Flow](https://docs.github.com/en/get-started/using-github/github-flow) with some naming conventions to trigger [Semantic Release](https://github.com/semantic-release/semantic-release) for releases:
41+
42+
| Branch | Release | Created From | Merge To |
43+
| ---------------- | ------- | ------------ | -------- |
44+
| `feature-<name>` | | `main` | `main` |
45+
| `main` | `#.#.#` | | |
6446
6547
## Commands
6648
6749
[NPM scripts](./package.json) are organized with [ESLint Package.json Conventions](https://eslint.org/docs/latest/contribute/package-json-conventions):
6850
6951
| Command | Purpose |
7052
| -------------------- | --------------------------------------------------------------- |
71-
| `build` | Build wasm binaries, TypeScript output, and wasm assets. |
53+
| `build` | Build WASM binaries, TypeScript output, and WASM assets. |
7254
| `build:clean` | Remove generated build directories. |
7355
| `build:typescript` | Compile TypeScript and rewrite path aliases. |
7456
| `build:wasm` | Compile algorithm `main.c` files to `main.wasm` when available. |
75-
| `build:wasm-assets` | Copy generated wasm binaries to build output tree. |
76-
| `build:wasm:check` | Validate wasm artifacts and execute wasm smoke checks. |
77-
| `build:wasm:strict` | Compile wasm and fail when wasm compilation is unavailable. |
57+
| `build:wasm-assets` | Copy generated WASM binaries to build output tree. |
58+
| `build:wasm:check` | Validate WASM artifacts and execute WASM smoke checks. |
59+
| `build:wasm:strict` | Compile WASM and fail when WASM compilation is unavailable. |
7860
| `release` | Run semantic-release for tags, GitHub release, and npm publish. |
7961
| `start:cli` | Run CLI directly from TypeScript sources. |
8062
| `start:cli:compiled` | Run CLI from compiled build output. |
@@ -83,85 +65,31 @@ The project is structured as follows:
8365
8466
## WebAssembly Behavior
8567
86-
<!--
87-
Some notes on WebAssembly behavior and guardrails:
88-
89-
- Generated `.wasm` files are ignored on purpose
90-
- NPM scripts skip WASM generation when no compiler is detected, unless `WASM_STRICT` is used to fail immediately
91-
- If WASM is unavailable at runtime (Algorithms attempt to use its own compiled `main.wasm`), code falls back to TypeScript automatically
92-
-->
93-
94-
Some notes on WebAssembly behavior and guardrails:
68+
Per-algorithm notes on WebAssembly behavior and guardrails:
9569
9670
```mermaid
9771
flowchart TD
98-
A[Run build:wasm] --> B{Compiler found?}
72+
A[Build WASM] --> B{Is compiler found?}
9973
B -->|Yes| C[Compile main.c to main.wasm]
100-
B -->|No| D{WASM_STRICT set?}
74+
B -->|No| D{Is WASM_STRICT set?}
10175
D -->|Yes| E[Fail build immediately]
102-
D -->|No| F[Skip wasm generation]
103-
C --> G[Do not commit generated .wasm files]
104-
F --> H[Runtime uses TypeScript fallback]
105-
C --> I{WASM loads at runtime?}
76+
D -->|No| F[Skip WASM generation]
77+
F --> R
78+
C --> R[Runtime]
79+
R --> I{Is WASM loaded at runtime?}
10680
I -->|Yes| J[Use compiled main.wasm]
107-
I -->|No| H
81+
I -->|No| K[Fallback to TypeScript implementation]
10882
```
10983
110-
## Coding conventions
111-
112-
<!--
113-
- Each algorithm folder contains:
114-
- `index.ts` (TypeScript implementation)
115-
- `index.test.ts` (tests)
116-
- `main.c` (WASM source)
117-
- Use default export for each algorithm function in `index.ts`.
118-
- Use a shared higher-order WASM wrapper under `source/shared/wasm.ts` for runtime loading only.
119-
- Use `@/` imports for code under `source/` (configured in `tsconfig.json`).
120-
- Do not import internal code from `@/entry-point`; import directly from `@/<folder>` (e.g., `@/algorithms/...`).
121-
- Keep algorithm APIs stable and deterministic for tests.
122-
-->
123-
124-
Each algorithm folder contains:
125-
126-
```plaintext
127-
├── index.ts # algorithm implementation
128-
├── index.test.ts # tests
129-
└── main.c # algorithm implementation in C for WASM compilation
130-
```
131-
132-
- Use `export default function main` for each algorithm implementation
133-
1. Check if WASM (`main.wasm` compiled from `main.c`) is available with a global generic wrapper
134-
2. If available, proceed with WASM implementation
135-
1. Check input prerequisites in C
136-
2. Errors thrown in C should be propagated and handled in TypeScript
137-
- Friendly error messages are provided in C already
138-
3. If not available, fall back to TypeScript implementation
139-
1. Check input prerequisites in TypeScript
140-
2. Errors thrown in TypeScript should be consistent with C error messages when the same input is given
141-
- Use `export async function prompt` for each algorithm CLI demonstration
142-
- Use `@/*` imports for code under `source/*`
143-
- Do not import internal code from `@/entry-point`
144-
- Keep algorithm APIs stable and deterministic for tests
145-
14684
## Workflows
14785
148-
<!--
149-
- `Test`: runs on every push and executes `npm run test:coverage -- --ci --runInBand --verbose`.
150-
- `Publish`: runs on every push to `main` using Node.js 25 and semantic-release.
151-
- `Release`: runs on every push to `main` using Node.js 25 and semantic-release.
152-
-->
153-
15486
```mermaid
155-
flowchart LR
87+
flowchart TB
15688
A[Push event] --> B[Test workflow]
157-
B --> C[Runs on every push]
158-
B --> D[Artifact: validation result]
159-
A --> E{Main branch?}
89+
B --> D[/Test reports/]
90+
A --> E{Is it in main?}
16091
E -->|Yes| F[Publish workflow]
161-
F --> G[Triggered by pushes to main]
162-
F --> H[Artifacts: package publish and release metadata]
92+
F --> H[/NPM package/]
16393
E -->|Yes| I[Release workflow]
164-
I --> J[Triggered by pushes to main]
165-
I --> K[Artifacts: release tag and release record]
166-
E -->|No| L[Only test workflow runs]
94+
I --> K[/Git tag and release record/]
16795
```

0 commit comments

Comments
 (0)