rizolang 0.0.0-stage → 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.
Files changed (53) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +399 -2
  3. package/build/src/ast.d.ts +133 -0
  4. package/build/src/ast.js +4 -0
  5. package/build/src/ast.js.map +1 -0
  6. package/build/src/bin.d.ts +2 -0
  7. package/build/src/bin.js +8 -0
  8. package/build/src/bin.js.map +1 -0
  9. package/build/src/check-api.d.ts +97 -0
  10. package/build/src/check-api.js +506 -0
  11. package/build/src/check-api.js.map +1 -0
  12. package/build/src/checker.d.ts +53 -0
  13. package/build/src/checker.js +235 -0
  14. package/build/src/checker.js.map +1 -0
  15. package/build/src/cli.d.ts +11 -0
  16. package/build/src/cli.js +94 -0
  17. package/build/src/cli.js.map +1 -0
  18. package/build/src/compiler.d.ts +36 -0
  19. package/build/src/compiler.js +61 -0
  20. package/build/src/compiler.js.map +1 -0
  21. package/build/src/diagnostics.d.ts +35 -0
  22. package/build/src/diagnostics.js +69 -0
  23. package/build/src/diagnostics.js.map +1 -0
  24. package/build/src/emit/routes.d.ts +20 -0
  25. package/build/src/emit/routes.js +246 -0
  26. package/build/src/emit/routes.js.map +1 -0
  27. package/build/src/emit/sql.d.ts +12 -0
  28. package/build/src/emit/sql.js +83 -0
  29. package/build/src/emit/sql.js.map +1 -0
  30. package/build/src/emit/typescript.d.ts +13 -0
  31. package/build/src/emit/typescript.js +74 -0
  32. package/build/src/emit/typescript.js.map +1 -0
  33. package/build/src/lexer.d.ts +17 -0
  34. package/build/src/lexer.js +124 -0
  35. package/build/src/lexer.js.map +1 -0
  36. package/build/src/parser.d.ts +17 -0
  37. package/build/src/parser.js +399 -0
  38. package/build/src/parser.js.map +1 -0
  39. package/build/src/types.d.ts +42 -0
  40. package/build/src/types.js +77 -0
  41. package/build/src/types.js.map +1 -0
  42. package/build/src/version.d.ts +2 -0
  43. package/build/src/version.js +3 -0
  44. package/build/src/version.js.map +1 -0
  45. package/docs/SPEC-COMPACT.md +148 -0
  46. package/docs/SPEC.md +597 -0
  47. package/package.json +48 -4
  48. package/runtime/password.ts +58 -0
  49. package/runtime/ratelimit.ts +53 -0
  50. package/runtime/server.ts +449 -0
  51. package/runtime/session.ts +48 -0
  52. package/runtime/types.ts +76 -0
  53. package/runtime/validate.ts +133 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,400 @@
