Skip to content

Commit 177c779

Browse files
committed
Document the public API style and drop DESIGN_REVIEW references
Add a Public API style section to AGENTS.md summarising the workspace specs/api-style.md rules, and point at it from the spec table. DESIGN_REVIEW.md was removed from the workspace; open questions now live inline in the specs. Reword the code and test comments that cited it.
1 parent c344e71 commit 177c779

6 files changed

Lines changed: 41 additions & 9 deletions

File tree

‎AGENTS.md‎

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ submodule. Read them before adding or reshaping public API:
2626
| --- | --- |
2727
| `../specs/architecture.md` | Layering, the six-platform matrix, naming, build |
2828
| `../specs/object-model.md` | Identity objects vs value objects |
29+
| `../specs/api-style.md` | Method vocabulary, parameter/return types, failure reporting, doc comments |
2930
| `../specs/platform-seam.md` | PIMPL, narrow seams, `NativeObjectProvider` |
3031
| `../specs/event-system.md` | `Event` / `EventEmitter`, threading, lazy listening |
3132
| `../specs/managers.md` | Singletons, registries, the handle table |
3233
| `../specs/c-abi.md` | What codegen produces and how types cross the boundary |
3334
| `../specs/handle-ownership.md` | C ABI handle ownership and invalidation |
3435

35-
`../DESIGN_REVIEW.md` tracks the *unresolved* inconsistencies; the specs describe what is
36-
already settled.
36+
Each spec also records the open questions and known legacy gaps of its own area inline;
37+
there is no separate issue list.
3738

3839
## Non-negotiables
3940

@@ -52,6 +53,37 @@ already settled.
5253
[src/foundation/id_allocator.h](src/foundation/id_allocator.h) — append only, never
5354
renumber.
5455

56+
## Public API style
57+
58+
The full rules and the review checklist are in `../specs/api-style.md`. Everything public in
59+
`src/*.h` is exported verbatim to C, Dart, Rust and C#, so the short version is:
60+
61+
- **Properties** are `SetX(v)` + `GetX() const`, booleans `SetX(bool is_x)` + `IsX() const`,
62+
declared as an adjacent pair. Getters are always `const` — codegen only turns `const`
63+
no-arg `Get`/`Is`/`Has` methods into binding properties.
64+
- **Actions** are bare imperative verbs with a fixed opposite (`Show`/`Hide`, `Open`/`Close`,
65+
`Maximize`/`Unmaximize`, `Enable`/`Disable`) and an `IsXxx() const` state query.
66+
- **No new overloads** — they surface as `native_x_verb_with_<params>`. Different meaning,
67+
different name (`RemoveItemById`, `RemoveItemAt`).
68+
- **Types**: strings in as `const std::string&`, out by value; geometry and enums by value;
69+
identity objects only as `std::shared_ptr<T>` (`nullptr` = none), never `const T&` / `T*`;
70+
`std::optional` wraps strings only; floating point is `double`; IDs use the `XxxId` alias.
71+
- **Enums**: `enum class`, PascalCase values, no `k` prefix, sequential from 0, first value
72+
is the neutral default, append only.
73+
- **Failure**: never throw across the public API. `void` when it cannot fail, `bool` when a
74+
platform may not support it (document what `false` means), `nullptr` for lookups and
75+
factories. Do not invent another error channel.
76+
- **Platform differences live in the doc comment**, not the signature: every API exists on
77+
all six platforms, and one that behaves differently carries the six-line
78+
`@note Platform availability:` block (✅ / ⚠️ / ❌).
79+
- **"Intercept before X" is a cancellable event on the object**, not another
80+
`SetWillXxxHook`; internal entry points stay out of the `public:` section.
81+
- After editing a header, run `./codegen` from the workspace root and make sure no
82+
`skipped` warning names the new API.
83+
84+
Where existing headers disagree, the spec says which side is the rule — do not copy the
85+
nearest neighbour.
86+
5587
## Naming
5688

5789
- C++ — classes and methods `PascalCase`, members `snake_case_`, files `snake_case.h`,

‎src/foundation/handle_table.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ class HandleTable {
5151
* @brief Process-wide table.
5252
*
5353
* A singleton for now, matching how the C ABI is structured. It is a Meyer's
54-
* singleton like the rest of the library; the explicit-lifetime work in
55-
* DESIGN_REVIEW §4.2 will fold this into the same Context as the others.
54+
* singleton like the rest of the library; if the singletons are ever folded
55+
* into an explicit-lifetime Context, this one goes with them.
5656
*/
5757
static HandleTable& GetInstance();
5858

‎src/foundation/id_allocator.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ namespace nativeapi {
1414
* T is a compile error rather than a silent runtime surprise.
1515
*
1616
* These values are stable identifiers, not arbitrary numbers. They appear in
17-
* the high bits of every ID handed out, and the handle-table work described in
18-
* DESIGN_REVIEW §P0-4 will use them to reject type-confused handles crossing
17+
* the high bits of every ID handed out, and the handle table
18+
* (foundation/handle_table.h) uses them to reject type-confused handles crossing
1919
* the C ABI. Therefore:
2020
*
2121
* - NEVER renumber an existing entry.

‎tests/event_emitter_test.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Regression tests for EventEmitter locking and dispatch behaviour.
22
//
3-
// Every case here maps to a defect described in DESIGN_REVIEW.md:
3+
// Every case here maps to a defect that was found and fixed:
44
// P0-1 EmitAsync self-deadlock (recursive lock on queue_mutex_)
55
// P0-2 Emit invoking listener callbacks while holding listeners_mutex_
66
//

‎tests/handle_table_test.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Tests for the generational handle table.
22
//
3-
// Maps to DESIGN_REVIEW.md P0-3 / P0-4 and docs/handle-ownership.md. The
3+
// The rules are in the workspace repo, specs/handle-ownership.md. The
44
// behaviours asserted here are exactly the ones raw-pointer handles could not
55
// provide: stale handles failing safely instead of dereferencing freed memory,
66
// double-release being a no-op, and handle confusion being rejected rather than

‎tests/id_allocator_test.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Tests for IdAllocator's ID encoding and type tagging.
22
//
3-
// Maps to DESIGN_REVIEW.md P1-5: type tags used to be handed out by a runtime
3+
// Regression background: type tags used to be handed out by a runtime
44
// counter on a first-call-wins basis, so a given C++ type could receive a
55
// different tag depending on call order or from one run to the next. That made
66
// the type bits useless for the handle validation they are meant to support.

0 commit comments

Comments
 (0)