Brick
brickcheck/
contract/
domain/
fakerepo/
server/
| 1 | # Compiler Creation |
| 2 | |
| 3 | A software module for creating compilers, which translate high-level programming languages into machine code. |
| 4 | |
| 5 | A Go module (`bricks.brico.dev/compile-engine`) generated by the BRICO engine from its spec. It has no dependencies outside the standard library. Layers: domain, server. |
| 6 | |
| 7 | ## Packages |
| 8 | |
| 9 | - `domain` — types and pure logic: no I/O, no clock. |
| 10 | - `server` — `server.New(deps)`: the operations that read and write through repositories. |
| 11 | - `contract` — the host contract vendored into the brick (`Money`, `Entity`, `Repository[T]`). |
| 12 | - `fakerepo` — an in-memory `contract.Repository[T]` for tests. |
| 13 | - `brickcheck` — helpers the generated tests use. |
| 14 | |
| 15 | ## Operations |
| 16 | |
| 17 | - `(*server.Service).Req1` (`req1`) — Create a new Compiler entry for a given ProgrammingLanguage. Errors: ERROR_CODE_100. |
| 18 | - `(*server.Service).Req2` (`req2`) — Check if a Compiler can be created for a given ProgrammingLanguage. Errors: ERROR_CODE_100. |
| 19 | |
| 20 | ## Lifecycles |
| 21 | |
| 22 | - Compilation.status: starts at `pending`; markInProgress (pending → inProgress), markCompleted (inProgress → completed). See `domain.CanCompilation`, `domain.TransitionCompilation` and `domain.AvailableCompilationEvents`. |
| 23 | |
| 24 | ## Use it |
| 25 | |
| 26 | Add the module, or point Go at a local copy: |
| 27 | |
| 28 | ```sh |
| 29 | go get bricks.brico.dev/compile-engine |
| 30 | # or, from a local folder: go mod edit -replace bricks.brico.dev/compile-engine=../compile-engine |
| 31 | ``` |
| 32 | |
| 33 | Build the service once, in your own composition code: |
| 34 | |
| 35 | ```go |
| 36 | svc := server.New(server.Service{ |
| 37 | ProgrammingLanguages: myStore, // a contract.Repository[domain.ProgrammingLanguage] |
| 38 | Compilations: myStore, // a contract.Repository[domain.Compilation] |
| 39 | Compilers: myStore, // a contract.Repository[domain.Compiler] |
| 40 | Now: func() string { return time.Now().UTC().Format("2006-01-02T15:04:05.000Z") }, |
| 41 | NewID: func() string { return uuid.NewString() }, |
| 42 | }) |
| 43 | ``` |
| 44 | |
| 45 | Expected failures are `*domain.Error` values with a `Code` (for example `INVALID_INPUT`); every operation returns them as its `error`. |
| 46 | |
| 47 | ## Tests |
| 48 | |
| 49 | ```sh |
| 50 | go test ./... |
| 51 | ``` |
| 52 | |
| 53 | Each operation's tests come from the examples agreed in the spec. |
| 54 | |
| 55 | ## Requirements |
| 56 | |
| 57 | - **REQ-3** The compiler name must not contain any special characters or spaces. (`req1`) |
| 58 | - **REQ-4** it should log the errors (`req2`) |
| 59 |
Requirements
- !
REQ-3The compiler name must not contain any special characters or spaces.
… [REQ-3] The compiler name must not contain any special characters or spaces. #1 · req1 was not implemented within budget.
- !
REQ-4it should log the errors
… [REQ-4] it should log the errors #1 · … [REQ-4] it should log the errors #2 · req2 was not implemented within budget.
- ✓
GATE-PORTABLESelf-contained: standard library and its own packages only, gofmt-clean
go vet offline + gofmt -l
- ✓
GATE-CONTRACTVendored Go contract matches the host contract (R8)
regenerated contract comparison
- ✓
GATE-TYPESCompiles and passes go vet
go vet ./...
- ✓
GATE-TESTSShips its own tests and they pass (R12)
10 passing
- ✓
GATE-LIFECYCLE-COMPILATIONCompilation.status only changes through declared transitions
10 generated lifecycle tests
Built 10/10/2026, 18:04:14 · 10 tests passing · operations by local