backbone-integrations 0.6.1

Integration registry: connectors, integration accounts and an idempotent inbound event lane, with one OAuth flow (HMAC-bound state, PKCE)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
# Schema Error Codes Reference

This document provides a comprehensive reference for all error codes that can be generated by the `backbone-schema` CLI.

## Table of Contents

- [Error Categories]#error-categories
- [Parse Errors (E0xx)]#parse-errors-e0xx
- [Type Errors (E1xx)]#type-errors-e1xx
- [Reference Errors (E2xx)]#reference-errors-e2xx
- [State Machine Errors (E3xx)]#state-machine-errors-e3xx
- [Permission Errors (E4xx)]#permission-errors-e4xx
- [Flow Errors (E5xx)]#flow-errors-e5xx
- [Generation Errors (E6xx)]#generation-errors-e6xx
- [Troubleshooting Guide]#troubleshooting-guide

---

## Error Categories

| Range | Category | Description |
|-------|----------|-------------|
| E0xx | Parse | Lexer and syntax errors |
| E1xx | Type | Type resolution and validation |
| E2xx | Reference | Model, field, and cross-module references |
| E3xx | State Machine | State and transition validation |
| E4xx | Permission | Access control and role validation |
| E5xx | Flow | Flow orchestration validation |
| E6xx | Generation | Code generation errors |

---

## Parse Errors (E0xx)

### E001: Lexer Error

**Description:** The lexer encountered an invalid character or token.

**Example:**
```yaml
models:
  - name: User
    fields:
      email: @@@invalid   # E001: Invalid characters
```

**Solution:** Check for invalid characters or malformed tokens in your schema.

---

### E002: Syntax Error

**Description:** The parser encountered unexpected syntax.

**Example:**
```yaml
models:
  - name: User
    fields
      email: string   # E002: Missing colon after 'fields'
```

**Solution:** Verify YAML syntax, ensure proper indentation, and check for missing colons.

---

### E003: Unexpected Token

**Description:** The parser found a token where a different one was expected.

**Example:**
```yaml
models:
  - name: 123User   # E003: Expected identifier, got number
```

**Solution:** Model and field names must start with a letter and contain only alphanumeric characters.

---

### E004: Unexpected End of File

**Description:** The file ended unexpectedly while parsing a construct.

**Example:**
```yaml
models:
  - name: User
    fields:
      # File ends here without defining fields
```

**Solution:** Complete all schema definitions before the end of the file.

---

### E005: Invalid Type

**Description:** An unrecognized type was specified.

**Example:**
```yaml
fields:
  data: unknownType   # E005: 'unknownType' is not a valid type
```

**Solution:** Use a valid primitive type, enum, or model reference. See [TYPES.md](./TYPES.md) for available types.

---

### E006: Invalid Attribute

**Description:** An unrecognized or malformed attribute was specified.

**Example:**
```yaml
fields:
  email:
    type: string
    attributes: ["@unknownAttr"]   # E006: Unknown attribute
```