1
- # Temporary Holding Version
1
+ <div align="center">
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
+ # Rizo Lang
4
+
5
+ **A modern, simple and secure web language for the AI era.**
6
+
7
+ Write your data models and endpoints in a few readable lines. Rizo Lang compiles them into a PostgreSQL schema, TypeScript types and a ready-to-run Node.js server, with login, validation and permission checks built in.
8
+
9
+ [![CI](https://github.com/chaitanyaaggarwal9/rizolang/actions/workflows/ci.yml/badge.svg)](https://github.com/chaitanyaaggarwal9/rizolang/actions/workflows/ci.yml)
10
+ [![CodeQL](https://github.com/chaitanyaaggarwal9/rizolang/actions/workflows/codeql.yml/badge.svg)](https://github.com/chaitanyaaggarwal9/rizolang/actions/workflows/codeql.yml)
11
+ [![License: Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
12
+
13
+ ![.rz Language](https://img.shields.io/badge/.rz-language-0ea5e9)
14
+ ![Full-Stack](https://img.shields.io/badge/full--stack-web-8b5cf6)
15
+ ![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white)
16
+ ![PostgreSQL](https://img.shields.io/badge/PostgreSQL-4169E1?logo=postgresql&logoColor=white)
17
+ ![Open Source](https://img.shields.io/badge/open%20source-Apache--2.0-10b981)
18
+
19
+ [Website](https://rizobot.com) · [Language spec](docs/SPEC.md) · [Compact spec for AI](docs/SPEC-COMPACT.md) · [Contributing](CONTRIBUTING.md) · [Security](SECURITY.md)
20
+
21
+ </div>
22
+
23
+ ---
24
+
25
+ ## Contents
26
+
27
+ - [Why Rizo Lang?](#why-rizo-lang)
28
+ - [A quick look](#a-quick-look)
29
+ - [What the compiler generates](#what-the-compiler-generates)
30
+ - [Getting started](#getting-started)
31
+ - [Language tour](#language-tour)
32
+ - [Security model](#security-model)
33
+ - [Error messages](#error-messages)
34
+ - [Using Rizo Lang with AI](#using-rizo-lang-with-ai)
35
+ - [Project status and roadmap](#project-status-and-roadmap)
36
+ - [Project structure](#project-structure)
37
+ - [Development](#development)
38
+ - [Contributing, security and license](#contributing-security-and-license)
39
+
40
+ ---
41
+
42
+ ## Why Rizo Lang?
43
+
44
+ Most security bugs in web apps are ordinary mistakes:
45
+ - a query built from text,
46
+ - a password returned in a response,
47
+ - an endpoint that forgot to check who is calling,
48
+ - a user editing someone else's data.
49
+
50
+ Rizo Lang is designed so those mistakes **cannot be written**, not just discouraged.
51
+
52
+ | Principle | What it means in practice |
53
+ |-----------|---------------------------|
54
+ | **Dangerous mistakes are impossible** | There is no raw SQL. Every query is generated and parameterized. |
55
+ | **Strict and clear** | Static types everywhere. Every error says what went wrong, where (file:line:column) and how to fix it. |
56
+ | **Small** | The whole language fits in a [short spec](docs/SPEC.md) that an AI can learn from in one read. |
57
+ | **Secure by default** | Passwords are hashed and never returned. Input is validated automatically. Login and ownership are part of the syntax. |
58
+ | **AI-first** | The [compact spec](docs/SPEC-COMPACT.md) works as a system prompt, so even small models can write correct Rizo Lang. |
59
+
60
+ Rizo Lang is part of the [Rizo](https://rizobot.com) ecosystem, alongside **Rizo**, an open-source BYOK AI coding assistant for VS Code. It compiles into technology you already use. Its only runtime is a small, readable library that is copied into your project.
61
+
62
+ ---
63
+
64
+ ## A quick look
65
+
66
+ ```rizo
67
+ // app.rz: a small blog
68
+ auth User by email
69
+
70
+ model User {
71
+ email: Email unique private
72
+ password: Password min 12
73
+ name: Text max 100
74
+ }
75
+
76
+ model Post {
77
+ author: User
78
+ title: Text min 1 max 200
79
+ body: Text
80
+ published: Bool
81
+ }
82
+
83
+ api GET /posts -> list Post.public {
84
+ public
85
+ return db.Post.list(published = true, order title, limit 20)
86
+ }
87
+
88
+ api POST /posts -> Post.public {
89
+ requires login
90
+ return db.Post.create(body, author = me)
91
+ }
92
+
93
+ api PATCH /posts/:id -> Post.public {
94
+ requires login
95
+ requires owner author
96
+ return db.Post.update(id, body)
97
+ }
98
+
99
+ api DELETE /posts/:id {
100
+ requires login
101
+ requires owner author
102
+ return db.Post.delete(id)
103
+ }
104
+ ```
105
+
106
+ ```sh
107
+ rizolang build app.rz
108
+ ```
109
+
110
+ That's a complete backend:
111
+ - **Accounts:** signup, login, logout and sessions.
112
+ - **Validation:** every request body and path parameter is checked against your models.
113
+ - **Ownership:** only a post's author can change or delete it. Everyone else gets 404.
114
+ - **Privacy:** emails and passwords are never returned by any endpoint.
115
+
116
+ ---
117
+
118
+ ## What the compiler generates
119
+
120
+ `rizolang build app.rz` writes everything to `dist/`:
121
+
122
+ | File | What it is |
123
+ |------|------------|
124
+ | `schema.sql` | PostgreSQL tables with `NOT NULL`, `UNIQUE`, `CHECK` and foreign-key constraints, plus the sessions table |
125
+ | `types.ts` | TypeScript types: `User` (server-only), `UserPublic` (safe to return) and `UserInput` (what clients send) |
126
+ | `routes.ts` | Every endpoint as plain data, **with its SQL written out in full** so you can review exactly what runs |
127
+ | `server.ts` | The entry point: `node server.ts` |
128
+ | `runtime/` | A small Rizo runtime: validation, sessions, password hashing and the HTTP server |
129
+ | `package.json`, `tsconfig.json` | Installs the only dependency, the [`pg`](https://www.npmjs.com/package/pg) driver, and type-checks the app |
130
+
131
+ A file with only models (no `auth` or `api`) produces just `schema.sql` and `types.ts`.
132
+
133
+ Part of the `PATCH /posts/:id` route above, as it appears in `routes.ts`:
134
+
135
+ ```ts
136
+ {
137
+ method: 'PATCH',
138
+ pattern: '/posts/:id',
139
+ access: 'login',
140
+ sql: 'UPDATE "posts" SET "title" = CASE WHEN $3 THEN $4 ELSE "title" END, ... WHERE "id" = $1 AND "author_id" = $2 RETURNING "id", "author_id" AS "author", ...',
141
+ values: [{ from: 'path', name: 'id' }, { from: 'me' }, ...],
142
+ }
143
+ ```
144
+
145
+ ---
146
+
147
+ ## Getting started
148
+
149
+ ### Requirements
150
+
151
+ - **Node.js 22.12+** to run the compiler. The generated server needs **22.18+**, which runs TypeScript directly; Node 24 LTS is recommended.
152
+ - **PostgreSQL 13+**
153
+
154
+ ### Install the compiler
155
+
156
+ Rizo Lang is not published to npm yet. Build it from source:
157
+
158
+ ```sh
159
+ git clone https://github.com/chaitanyaaggarwal9/rizolang.git
160
+ cd rizolang
161
+ npm ci
162
+ npm run build
163
+ npm link # optional: makes the `rizolang` command available everywhere
164
+ ```
165
+
166
+ ### Build and run an app
167
+
168
+ ```sh
169
+ rizolang build app.rz # or: node path/to/rizolang/build/src/bin.js build app.rz
170
+ cd dist
171
+ npm install # installs pg
172
+ psql "$DATABASE_URL" -f schema.sql # create the tables
173
+ DATABASE_URL=postgres://user:pass@localhost:5432/app node server.ts
174
+ ```
175
+
176
+ ### Try it
177
+
178
+ ```sh
179
+ # Sign up (this also logs you in; curl keeps the session cookie in ./jar)
180
+ curl -c jar -H 'Content-Type: application/json' \
181
+ -d '{"email":"ann@example.com","password":"correct horse battery","name":"Ann"}' \
182
+ http://127.0.0.1:3000/auth/signup
183
+
184
+ # Create a post as Ann
185
+ curl -b jar -H 'Content-Type: application/json' \
186
+ -d '{"title":"Hello","body":"First post","published":true}' \
187
+ http://127.0.0.1:3000/posts
188
+
189
+ # Anyone can list published posts
190
+ curl http://127.0.0.1:3000/posts
191
+ ```
192
+
193
+ > Session cookies are marked `Secure`, so they are only sent over https. Browsers and curl treat `localhost` and `127.0.0.1` as secure, so the steps above work locally as written. Only if you test over plain http on another host, start the server with `RIZO_DEV_INSECURE_COOKIES=1`. Never use this setting in production.
194
+
195
+ ### Configuration
196
+
197
+ | Variable | Default | Meaning |
198
+ |----------|---------|---------|
199
+ | `DATABASE_URL` | (required) | PostgreSQL connection string |
200
+ | `PORT` / `HOST` | `3000` / `127.0.0.1` | Where the server listens |
201
+ | `RIZO_ALLOWED_ORIGINS` | none | Extra origins allowed to send POST, PUT, PATCH or DELETE requests (comma-separated) |
202
+ | `RIZO_TRUST_PROXY` | off | `1` to read the client IP from `X-Forwarded-For` (only behind a trusted proxy) |
203
+ | `RIZO_DB_POOL_SIZE` | `10` | Maximum number of database connections |
204
+ | `RIZO_DEV_INSECURE_COOKIES` | off | `1` to allow cookies over http. For local development only |
205
+
206
+ ---
207
+
208
+ ## Language tour
209
+
210
+ The [full spec](docs/SPEC.md) is the reference. This is the short version.
211
+
212
+ ### Models and field types
213
+
214
+ ```rizo
215
+ model User {
216
+ email: Email unique private
217
+ password: Password min 12
218
+ name: Text max 100
219
+ age: Number min 0 optional
220
+ isAdmin: Bool
221
+ birthday: Date optional
222
+ }
223
+ ```
224
+
225
+ | Type | Stores | Notes |
226
+ |------|--------|-------|
227
+ | `Text` | text | At most 10,000 characters unless you set `max` |
228
+ | `Number` | whole number (32-bit) | Use cents for money |
229
+ | `Bool` | `true` / `false` | |
230
+ | `Email` | email address | Trimmed, lowercased and checked |
231
+ | `Password` | salted scrypt hash | Never stored as plain text and never returned |
232
+ | `Date` | date and time (UTC) | ISO 8601 in JSON |
233
+ | `ID` | UUID | |
234
+ | *a model name* | a link, e.g. `author: User` | A foreign key to that model |
235
+
236
+ Every model gets an `id` automatically.
237
+
238
+ **Modifiers:**
239
+ - `unique`: no two records share the value.
240
+ - `optional`: the value may be missing.
241
+ - `private`: stored, but never returned.
242
+ - `min N` / `max N`: the length for text, the value for numbers.
243
+
244
+ ### Login
245
+
246
+ ```rizo
247
+ auth User by email
248
+ ```
249
+
250
+ This one line adds `POST /auth/signup`, `POST /auth/login`, `POST /auth/logout` and `GET /auth/me`.
251
+
252
+ **Built in:**
253
+ - Secure session cookies, with only a hash of each token stored in the database.
254
+ - Rate limits on login and signup.
255
+ - The same response for a wrong password and an unknown account, so callers can't find out which emails are registered.
256
+
257
+ ### Endpoints
258
+
259
+ ```
260
+ api <METHOD> <path> -> Model.public {
261
+ public | requires login
262
+ requires owner <link field> // optional
263
+ return db.Model.<action>(...)
264
+ }
265
+ ```
266
+
267
+ | Action | Method | Example |
268
+ |--------|--------|---------|
269
+ | `find` | GET | `db.Post.find(id)` |
270
+ | `list` | GET | `db.Post.list(author = me, order title desc, limit 20)` |
271
+ | `create` | POST | `db.Post.create(body, author = me)` |
272
+ | `update` | PUT / PATCH | `db.Post.update(id, body)` |
273
+ | `delete` | DELETE | `db.Post.delete(id)` |
274
+
275
+ The compiler enforces these rules:
276
+ - Every endpoint must say `public` or `requires login`. There is no default.
277
+ - Endpoints can only return `.public` views.
278
+ - A record's owner is always `me`, the logged-in user. It is never taken from the request body.
279
+ - `requires owner author` is enforced inside the SQL query, so someone else's record looks exactly like a missing one.
280
+ - `GET` endpoints can never change data.
281
+
282
+ ---
283
+
284
+ ## Security model
285
+
286
+ | Threat | How Rizo Lang prevents it |
287
+ |--------|---------------------------|
288
+ | SQL injection | All SQL is written at compile time. Request data only fills `$1, $2, …` parameters. |
289
+ | Leaking passwords or private data | Password and `private` fields are never selected for responses, and the runtime copies only public keys. |
290
+ | Plain-text or weak passwords | scrypt with a random salt. A minimum length of 8, and you can only raise it. |
291
+ | Missing login checks | Every endpoint must declare `public` or `requires login`. |
292
+ | Editing someone else's data (IDOR) | `requires owner` becomes part of the `WHERE` clause. Owners are set from the session. |
293
+ | Mass assignment | Unknown body fields are rejected. Ownership links are never accepted from clients. |
294
+ | CSRF | `SameSite=Lax` cookies, JSON-only bodies and an `Origin` check on every POST, PUT, PATCH and DELETE. |
295
+ | Brute force | Rate limits on login and signup. |
296
+ | Account enumeration at login | Identical responses and timing for an unknown account and a wrong password. |
297
+ | Leaky logs | Logs contain only the method, route pattern, status, time and request id. |
298
+ | Clickjacking and sniffing | A strict CSP, plus `X-Frame-Options: DENY`, `nosniff` and `no-store` on every response. |
299
+
300
+ Every guarantee is tested, in [`tests/security.test.ts`](tests/security.test.ts) and in the end-to-end suite [`tests/e2e.test.ts`](tests/e2e.test.ts), which attacks a real server backed by PostgreSQL. Found a hole? Please [report it privately](SECURITY.md).
301
+
302
+ ---
303
+
304
+ ## Error messages
305
+
306
+ Every error has a code, an exact location and a concrete fix. Real output from `rizolang build`:
307
+
308
+ ```
309
+ app.rz:14:5 error RZ0318: Endpoint "GET /posts" does not say who may call it.
310
+ 14 | api GET /posts -> list Post.public {
311
+ | ^^^
312
+ fix: Add `requires login` for logged-in users only, or `public` if anyone may call it.
313
+
314
+ app.rz:20:18 error RZ0326: "Post.author" links to the auth model, so the server must set it.
315
+ 20 | return db.Post.create(body)
316
+ | ^^^^^^
317
+ fix: Write `db.Post.create(body, author = me)`. Otherwise a client could create records owned by someone else.
318
+
319
+ Build failed with 2 errors. No files were written.
320
+ ```
321
+
322
+ The full list of error codes is in the [spec](docs/SPEC.md#8-errors).
323
+
324
+ ---
325
+
326
+ ## Using Rizo Lang with AI
327
+
328
+ Rizo Lang is designed to be written by AI models as well as people:
329
+ - [`docs/SPEC-COMPACT.md`](docs/SPEC-COMPACT.md) is under 1,500 words. Paste it into any model's system prompt.
330
+ - Error messages include a `fix:` line that a model can apply directly.
331
+ - The Rizo VS Code extension ([rizobot.com](https://rizobot.com)) will detect `.rz` files and load the spec automatically.
332
+
333
+ ---
334
+
335
+ ## Project status and roadmap
336
+
337
+ Rizo Lang is in **early development**, so expect the language to change before 1.0.
338
+
339
+ - [x] **Milestone 1:** models, compiled to a PostgreSQL schema and TypeScript types ([v0.1.0](https://github.com/chaitanyaaggarwal9/rizolang/releases/tag/v0.1.0))
340
+ - [x] **Milestone 2:** `auth`, `api` endpoints, links, `private` fields and a generated Node.js server ([v0.2.0](https://github.com/chaitanyaaggarwal9/rizolang/releases/tag/v0.2.0))
341
+ - [ ] **Milestone 3:** roles (`requires role admin`), pagination, account management, migrations
342
+ - [ ] **Milestone 4:** frontend `page` blocks compiled to HTML and TypeScript
343
+ - [ ] Publish the compiler to npm, and a VS Code extension with syntax highlighting
344
+
345
+ See [CHANGELOG.md](CHANGELOG.md) for what changed in each version.
346
+
347
+ ---
348
+
349
+ ## Project structure
350
+
351
+ ```
352
+ rizolang/
353
+ ├── src/ # the compiler
354
+ │ ├── lexer.ts # source text → tokens
355
+ │ ├── parser.ts # tokens → syntax tree (hand-written recursive descent)
356
+ │ ├── checker.ts # models: types, modifiers, links, names
357
+ │ ├── check-api.ts # auth and api: access, ownership, queries
358
+ │ ├── emit/ # SQL, TypeScript types and routes
359
+ │ └── cli.ts # `rizolang build`
360
+ ├── runtime/ # copied into every generated app (validation, sessions, server)
361
+ ├── tests/ # unit, security, docs and end-to-end tests
362
+ ├── docs/ # SPEC.md and SPEC-COMPACT.md
363
+ └── examples/blog.rz # a complete example app
364
+ ```
365
+
366
+ ---
367
+
368
+ ## Development
369
+
370
+ ```sh
371
+ npm ci # install the exact locked dependencies
372
+ npm test # run all tests (end-to-end tests are skipped without a database)
373
+ npm run typecheck # strict type checking
374
+ npm run build # compile the compiler to build/
375
+
376
+ # Run the end-to-end tests against a PostgreSQL database you control.
377
+ # They create and drop their own temporary schema.
378
+ RIZO_TEST_DATABASE_URL=postgres://user:pass@localhost:5432/dev npm test
379
+ ```
380
+
381
+ The compiler has **zero runtime dependencies**, and every dev dependency is pinned to an exact version. CI runs:
382
+ - the tests on Node 22, 24 and 26,
383
+ - the end-to-end suite and a real server against PostgreSQL 17,
384
+ - CodeQL,
385
+ - dependency review.
386
+
387
+ ---
388
+
389
+ ## Contributing, security and license
390
+
391
+ - **Contributing:** contributions are welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md), and propose language changes in an issue first.
392
+ - **Code of Conduct:** this project follows the [Contributor Covenant](CODE_OF_CONDUCT.md).
393
+ - **Security:** please report vulnerabilities privately, as described in [SECURITY.md](SECURITY.md).
394
+ - **License:** [Apache License 2.0](LICENSE).
395
+
396
+ <div align="center">
397
+
398
+ Made for the [Rizo](https://rizobot.com) ecosystem.
399
+
400
+ </div>