Skip to content

Commit a510538

Browse files
committed
docs(server): clarify delta record inheritance/override system in HTTP spec
Rewrite delta documentation to accurately describe the inheritance model: NULL-means-inherit semantics, child entity overrides, and resolution logic.
1 parent e6c2b88 commit a510538

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

‎packages/server/docs/specs/HTTP.md‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ A Request is the fundamental unit, defining _what_ to send.
2424

2525
Every `http` record is classified by two independent boolean columns (`is_delta`, `is_snapshot`) into one of three mutually exclusive states:
2626

27-
| `is_delta` | `is_snapshot` | State | Description |
28-
| ---------- | ------------- | ------------ | -------------------------------------------------------------------- |
29-
| `FALSE` | `FALSE` | **Base** | The canonical saved request in a collection. Visible in the sidebar. |
30-
| `TRUE` | `FALSE` | **Delta** | A transient overlay on a base record (unsaved UI edits, variants). |
31-
| `FALSE` | `TRUE` | **Snapshot** | An immutable, fully-resolved copy captured at execution time. |
27+
| `is_delta` | `is_snapshot` | State | Description |
28+
| ---------- | ------------- | ------------ | ------------------------------------------------------------------------------------------- |
29+
| `FALSE` | `FALSE` | **Base** | The canonical saved request in a collection. Visible in the sidebar. |
30+
| `TRUE` | `FALSE` | **Delta** | An inheritance-based override of a base record. Inherits all fields, overrides selectively. |
31+
| `FALSE` | `TRUE` | **Snapshot** | An immutable, fully-resolved copy captured at execution time. |
3232

3333
The combination `is_delta=TRUE, is_snapshot=TRUE` is **invalid** and enforced by:
3434

@@ -41,11 +41,14 @@ The normal saved requests users see in the workspace tree.
4141

4242
#### Delta Records
4343

44-
Non-destructive overlays on top of a base record. Used when users edit a request in the UI before saving.
44+
Deltas implement an **inheritance/override system** on top of base records. A delta is a child of a base record that inherits every field from its parent and selectively overrides only the fields it specifies. This is used when users edit a request in the UI before saving — the edits are stored as a delta, leaving the original base untouched.
4545

46-
- **Parent Relationship:** Deltas link back to a `ParentHttpID` (enforced by a `CHECK` constraint).
47-
- **NULL-means-no-change:** Delta override fields (`delta_url`, `delta_method`, etc.) use `NULL` to indicate "inherit from parent". Only non-NULL fields override the base.
48-
- **Resolution:** `packages/server/pkg/delta` merges base + delta into a resolved view at read time.
46+
- **Parent Relationship:** Every delta links back to a `ParentHttpID` (enforced by a `CHECK` constraint: `is_delta = FALSE OR parent_http_id IS NOT NULL`). Deleting the parent cascades to all its deltas.
47+
- **NULL-means-inherit:** Each overridable field has a corresponding `delta_*` column (e.g., `delta_url`, `delta_method`, `delta_name`, `delta_body_kind`, `delta_description`). A `NULL` delta field means "inherit from the parent base". Only non-NULL delta fields override the base value.
48+
- **Child entity inheritance:** The same override pattern extends to child entities (headers, params, body forms, URL-encoded entries, body raw, asserts). Each child delta can either:
49+
- **Override** an existing parent child (via `parent_http_header_id`, `parent_http_search_param_id`, etc.) — inheriting its fields and selectively overriding them.
50+
- **Add** a new child (when the parent link is `NULL`) — appended to the resolved collection.
51+
- **Resolution:** `packages/server/pkg/delta` merges base + delta into a fully resolved view at read time. The resolver walks every field and child entity, applying the override-or-inherit logic, and returns a complete HTTP request with `IsDelta = false`.
4952

5053
#### Snapshot Records
5154

@@ -89,9 +92,10 @@ When a request is "Run":
8992

9093
- **Pure Go Structs:** Decoupled from DB and API.
9194
- **Key Fields:**
92-
- `IsDelta` (bool): Marks a request as a transient edit (delta overlay).
95+
- `IsDelta` (bool): Marks a request as an inherited override of a base record (see Delta Records).
9396
- `IsSnapshot` (bool): Marks a request as an immutable version snapshot.
94-
- `ParentHttpID` (UUID): Links a delta to its source base record.
97+
- `ParentHttpID` (UUID): Links a delta to its parent base record for inheritance.
98+
- `Delta*` fields (`DeltaName *string`, `DeltaUrl *string`, etc.): Nullable override fields. `nil` = inherit from parent.
9599
- `DisplayOrder` (float): Manages sorting in the collection list.
96100

97101
## Database Schema

0 commit comments

Comments
 (0)