**Solution:** Check [RULE_FORMAT_MODELS.md](./RULE_FORMAT_MODELS.md#field-attributes) for valid validation attributes.

---

## Type Errors (E1xx)

### E100: Unknown Type

**Description:** A type reference could not be resolved.

**Example:**
```yaml
fields:
  status:
    type: UserStatus   # E100: 'UserStatus' enum not defined
```

**Solution:** Define the enum or custom type before referencing it.

```yaml
enums:
  - name: UserStatus
    values: [active, inactive]

models:
  - name: User
    fields:
      status:
        type: UserStatus   # Now valid
```

---

### E101: Type Mismatch

**Description:** A value or expression has an incompatible type.

**Example:**
```yaml
fields:
  age:
    type: int
    attributes: ["@default('not a number')"]   # E101: String for int field
```

**Solution:** Ensure default values and expressions match the field type.

---

### E102: Invalid Attribute for Type

**Description:** An attribute was applied to an incompatible type.

**Example:**
```yaml
fields:
  count:
    type: int
    attributes: ["@email"]   # E102: @email not valid for int
```

**Solution:** Use type-appropriate attributes. `@email` is only valid for string fields.

---

### E103: Array Type Error

**Description:** Invalid array type specification.

**Example:**
```yaml
fields:
  tags:
    type: "[]"   # E103: Array must have element type
```

**Solution:** Specify the array element type: `type: string[]` or `type: Tag[]`.

---

## Reference Errors (E2xx)

### E200: Unknown Model

**Description:** A model reference could not be resolved.

**Example:**
```yaml
relations:
  author:
    type: belongs_to
    model: UnknownModel   # E200: Model not found
```

**Solution:** Ensure the referenced model exists in the same module or import it.

```yaml
# user.model.yaml
external_imports:
  posts: Post

relations:
  posts:
    type: has_many
    model: Post   # Now valid if Post is defined in posts module
```

---

### E201: Unknown Field

**Description:** A field reference could not be resolved.

**Example:**
```yaml
indexes:
  - name: idx_email
    fields: [email_address]   # E201: 'email_address' not defined
```

**Solution:** Use the correct field name as defined in the model.

---

### E202: Circular Reference

**Description:** A circular dependency was detected between models.

**Example:**
```yaml
# user.model.yaml
relations:
  profile:
    type: has_one
    model: Profile

# profile.model.yaml
relations:
  user:
    type: belongs_to
    model: User
  settings:
    type: has_one
    model: Settings

# settings.model.yaml
relations:
  user:
    type: belongs_to
    model: User   # E202: Circular: User -> Profile -> Settings -> User
```

**Solution:** Review your relation structure and break circular dependencies.

---

### E203: Invalid Cross-Module Reference

**Description:** A cross-module reference is invalid or not imported.

**Example:**
```yaml
relations:
  posts:
    type: has_many
    model: posts.Post   # E203: 'posts' module not imported
```

**Solution:** Add the module to `external_imports` in your schema.

---

## State Machine Errors (E3xx)

### E300: Invalid Transition

**Description:** A state transition is not allowed.

**Example:**
```yaml
states:
  values:
    draft: {}
    published: {}
    archived: {}
  transitions:
    publish:
      from: archived   # E300: Can't publish from archived
      to: published
```

**Solution:** Review your state machine design and ensure transitions make logical sense.

---

### E301: Unreachable State

**Description:** A state cannot be reached from any other state.

**Example:**
```yaml
states:
  values:
    draft: {}
    published: {}
    orphaned: {}   # E301: No transition leads to 'orphaned'
  transitions:
    publish:
      from: draft
      to: published
```

**Solution:** Add a transition to reach the orphaned state or remove it.

---

### E302: Missing Initial State

**Description:** No initial state is defined for the state machine.

**Example:**
```yaml
states:
  field: status
  values:
    published: {}
    archived: {}
  # E302: No state marked as initial
```

**Solution:** Ensure the first state or one marked with `initial: true` exists.

```yaml
states:
  values:
    draft:
      initial: true   # Or just make it first
    published: {}
```

---

### E303: Multiple Final States Conflict

**Description:** Conflicting final state definitions.

**Solution:** Review which states should be terminal (no outgoing transitions).

---

### E304: Missing State Field

**Description:** The workflow references a status field not in the model.

**Example:**
```yaml
# workflow references 'status' field
states:
  field: status   # E304: 'status' not in User model
```

**Solution:** Add the status field to your model.

---

## Permission Errors (E4xx)

### E400: Unknown Role

**Description:** A permission references an undefined role.

**Example:**
```yaml
permissions:
  superadmin:   # E400: Role 'superadmin' not defined
    allow: [create, read, update, delete]
```

**Solution:** Use standard roles (admin, user, guest) or define custom roles.

---

### E401: Conflicting Permissions

**Description:** A role has conflicting allow and deny rules.

**Example:**
```yaml
permissions:
  editor:
    allow: [update]
    deny: [update]   # E401: 'update' both allowed and denied
```

**Solution:** Remove the conflicting permission from either allow or deny.

---

### E402: Invalid Permission Action

**Description:** An unrecognized action was specified.

**Example:**
```yaml
permissions:
  admin:
    allow: [create, read, modify]   # E402: 'modify' not valid
```

**Valid Actions:**
- `create` - Create new records
- `read` - View records
- `update` - Modify existing records
- `delete` - Soft delete records
- `list` - List/query records
- `restore` - Restore deleted records
- `*` - All actions

---

### E403: Invalid Field Restriction

**Description:** Field-level permission references invalid fields.

**Example:**
```yaml
permissions:
  user:
    allow:
      read:
        only: [unknown_field]   # E403: 'unknown_field' doesn't exist
```

**Solution:** Use valid field names from the model.

---

## Flow Errors (E5xx)

### E500: Duplicate Step Name

**Description:** Two steps in a flow have the same name.

**Example:**
```yaml
steps:
  - name: validate
    action: validate_order
  - name: validate   # E500: Duplicate step name
    action: check_inventory
```

**Solution:** Use unique step names throughout the flow.

---

### E501: Invalid Step Reference

**Description:** A step references a non-existent step.

**Example:**
```yaml
steps:
  - name: start
    on_success:
      next: process_payment   # E501: 'process_payment' not defined
```

**Solution:** Ensure all referenced steps exist in the flow.

---

### E502: Missing Terminal Step

**Description:** A flow has no terminal step (no way to complete).

**Example:**
```yaml
steps:
  - name: process
    action: do_something
    on_success:
      next: process   # E502: Infinite loop, no terminal
```

**Solution:** Add a terminal step to end the flow.

```yaml
steps:
  - name: process
    action: do_something
    on_success:
      next: complete
  - name: complete
    type: terminal
    status: success
```

---

### E503: Unreachable Step

**Description:** A step cannot be reached from the flow entry point.

**Example:**
```yaml
steps:
  - name: start
    action: begin
    on_success:
      next: end
  - name: orphan   # E503: No path leads to 'orphan'
    action: never_called
  - name: end
    type: terminal
```

**Solution:** Connect the step to the flow or remove it.

---

### E504: Invalid Compensation

**Description:** Compensation configuration is invalid.

**Example:**
```yaml
compensation:
  - action: rollback
    entity: UnknownEntity   # E504: Entity not found
```

**Solution:** Use valid entity names and actions in compensation.

---

### E505: Invalid Parallel Branch

**Description:** A parallel step has invalid branch configuration.

**Example:**
```yaml
steps:
  - name: parallel_work
    type: parallel
    branches: []   # E505: At least one branch required
```

**Solution:** Define at least one branch in parallel steps.

---

## Generation Errors (E6xx)

### E600: Template Error

**Description:** A code generation template failed.

**Solution:** This is typically an internal error. Please report it with your schema.

---

### E601: IO Error

**Description:** Failed to write generated files.

**Example:**
```
E601: Cannot write to /readonly/directory/user.rs
```

**Solution:** Check file permissions and ensure the output directory exists and is writable.

---

### E602: Generation Error

**Description:** Code generation failed for a specific reason.

**Solution:** Check the error message for details about what failed.

---

## Troubleshooting Guide

### Common Issues

#### 1. "Unknown type" errors

```bash
backbone-schema schema validate mymodule
Error: E100: Unknown type 'CustomType'
```

**Fix:** Check that:
- The type is defined as an enum in your schema
- Cross-module types are imported via `external_imports`
- Type names are spelled correctly (case-sensitive)

#### 2. YAML indentation errors

```bash
Error: E002: Syntax error at line 5
```

**Fix:**
- Use spaces, not tabs, for indentation
- Maintain consistent 2-space indentation
- Check for missing colons after keys

#### 3. Circular reference detection

```bash
Error: E202: Circular reference detected: User -> Profile -> User
```

**Fix:**
- Review your model relationships
- Consider using IDs instead of embedded objects
- Break the cycle by removing one direction of the relationship

### Getting Help

If you encounter an error not listed here:

1. Run with verbose output: `backbone-schema schema validate mymodule --verbose`
2. Check the schema documentation: [RULE_FORMAT_MODELS.md]./RULE_FORMAT_MODELS.md, [RULE_FORMAT_HOOKS.md]./RULE_FORMAT_HOOKS.md, [RULE_FORMAT_WORKFLOWS.md]./RULE_FORMAT_WORKFLOWS.md
3. Report issues at: https://github.com/anthropics/claude-code/issues

### Error Message Format

Errors are displayed with source context:

```
error in user.model.yaml:
  E201: Unknown field 'email_address' in model 'User'

    5 │ indexes:
    6 │   - name: idx_email
    7 │     fields: [email_address]
      │              ^
    8 │
```

The caret (`^`) points to the exact location of the error.