@rqml/schema 0.1.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.
@@ -0,0 +1,2236 @@
1
+ <!--
2
+ RQML (Requirements Markup Language) Schema v2.0.1
3
+ =================================================
4
+
5
+ PURPOSE
6
+ =======
7
+ RQML is an XML-based format for capturing software requirements in a structured,
8
+ machine-readable way. It is designed for LLM-native workflows where:
9
+
10
+ 1. Requirements are the primary artifact (not code)
11
+ 2. LLMs use requirements to generate and validate implementations
12
+ 3. Traceability from goals to tests is explicit and queryable
13
+ 4. Human collaboration happens on intent; implementation is derived
14
+
15
+ FOR LLMs: REQUIREMENTS ELICITATION
16
+ ==================================
17
+ When helping users write RQML documents:
18
+
19
+ - Start with `meta` (required): capture document identity, ownership, and conventions
20
+ - Add `catalogs` early: define glossary terms, actors, stakeholders, constraints, and
21
+ risks to establish shared vocabulary and reduce ambiguity in requirements
22
+ - Use `domain` to model key entities and business rules that requirements reference
23
+ - Capture `goals` to document WHY the system exists (business objectives, quality goals)
24
+ - Write `scenarios` to describe HOW users interact with the system (use cases, misuse cases)
25
+ - Derive `requirements` from goals and scenarios - each requirement should be:
26
+ * Necessary (traces to a goal or stakeholder need)
27
+ * Verifiable (has acceptance criteria or can be tested)
28
+ * Unambiguous (single interpretation)
29
+ * Feasible (technically achievable)
30
+ - Use `behavior` to formalize entity lifecycles as state machines (derived from requirements)
31
+ - Document `interfaces` for system boundaries (APIs, events)
32
+ - Add `verification` to define how requirements are tested
33
+ - Create `trace` edges to link artifacts for impact analysis
34
+ - Use `governance` for approval workflows and open issues
35
+
36
+ FOR LLMs: CODE GENERATION
37
+ =========================
38
+ When generating code from RQML documents:
39
+
40
+ - Read `domain/entities` for data models (classes, database schemas, types)
41
+ - Read `domain/businessRules` for validation logic and constraints
42
+ - Read `behavior/stateMachine` for state enums, transition logic, and lifecycle validation
43
+ - Read `requirements` with type="FR" for features to implement
44
+ - Read `requirements` with type="NFR" for quality attributes (performance, reliability)
45
+ - Read `requirements` with type="IR" for API contracts and integrations
46
+ - Read `requirements` with type="DR" for data validation rules
47
+ - Read `requirements` with type="SR" for security controls
48
+ - Read `interfaces/api/endpoint` for REST/HTTP endpoint implementations
49
+ - Read `interfaces/event` for event handlers and message schemas
50
+ - Use `acceptance/criterion` (given/when/then) for test case generation
51
+ - Check `trace` edges with type="implements" for code-to-requirement mapping
52
+
53
+ DOCUMENT STRUCTURE (in order)
54
+ =============================
55
+ 1. meta (REQUIRED) - Document identity and metadata
56
+ 2. catalogs - Shared definitions: glossary, actors, stakeholders, constraints, policies, decisions, risks
57
+ 3. domain - Problem space: entities, attributes, business rules
58
+ 4. goals - Objectives: business goals, quality goals, obstacles, goal links
59
+ 5. scenarios - User journeys: use cases, misuse cases, edge cases
60
+ 6. requirements (REQUIRED) - Normative statements: packages and individual requirements
61
+ 7. behavior - State machines: formalized entity lifecycles derived from requirements
62
+ 8. interfaces - System boundaries: APIs, endpoints, events
63
+ 9. verification - Testing: test suites and test cases
64
+ 10. trace - Traceability: edges linking all artifacts
65
+ 11. governance - Change control: issues and approvals
66
+
67
+ ID CONVENTIONS
68
+ ==============
69
+ All IDs must be unique within the document. Recommended patterns:
70
+ - Requirements: REQ-<AREA>-NNN (e.g., REQ-AUTH-001)
71
+ - Goals: GOAL-<AREA>-NNN (e.g., GOAL-AVAIL-001)
72
+ - Quality Goals: QGOAL-<NAME> (e.g., QGOAL-LATENCY)
73
+ - Test Cases: TC-<NAME>-NNN (e.g., TC-AUTH-001)
74
+ - Entities: ENT-<NAME> (e.g., ENT-PAYMENT)
75
+ - Actors: ACT-<NAME> (e.g., ACT-USER)
76
+ - Stakeholders: STK-<NAME> (e.g., STK-RISK)
77
+ - Scenarios: SCN-<NAME> (e.g., SCN-CHECKOUT)
78
+ - Risks: RISK-<NAME> (e.g., RISK-FRAUD)
79
+ - Decisions: DEC-<NAME> (e.g., DEC-IDEMPOTENCY)
80
+ - State Machines: SM-<NAME> (e.g., SM-ORDER)
81
+ - States: ST-<NAME> (e.g., ST-PENDING, ST-CONFIRMED)
82
+ - Transitions: TR-<NAME> (e.g., TR-CONFIRM, TR-SHIP)
83
+
84
+ STANDARDS ALIGNMENT
85
+ ===================
86
+ RQML aligns with requirements engineering best practices from:
87
+ - IEEE 29148-2018: Systems and software engineering - Life cycle processes - Requirements engineering
88
+ - ISO/IEC 25010: Systems and software quality models
89
+ - KAOS/i* goal-oriented RE frameworks
90
+ - Volere requirements template
91
+ - BDD/Gherkin for acceptance criteria
92
+
93
+ NAMESPACE: https://rqml.org/schema/2.0.1
94
+ -->
95
+ <xs:schema
96
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
97
+ targetNamespace="https://rqml.org/schema/2.0.1"
98
+ xmlns="https://rqml.org/schema/2.0.1"
99
+ elementFormDefault="qualified"
100
+ attributeFormDefault="unqualified"
101
+ version="2.0.1">
102
+
103
+ <!-- =========================
104
+ Simple types
105
+
106
+ These define the controlled vocabularies and value constraints
107
+ used throughout RQML. LLMs should use these exact values.
108
+ ========================= -->
109
+
110
+ <!--
111
+ IdType: Identifier format for all referenceable elements
112
+
113
+ Pattern: Start with letter, followed by letters, digits, dots, underscores, or hyphens
114
+ Length: 2-80 characters
115
+
116
+ EXAMPLES:
117
+ - REQ-AUTH-001 (requirement)
118
+ - GOAL-AVAIL (goal)
119
+ - ENT-PAYMENT (entity)
120
+ - ACT-USER (actor)
121
+ - TC-LOGIN-001 (test case)
122
+
123
+ FOR LLMs: When creating IDs, use descriptive prefixes that indicate the element type,
124
+ followed by a meaningful name or area, optionally with a sequence number.
125
+ Keep IDs stable across document revisions for traceability.
126
+ -->
127
+ <xs:simpleType name="IdType">
128
+ <xs:restriction base="xs:token">
129
+ <!-- Human-friendly IDs like REQ-LOGIN-001, GOAL_AUTH_01, TC-001 -->
130
+ <xs:pattern value="[A-Za-z][A-Za-z0-9._-]*"/>
131
+ <xs:minLength value="2"/>
132
+ <xs:maxLength value="80"/>
133
+ </xs:restriction>
134
+ </xs:simpleType>
135
+
136
+ <!--
137
+ StatusType: Lifecycle state of requirements, goals, decisions, and other artifacts
138
+
139
+ VALUES:
140
+ - draft: Initial state; content is incomplete or unreviewed
141
+ - review: Under stakeholder review; awaiting feedback or approval
142
+ - approved: Formally accepted; ready for implementation
143
+ - deprecated: No longer active; kept for historical reference
144
+
145
+ FOR LLMs:
146
+ - When eliciting requirements, start with status="draft"
147
+ - Only requirements with status="approved" should drive implementation
148
+ - Deprecated items should not be implemented but may explain historical decisions
149
+ -->
150
+ <xs:simpleType name="StatusType">
151
+ <xs:restriction base="xs:token">
152
+ <xs:enumeration value="draft"/>
153
+ <xs:enumeration value="review"/>
154
+ <xs:enumeration value="approved"/>
155
+ <xs:enumeration value="deprecated"/>
156
+ </xs:restriction>
157
+ </xs:simpleType>
158
+
159
+ <!--
160
+ PriorityType: MoSCoW-style priority for requirements and goals
161
+
162
+ VALUES (from RFC 2119 / IEEE 29148):
163
+ - must: Mandatory; system is unacceptable without this. Non-negotiable for MVP.
164
+ - should: Important; system is diminished without this. Include if feasible.
165
+ - may: Optional; nice to have. Include if time/budget permits.
166
+
167
+ FOR LLMs:
168
+ - When generating code, implement all "must" requirements first
169
+ - "should" requirements are strong candidates for the implementation
170
+ - "may" requirements can be deferred or simplified
171
+ - When eliciting, ask stakeholders to prioritize ruthlessly - too many "must" items
172
+ indicates poor prioritization
173
+ -->
174
+ <xs:simpleType name="PriorityType">
175
+ <xs:restriction base="xs:token">
176
+ <xs:enumeration value="must"/>
177
+ <xs:enumeration value="should"/>
178
+ <xs:enumeration value="may"/>
179
+ </xs:restriction>
180
+ </xs:simpleType>
181
+
182
+ <!--
183
+ ReqType: Classification of requirement types
184
+
185
+ This taxonomy helps organize requirements and determines how they should be
186
+ implemented and verified. Each type has distinct characteristics:
187
+
188
+ VALUES:
189
+ - FR (Functional Requirement): What the system must DO
190
+ * Features, behaviors, business functions, use case realizations
191
+ * Example: "The system SHALL allow users to reset their password via email"
192
+ * Code: Application logic, controllers, services, business rules
193
+
194
+ - NFR (Non-Functional Requirement): How WELL the system must perform
195
+ * Quality attributes: performance, reliability, scalability, usability, maintainability
196
+ * Example: "The API SHALL respond within 200ms for 95th percentile requests"
197
+ * Code: Caching, indexing, async processing, architecture decisions
198
+
199
+ - IR (Interface Requirement): Contracts with external systems
200
+ * APIs, protocols, message formats, integration points
201
+ * Example: "The system SHALL expose a REST API conforming to OpenAPI 3.0"
202
+ * Code: API controllers, serializers, protocol handlers, SDK clients
203
+
204
+ - DR (Data Requirement): Data structure and handling rules
205
+ * Data models, validation, retention, privacy classification
206
+ * Example: "Payment card numbers SHALL be stored encrypted using AES-256"
207
+ * Code: Database schemas, models, validators, data access layers
208
+
209
+ - SR (Security Requirement): Security controls and protections
210
+ * Authentication, authorization, encryption, audit logging, threat mitigations
211
+ * Example: "The system SHALL enforce MFA for administrative operations"
212
+ * Code: Auth middleware, encryption utilities, audit loggers, security filters
213
+
214
+ - CR (Constraint Requirement): Hard limits on the solution space
215
+ * Technology mandates, platform requirements, standards compliance
216
+ * Example: "The system SHALL run on Kubernetes 1.28+"
217
+ * Code: Deployment configurations, technology choices, compatibility layers
218
+
219
+ - PR (Policy/Compliance Requirement): Regulatory and policy obligations
220
+ * GDPR, HIPAA, PCI-DSS, SOX, internal policies
221
+ * Example: "The system SHALL retain audit logs for 7 years per SOX requirements"
222
+ * Code: Compliance features, audit trails, data retention, reporting
223
+
224
+ - UXR (User Experience Requirement): UI and interaction expectations
225
+ * Accessibility, internationalization, content, visual design, user flows
226
+ * Example: "The application SHALL meet WCAG 2.1 Level AA accessibility"
227
+ * Code: UI components, accessibility attributes, i18n, responsive design
228
+
229
+ - OR (Operational Requirement): Run and maintain the system
230
+ * Monitoring, logging, alerting, backups, disaster recovery, runbooks
231
+ * Example: "The system SHALL emit structured logs to the central logging platform"
232
+ * Code: Logging configuration, metrics endpoints, health checks, backup scripts
233
+
234
+ FOR LLMs:
235
+ - When eliciting requirements, ensure coverage across relevant types
236
+ - FR requirements are the primary drivers of application code
237
+ - NFR requirements shape architecture and infrastructure
238
+ - Use the type to determine which team or component owns implementation
239
+ -->
240
+ <xs:simpleType name="ReqType">
241
+ <xs:restriction base="xs:token">
242
+ <xs:enumeration value="FR"/>
243
+ <xs:enumeration value="NFR"/>
244
+ <xs:enumeration value="IR"/>
245
+ <xs:enumeration value="DR"/>
246
+ <xs:enumeration value="SR"/>
247
+ <xs:enumeration value="CR"/>
248
+ <xs:enumeration value="PR"/>
249
+ <xs:enumeration value="UXR"/>
250
+ <xs:enumeration value="OR"/>
251
+ </xs:restriction>
252
+ </xs:simpleType>
253
+
254
+ <!--
255
+ TraceType: Relationship types for traceability links between artifacts
256
+
257
+ Traceability enables impact analysis ("what breaks if this changes?") and
258
+ coverage analysis ("is this goal satisfied?"). Choose the most specific type.
259
+
260
+ VALUES:
261
+ - refines: Source provides more detail for target (goal decomposition)
262
+ * Example: Sub-goal refines parent goal; detailed req refines high-level req
263
+ * Direction: child -> parent (more specific refines less specific)
264
+
265
+ - satisfies: Source fulfills or achieves the target
266
+ * Example: Requirement satisfies goal; implementation satisfies requirement
267
+ * Direction: solution -> need (what satisfies why)
268
+
269
+ - dependsOn: Source requires target to function
270
+ * Example: Feature depends on infrastructure; requirement depends on constraint
271
+ * Direction: dependent -> dependency (what needs what)
272
+
273
+ - conflictsWith: Source and target cannot both be fully achieved
274
+ * Example: Performance goal conflicts with detailed logging goal
275
+ * Direction: bidirectional (both conflict with each other)
276
+
277
+ - threatens: Source poses risk to achieving target
278
+ * Example: Obstacle threatens goal; risk threatens requirement
279
+ * Direction: threat -> threatened (what endangers what)
280
+
281
+ - mitigates: Source reduces the impact or likelihood of target threat
282
+ * Example: Requirement mitigates risk; control mitigates obstacle
283
+ * Direction: mitigation -> threat (what addresses what)
284
+
285
+ - verifiedBy: Source is validated by target test/inspection
286
+ * Example: Requirement verifiedBy test case
287
+ * Direction: requirement -> verification (what is proven by what)
288
+
289
+ - covers: Source test addresses target requirement/scenario
290
+ * Example: Test case covers requirement; test suite covers scenario
291
+ * Direction: test -> requirement (what validates what)
292
+
293
+ - implements: Source code/component realizes target requirement
294
+ * Example: Module implements requirement (reserved for tooling)
295
+ * Direction: implementation -> requirement
296
+ * NOTE: This type is primarily for downstream tools that track code-to-requirement mapping
297
+
298
+ - supersedes: Source replaces target (for deprecation/versioning)
299
+ * Example: REQ-AUTH-002 supersedes REQ-AUTH-001 after security audit
300
+ * Direction: replacement -> deprecated (new replaces old)
301
+ * Use when archiving requirements: mark old as deprecated, link new via supersedes
302
+
303
+ FOR LLMs:
304
+ - Use trace edges to answer "why does this exist?" (follow satisfies/refines up)
305
+ - Use trace edges to answer "what depends on this?" (follow dependsOn/implements down)
306
+ - When generating code, create implements edges to maintain traceability
307
+ - When writing tests, create verifiedBy/covers edges to requirements
308
+ -->
309
+ <xs:simpleType name="TraceType">
310
+ <xs:restriction base="xs:token">
311
+ <xs:enumeration value="refines"/>
312
+ <xs:enumeration value="satisfies"/>
313
+ <xs:enumeration value="dependsOn"/>
314
+ <xs:enumeration value="conflictsWith"/>
315
+ <xs:enumeration value="threatens"/>
316
+ <xs:enumeration value="mitigates"/>
317
+ <xs:enumeration value="verifiedBy"/>
318
+ <xs:enumeration value="covers"/>
319
+ <!-- reserved for downstream tooling -->
320
+ <xs:enumeration value="implements"/>
321
+ <!-- lifecycle management -->
322
+ <xs:enumeration value="supersedes"/>
323
+ </xs:restriction>
324
+ </xs:simpleType>
325
+
326
+ <!--
327
+ TestType: Classification of verification activities
328
+
329
+ Different test types validate different aspects of the system and run at
330
+ different phases of development.
331
+
332
+ VALUES:
333
+ - acceptance: Validates business requirements from user perspective
334
+ * Typically derived from acceptance criteria (given/when/then)
335
+ * Stakeholder-facing; often automated as end-to-end tests
336
+ * Example: "User can complete checkout flow"
337
+
338
+ - integration: Validates interactions between components/systems
339
+ * Tests API contracts, database interactions, external service calls
340
+ * Example: "Payment service correctly calls bank API"
341
+
342
+ - unit: Validates individual functions/methods/classes in isolation
343
+ * Fast, numerous, developer-facing
344
+ * Example: "calculateTotal returns correct sum with discounts"
345
+
346
+ - security: Validates security controls and identifies vulnerabilities
347
+ * Penetration testing, vulnerability scanning, auth testing
348
+ * Example: "SQL injection attempts are blocked"
349
+
350
+ - performance: Validates speed, throughput, and resource usage
351
+ * Load testing, stress testing, benchmarking
352
+ * Example: "System handles 1000 concurrent users with <500ms response"
353
+
354
+ - inspection: Manual review or audit (non-automated verification)
355
+ * Code review, design review, compliance audit
356
+ * Example: "Security architect reviews authentication design"
357
+
358
+ FOR LLMs:
359
+ - Generate acceptance tests from requirement acceptance criteria
360
+ - Generate unit tests for individual functions in generated code
361
+ - Generate integration tests for API endpoints and external calls
362
+ - Map NFR requirements to performance tests
363
+ - Map SR requirements to security tests
364
+ -->
365
+ <xs:simpleType name="TestType">
366
+ <xs:restriction base="xs:token">
367
+ <xs:enumeration value="acceptance"/>
368
+ <xs:enumeration value="integration"/>
369
+ <xs:enumeration value="unit"/>
370
+ <xs:enumeration value="security"/>
371
+ <xs:enumeration value="performance"/>
372
+ <xs:enumeration value="inspection"/>
373
+ </xs:restriction>
374
+ </xs:simpleType>
375
+
376
+ <!--
377
+ ConfidenceType: Probability/certainty level for trace links and estimates
378
+
379
+ Range: 0.0 to 1.0 (0% to 100% confidence)
380
+
381
+ INTERPRETATION:
382
+ - 1.0: Certain; formally verified or definitionally true
383
+ - 0.8-0.99: High confidence; strong evidence or expert judgment
384
+ - 0.5-0.79: Medium confidence; reasonable belief with some uncertainty
385
+ - 0.2-0.49: Low confidence; tentative or speculative
386
+ - 0.0-0.19: Very low confidence; placeholder or assumption needing validation
387
+
388
+ FOR LLMs:
389
+ - Use confidence on trace edges to indicate strength of relationship
390
+ - Lower confidence links should be flagged for stakeholder review
391
+ - When eliciting, ask about confidence when relationships are uncertain
392
+ - When analyzing impact, weight changes by confidence of affected links
393
+ -->
394
+ <xs:simpleType name="ConfidenceType">
395
+ <xs:restriction base="xs:decimal">
396
+ <xs:minInclusive value="0.0"/>
397
+ <xs:maxInclusive value="1.0"/>
398
+ </xs:restriction>
399
+ </xs:simpleType>
400
+
401
+ <!--
402
+ StateKindType: Classification of states in a state machine
403
+
404
+ VALUES:
405
+ - initial: The starting state; exactly one per state machine
406
+ - normal: Regular intermediate state (default)
407
+ - final: Terminal state; no outgoing transitions allowed
408
+
409
+ FOR LLMs:
410
+ - Every state machine must have exactly one initial state
411
+ - Final states represent completed lifecycles
412
+ - Normal states are the default; omit the attribute for normal states
413
+ -->
414
+ <xs:simpleType name="StateKindType">
415
+ <xs:restriction base="xs:token">
416
+ <xs:enumeration value="initial"/>
417
+ <xs:enumeration value="normal"/>
418
+ <xs:enumeration value="final"/>
419
+ </xs:restriction>
420
+ </xs:simpleType>
421
+
422
+ <!-- =========================
423
+ Reusable complex types
424
+
425
+ Building blocks used by multiple sections of the schema.
426
+ ========================= -->
427
+
428
+ <!--
429
+ TextBlockType: Rich text content container
430
+
431
+ Allows mixed content (text with embedded elements) for descriptions,
432
+ statements, rationales, and other narrative content.
433
+
434
+ FOR LLMs:
435
+ - Can contain plain text or simple markup
436
+ - Use for any prose content: descriptions, rationales, notes
437
+ - Keep content concise but complete
438
+ - In statements, use normative language: "SHALL", "SHOULD", "MAY" (RFC 2119)
439
+ -->
440
+ <xs:complexType name="TextBlockType" mixed="true">
441
+ <xs:sequence>
442
+ <xs:any minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
443
+ </xs:sequence>
444
+ </xs:complexType>
445
+
446
+ <!--
447
+ RefType: Single reference to another element by ID
448
+
449
+ Used to create links between elements (e.g., requirement references a goal).
450
+ The @ref attribute must contain a valid IdType that exists in the document.
451
+
452
+ FOR LLMs: Always verify that referenced IDs exist in the document.
453
+ -->
454
+ <xs:complexType name="RefType">
455
+ <xs:attribute name="ref" type="IdType" use="required"/>
456
+ </xs:complexType>
457
+
458
+ <!--
459
+ RefsType: Collection of references to other elements
460
+
461
+ Container for multiple ref elements, used when an artifact relates to
462
+ several other artifacts (e.g., a requirement linked to multiple goals).
463
+ -->
464
+ <xs:complexType name="RefsType">
465
+ <xs:sequence>
466
+ <xs:element name="ref" type="RefType" minOccurs="0" maxOccurs="unbounded"/>
467
+ </xs:sequence>
468
+ </xs:complexType>
469
+
470
+ <!-- =========================
471
+ Root Element
472
+
473
+ The rqml element is the document root. It enforces:
474
+ 1. Required version and document identity
475
+ 2. Unique IDs across all elements (via xs:key)
476
+ 3. Referential integrity for trace edges (via xs:keyref)
477
+ ========================= -->
478
+
479
+ <!--
480
+ rqml: Root element of an RQML document
481
+
482
+ REQUIRED ATTRIBUTES:
483
+ - version: Schema version (fixed at "2.0.1")
484
+ - docId: Unique document identifier; keep stable across revisions
485
+ - status: Document lifecycle state (draft/review/approved/deprecated)
486
+
487
+ STRUCTURE:
488
+ Contains sections in fixed order: meta, catalogs?, domain?, goals?,
489
+ scenarios?, requirements, behavior?, interfaces?, verification?, trace?, governance?
490
+
491
+ CONSTRAINTS:
492
+ - All @id attributes must be unique within the document
493
+ - All trace edge @from and @to must reference existing IDs
494
+
495
+ FOR LLMs:
496
+ - Always include xmlns="https://rqml.org/schema/2.0.1"
497
+ - Start documents with status="draft" during elicitation
498
+ - Use a meaningful docId that identifies the system/project
499
+ -->
500
+ <xs:element name="rqml" type="RqmlDocumentType">
501
+
502
+ <!-- Ensure IDs are unique across the document -->
503
+ <xs:key name="allIds">
504
+ <xs:selector xpath=".//profile|.//term|.//actor|.//stakeholder|.//constraint|.//policy|.//decision|.//risk|.//entity|.//attr|.//rule|.//stateMachine|.//state|.//transition|.//goal|.//qgoal|.//obstacle|.//goalLink|.//scenario|.//misuseCase|.//edgeCase|.//reqPackage|.//req|.//criterion|.//api|.//endpoint|.//event|.//testSuite|.//testCase|.//traceEdge|.//issue|.//approval"/>
505
+ <xs:field xpath="@id"/>
506
+ </xs:key>
507
+
508
+ <!-- Trace edges: internal refs (from/to) must point to declared ids.
509
+ External refs (fromUri/toUri) are not validated by schema.
510
+ Keyrefs only fire when the attribute is present. -->
511
+ <xs:keyref name="traceFromRef" refer="allIds">
512
+ <xs:selector xpath=".//traceEdge"/>
513
+ <xs:field xpath="@from"/>
514
+ </xs:keyref>
515
+ <xs:keyref name="traceToRef" refer="allIds">
516
+ <xs:selector xpath=".//traceEdge"/>
517
+ <xs:field xpath="@to"/>
518
+ </xs:keyref>
519
+
520
+ <!-- State machine initial state must reference a declared state -->
521
+ <xs:keyref name="smInitialRef" refer="allIds">
522
+ <xs:selector xpath=".//stateMachine"/>
523
+ <xs:field xpath="@initial"/>
524
+ </xs:keyref>
525
+
526
+ <!-- Transition from/to must reference declared states -->
527
+ <xs:keyref name="transitionFromRef" refer="allIds">
528
+ <xs:selector xpath=".//transition"/>
529
+ <xs:field xpath="@from"/>
530
+ </xs:keyref>
531
+ <xs:keyref name="transitionToRef" refer="allIds">
532
+ <xs:selector xpath=".//transition"/>
533
+ <xs:field xpath="@to"/>
534
+ </xs:keyref>
535
+
536
+ </xs:element>
537
+
538
+ <!--
539
+ RqmlDocumentType: Structure of the complete RQML document
540
+
541
+ Defines the top-level sections in their required order.
542
+ Only `meta` and `requirements` are mandatory; others are optional
543
+ but recommended for complete specifications.
544
+ -->
545
+ <xs:complexType name="RqmlDocumentType">
546
+ <xs:sequence>
547
+ <xs:element name="meta" type="MetaType"/>
548
+ <xs:element name="catalogs" type="CatalogsType" minOccurs="0"/>
549
+ <xs:element name="domain" type="DomainType" minOccurs="0"/>
550
+ <xs:element name="goals" type="GoalsType" minOccurs="0"/>
551
+ <xs:element name="scenarios" type="ScenariosType" minOccurs="0"/>
552
+ <xs:element name="requirements" type="RequirementsType"/>
553
+ <xs:element name="behavior" type="BehaviorType" minOccurs="0"/>
554
+ <xs:element name="interfaces" type="InterfacesType" minOccurs="0"/>
555
+ <xs:element name="verification" type="VerificationType" minOccurs="0"/>
556
+ <xs:element name="trace" type="TraceTypeContainer" minOccurs="0"/>
557
+ <xs:element name="governance" type="GovernanceType" minOccurs="0"/>
558
+ </xs:sequence>
559
+
560
+ <xs:attribute name="version" type="xs:token" use="required" fixed="2.0.1"/>
561
+ <xs:attribute name="docId" type="IdType" use="required"/>
562
+ <xs:attribute name="status" type="StatusType" use="required"/>
563
+ </xs:complexType>
564
+
565
+ <!-- =========================
566
+ Meta Section
567
+
568
+ Document identity, ownership, and conventions. Required section that
569
+ must appear first. Establishes provenance and change control context.
570
+
571
+ FOR LLMs:
572
+ - Always populate title and system
573
+ - Use conventions to establish ID patterns and normative keywords
574
+ - Track updates in dates/updated for change management
575
+ - Use profiles for domain-specific customizations
576
+ ========================= -->
577
+
578
+ <!--
579
+ MetaType: Document metadata container
580
+
581
+ REQUIRED CHILDREN:
582
+ - title: Human-readable document name
583
+ - system: Name/code of the system being specified
584
+
585
+ OPTIONAL CHILDREN:
586
+ - summary: Overview of scope and purpose
587
+ - authors: Who wrote/owns this document
588
+ - dates: Creation, update, and release timing
589
+ - conventions: Rules for IDs and normative language
590
+ - profiles: Domain-specific customizations
591
+ -->
592
+ <xs:complexType name="MetaType">
593
+ <xs:sequence>
594
+ <xs:element name="title" type="xs:string"/>
595
+ <xs:element name="system" type="xs:string"/>
596
+ <xs:element name="summary" type="TextBlockType" minOccurs="0"/>
597
+ <xs:element name="authors" type="AuthorsType" minOccurs="0"/>
598
+ <xs:element name="dates" type="DatesType" minOccurs="0"/>
599
+ <xs:element name="conventions" type="ConventionsType" minOccurs="0"/>
600
+ <xs:element name="profiles" type="ProfilesType" minOccurs="0"/>
601
+ </xs:sequence>
602
+ </xs:complexType>
603
+
604
+ <xs:complexType name="AuthorsType">
605
+ <xs:sequence>
606
+ <xs:element name="author" type="AuthorType" minOccurs="1" maxOccurs="unbounded"/>
607
+ </xs:sequence>
608
+ </xs:complexType>
609
+
610
+ <!--
611
+ AuthorType: Individual author/contributor information
612
+
613
+ FOR LLMs: Capture at least name and role for accountability.
614
+ Contact info helps with follow-up questions during elicitation.
615
+ -->
616
+ <xs:complexType name="AuthorType">
617
+ <xs:sequence>
618
+ <xs:element name="name" type="xs:string"/>
619
+ <xs:element name="role" type="xs:string" minOccurs="0"/>
620
+ <xs:element name="org" type="xs:string" minOccurs="0"/>
621
+ <xs:element name="contact" type="xs:string" minOccurs="0"/>
622
+ </xs:sequence>
623
+ </xs:complexType>
624
+
625
+ <!--
626
+ DatesType: Temporal metadata for change control
627
+
628
+ - created: When the document was first created (xs:date format: YYYY-MM-DD)
629
+ - updated: When the document was last modified
630
+ - targetRelease: Version/sprint/date when requirements should be delivered
631
+ -->
632
+ <xs:complexType name="DatesType">
633
+ <xs:sequence>
634
+ <xs:element name="created" type="xs:date" minOccurs="0"/>
635
+ <xs:element name="updated" type="xs:date" minOccurs="0"/>
636
+ <xs:element name="targetRelease" type="xs:string" minOccurs="0"/>
637
+ </xs:sequence>
638
+ </xs:complexType>
639
+
640
+ <!--
641
+ ConventionsType: Document-wide rules and standards
642
+
643
+ - normativeKeywords: How to interpret MUST/SHALL/SHOULD/MAY (typically RFC 2119)
644
+ - idConventions: Patterns for generating IDs (e.g., "REQ-<AREA>-NNN")
645
+
646
+ FOR LLMs: Follow these conventions when adding new elements.
647
+ -->
648
+ <xs:complexType name="ConventionsType">
649
+ <xs:sequence>
650
+ <xs:element name="normativeKeywords" type="TextBlockType" minOccurs="0"/>
651
+ <xs:element name="idConventions" type="TextBlockType" minOccurs="0"/>
652
+ </xs:sequence>
653
+ </xs:complexType>
654
+
655
+ <xs:complexType name="ProfilesType">
656
+ <xs:sequence>
657
+ <xs:element name="profile" type="ProfileType" minOccurs="0" maxOccurs="unbounded"/>
658
+ </xs:sequence>
659
+ </xs:complexType>
660
+
661
+ <!--
662
+ ProfileType: Domain-specific customization or viewpoint
663
+
664
+ Profiles allow tailoring the spec for different audiences or domains
665
+ (e.g., safety-critical, regulatory, mobile). Similar to viewpoints in
666
+ ISO/IEC/IEEE 42010 architecture descriptions.
667
+
668
+ ATTRIBUTES:
669
+ - id: Unique identifier for the profile
670
+ - type: Category of profile (e.g., "safety", "compliance", "mobile")
671
+ -->
672
+ <xs:complexType name="ProfileType">
673
+ <xs:sequence>
674
+ <xs:element name="description" type="TextBlockType" minOccurs="0"/>
675
+ </xs:sequence>
676
+ <xs:attribute name="id" type="IdType" use="required"/>
677
+ <xs:attribute name="type" type="xs:token" use="required"/>
678
+ </xs:complexType>
679
+
680
+ <!-- =========================
681
+ Catalogs Section
682
+
683
+ Shared definitions and reusable reference lists. Centralizes vocabulary
684
+ and facts to keep requirements concise and consistent.
685
+
686
+ FOR LLMs:
687
+ - Define terms in glossary BEFORE using them in requirements
688
+ - Define actors and stakeholders to establish WHO the system serves
689
+ - Capture constraints early - they limit the solution space
690
+ - Log decisions to preserve rationale (like ADRs)
691
+ - Document risks so requirements can address them
692
+ ========================= -->
693
+
694
+ <!--
695
+ CatalogsType: Container for all catalog subsections
696
+
697
+ Subsections can appear in any order and multiple times.
698
+ All provide referenceable items for use throughout the document.
699
+ -->
700
+ <xs:complexType name="CatalogsType">
701
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
702
+ <xs:element name="glossary" type="GlossaryType"/>
703
+ <xs:element name="actors" type="ActorsType"/>
704
+ <xs:element name="stakeholders" type="StakeholdersType"/>
705
+ <xs:element name="constraints" type="ConstraintsType"/>
706
+ <xs:element name="policies" type="PoliciesType"/>
707
+ <xs:element name="decisions" type="DecisionsType"/>
708
+ <xs:element name="risks" type="RisksType"/>
709
+ </xs:choice>
710
+ </xs:complexType>
711
+
712
+ <!--
713
+ GlossaryType: Domain vocabulary definitions
714
+
715
+ Establishes shared understanding of terms to reduce ambiguity.
716
+ IEEE 29148 emphasizes consistent terminology in requirements.
717
+
718
+ FOR LLMs:
719
+ - Add terms when stakeholders use domain-specific language
720
+ - Reference terms by ID in requirements to enforce consistency
721
+ - Include synonyms to handle variant terminology
722
+ -->
723
+ <xs:complexType name="GlossaryType">
724
+ <xs:sequence>
725
+ <xs:element name="term" type="TermType" minOccurs="0" maxOccurs="unbounded"/>
726
+ </xs:sequence>
727
+ </xs:complexType>
728
+
729
+ <!--
730
+ TermType: Individual glossary entry
731
+
732
+ ATTRIBUTES:
733
+ - id: Unique identifier (e.g., TERM-PCI, TERM-PAYMENT)
734
+
735
+ CHILDREN:
736
+ - name: The term as used in text
737
+ - definition: Precise meaning in this context
738
+ - synonyms: Alternative names for the same concept
739
+ -->
740
+ <xs:complexType name="TermType">
741
+ <xs:sequence>
742
+ <xs:element name="name" type="xs:string"/>
743
+ <xs:element name="definition" type="TextBlockType"/>
744
+ <xs:element name="synonyms" type="SynonymsType" minOccurs="0"/>
745
+ </xs:sequence>
746
+ <xs:attribute name="id" type="IdType" use="required"/>
747
+ </xs:complexType>
748
+
749
+ <xs:complexType name="SynonymsType">
750
+ <xs:sequence>
751
+ <xs:element name="synonym" type="xs:string" minOccurs="1" maxOccurs="unbounded"/>
752
+ </xs:sequence>
753
+ </xs:complexType>
754
+
755
+ <!--
756
+ ActorsType: Users and external systems that interact with the system
757
+
758
+ Actors from UML use case modeling - entities outside the system boundary
759
+ that interact with it. Can be humans, systems, or devices.
760
+ -->
761
+ <xs:complexType name="ActorsType">
762
+ <xs:sequence>
763
+ <xs:element name="actor" type="ActorType" minOccurs="0" maxOccurs="unbounded"/>
764
+ </xs:sequence>
765
+ </xs:complexType>
766
+
767
+ <!--
768
+ ActorType: Individual actor definition
769
+
770
+ ATTRIBUTES:
771
+ - id: Unique identifier (e.g., ACT-USER, ACT-ADMIN, ACT-PAYMENT-GATEWAY)
772
+ - name: Human-readable actor name
773
+ - type: Category of actor (e.g., "human", "system", "device", "timer")
774
+
775
+ CHILDREN:
776
+ - description: Role and characteristics of this actor
777
+ - goals: References to goals this actor wants to achieve
778
+
779
+ FOR LLMs:
780
+ - Reference actors in scenarios via actorRef
781
+ - Link actors to their goals to trace motivation
782
+ - Use actor types to distinguish user personas from system integrations
783
+ -->
784
+ <xs:complexType name="ActorType">
785
+ <xs:sequence>
786
+ <xs:element name="description" type="TextBlockType" minOccurs="0"/>
787
+ <xs:element name="goals" type="RefsType" minOccurs="0"/>
788
+ </xs:sequence>
789
+ <xs:attribute name="id" type="IdType" use="required"/>
790
+ <xs:attribute name="name" type="xs:string" use="required"/>
791
+ <xs:attribute name="type" type="xs:token" use="optional"/>
792
+ </xs:complexType>
793
+
794
+ <!--
795
+ StakeholdersType: Parties with interest in the system
796
+
797
+ Stakeholders may not directly use the system but have concerns that
798
+ requirements must address (e.g., compliance officers, operations team).
799
+ Aligns with BABOK stakeholder analysis.
800
+ -->
801
+ <xs:complexType name="StakeholdersType">
802
+ <xs:sequence>
803
+ <xs:element name="stakeholder" type="StakeholderType" minOccurs="0" maxOccurs="unbounded"/>
804
+ </xs:sequence>
805
+ </xs:complexType>
806
+
807
+ <!--
808
+ StakeholderType: Individual stakeholder definition
809
+
810
+ ATTRIBUTES:
811
+ - id: Unique identifier (e.g., STK-RISK, STK-OPS, STK-LEGAL)
812
+ - name: Stakeholder name or role
813
+ - org: Organization they belong to
814
+
815
+ CHILDREN:
816
+ - concerns: What this stakeholder cares about; requirements should address these
817
+
818
+ FOR LLMs:
819
+ - Use ownerRef to assign requirements to responsible stakeholders
820
+ - Ensure each concern maps to at least one requirement
821
+ - Different stakeholders may have conflicting concerns - flag these
822
+ -->
823
+ <xs:complexType name="StakeholderType">
824
+ <xs:sequence>
825
+ <xs:element name="concerns" type="TextBlockType" minOccurs="0"/>
826
+ </xs:sequence>
827
+ <xs:attribute name="id" type="IdType" use="required"/>
828
+ <xs:attribute name="name" type="xs:string" use="required"/>
829
+ <xs:attribute name="org" type="xs:string" use="optional"/>
830
+ </xs:complexType>
831
+
832
+ <!--
833
+ ConstraintsType: Non-negotiable limitations on the solution
834
+
835
+ Constraints restrict what solutions are acceptable, unlike requirements
836
+ which specify what the solution must do. They come from technical,
837
+ business, regulatory, or organizational sources.
838
+ -->
839
+ <xs:complexType name="ConstraintsType">
840
+ <xs:sequence>
841
+ <xs:element name="constraint" type="ConstraintType" minOccurs="0" maxOccurs="unbounded"/>
842
+ </xs:sequence>
843
+ </xs:complexType>
844
+
845
+ <!--
846
+ ConstraintType: Individual constraint definition
847
+
848
+ ATTRIBUTES:
849
+ - id: Unique identifier (e.g., CON-HTTPS, CON-K8S, CON-JAVA17)
850
+ - severity: Impact level (e.g., "high", "medium", "low", "blocking")
851
+
852
+ CHILDREN:
853
+ - statement: What is constrained and how
854
+ - source: Where this constraint comes from (policy, standard, etc.)
855
+
856
+ FOR LLMs:
857
+ - Constraints with severity="blocking" must be satisfied by any solution
858
+ - When generating code, check constraints first to avoid invalid approaches
859
+ - Reference constraints in requirement rationale to explain "why this way"
860
+
861
+ EXAMPLES:
862
+ - "All APIs must use TLS 1.2+" (source: Security Policy)
863
+ - "Must deploy to AWS us-east-1" (source: Data Residency Policy)
864
+ - "Must use Java 17 LTS" (source: Platform Standards)
865
+ -->
866
+ <xs:complexType name="ConstraintType">
867
+ <xs:sequence>
868
+ <xs:element name="statement" type="TextBlockType"/>
869
+ <xs:element name="source" type="xs:string" minOccurs="0"/>
870
+ </xs:sequence>
871
+ <xs:attribute name="id" type="IdType" use="required"/>
872
+ <xs:attribute name="severity" type="xs:token" use="optional"/>
873
+ </xs:complexType>
874
+
875
+ <!--
876
+ PoliciesType: Organizational and regulatory obligations
877
+
878
+ Policies define what MUST be done due to external mandates (laws,
879
+ regulations, standards) or internal rules. They differ from constraints
880
+ in that they specify obligations rather than limitations.
881
+ -->
882
+ <xs:complexType name="PoliciesType">
883
+ <xs:sequence>
884
+ <xs:element name="policy" type="PolicyType" minOccurs="0" maxOccurs="unbounded"/>
885
+ </xs:sequence>
886
+ </xs:complexType>
887
+
888
+ <!--
889
+ PolicyType: Individual policy definition
890
+
891
+ ATTRIBUTES:
892
+ - id: Unique identifier (e.g., POL-GDPR-CONSENT, POL-PCI-STORAGE)
893
+ - source: Authority mandating this policy (e.g., "GDPR Art. 7", "PCI-DSS 3.4")
894
+
895
+ CHILDREN:
896
+ - obligation: What must be done to comply
897
+ - evidence: How compliance is demonstrated
898
+
899
+ FOR LLMs:
900
+ - Generate PR (Policy/Compliance) requirements from policies
901
+ - Include evidence requirements in verification section
902
+ - Policy violations can have legal/financial consequences - flag gaps
903
+ -->
904
+ <xs:complexType name="PolicyType">
905
+ <xs:sequence>
906
+ <xs:element name="obligation" type="TextBlockType"/>
907
+ <xs:element name="evidence" type="TextBlockType" minOccurs="0"/>
908
+ </xs:sequence>
909
+ <xs:attribute name="id" type="IdType" use="required"/>
910
+ <xs:attribute name="source" type="xs:string" use="optional"/>
911
+ </xs:complexType>
912
+
913
+ <!--
914
+ DecisionsType: Architecture and design decisions
915
+
916
+ Records significant decisions and their rationale. Similar to Architecture
917
+ Decision Records (ADRs). Preserves context for future maintainers.
918
+ -->
919
+ <xs:complexType name="DecisionsType">
920
+ <xs:sequence>
921
+ <xs:element name="decision" type="DecisionType" minOccurs="0" maxOccurs="unbounded"/>
922
+ </xs:sequence>
923
+ </xs:complexType>
924
+
925
+ <!--
926
+ DecisionType: Individual decision record
927
+
928
+ ATTRIBUTES:
929
+ - id: Unique identifier (e.g., DEC-IDEMPOTENCY, DEC-DATABASE)
930
+ - status: Decision lifecycle (draft/review/approved/deprecated)
931
+
932
+ CHILDREN:
933
+ - context: Why this decision was needed (the problem)
934
+ - decision: What was decided (the solution chosen)
935
+ - alternatives: Other options considered and why rejected
936
+ - consequences: Implications of this decision (good and bad)
937
+
938
+ FOR LLMs:
939
+ - When generating code, follow approved decisions
940
+ - Deprecated decisions may explain legacy code
941
+ - Use decision context to understand trade-offs
942
+ - Reference decisions in requirement rationale
943
+ -->
944
+ <xs:complexType name="DecisionType">
945
+ <xs:sequence>
946
+ <xs:element name="context" type="TextBlockType"/>
947
+ <xs:element name="decision" type="TextBlockType"/>
948
+ <xs:element name="alternatives" type="TextBlockType" minOccurs="0"/>
949
+ <xs:element name="consequences" type="TextBlockType" minOccurs="0"/>
950
+ </xs:sequence>
951
+ <xs:attribute name="id" type="IdType" use="required"/>
952
+ <xs:attribute name="status" type="StatusType" use="optional"/>
953
+ </xs:complexType>
954
+
955
+ <!--
956
+ RisksType: Identified risks to the project or system
957
+
958
+ Risks are potential problems that could prevent goals from being achieved.
959
+ Aligned with ISO 31000 risk management principles.
960
+ -->
961
+ <xs:complexType name="RisksType">
962
+ <xs:sequence>
963
+ <xs:element name="risk" type="RiskType" minOccurs="0" maxOccurs="unbounded"/>
964
+ </xs:sequence>
965
+ </xs:complexType>
966
+
967
+ <!--
968
+ RiskType: Individual risk entry
969
+
970
+ ATTRIBUTES:
971
+ - id: Unique identifier (e.g., RISK-FRAUD, RISK-DOWNTIME, RISK-DATA-LOSS)
972
+ - severity: Impact level (e.g., "critical", "high", "medium", "low")
973
+
974
+ CHILDREN:
975
+ - statement: Description of the risk and its potential impact
976
+ - mitigation: How this risk is addressed (link to requirements/controls)
977
+
978
+ FOR LLMs:
979
+ - Create trace edges from risks to goals they threaten (type="threatens")
980
+ - Create trace edges from requirements to risks they mitigate (type="mitigates")
981
+ - Generate SR (Security) or NFR requirements to address high-severity risks
982
+ - Unmitigated high-severity risks should be flagged
983
+ -->
984
+ <xs:complexType name="RiskType">
985
+ <xs:sequence>
986
+ <xs:element name="statement" type="TextBlockType"/>
987
+ <xs:element name="mitigation" type="TextBlockType" minOccurs="0"/>
988
+ </xs:sequence>
989
+ <xs:attribute name="id" type="IdType" use="required"/>
990
+ <xs:attribute name="severity" type="xs:token" use="optional"/>
991
+ </xs:complexType>
992
+
993
+ <!-- =========================
994
+ Domain Section
995
+
996
+ Captures shared understanding of the problem space: key concepts,
997
+ data structures, and business logic. Provides vocabulary for requirements.
998
+
999
+ Aligned with Domain-Driven Design (DDD) and Michael Jackson's Problem Frames.
1000
+
1001
+ FOR LLMs:
1002
+ - Use entities as the basis for data models and class hierarchies
1003
+ - Use attributes to generate database schemas and API payloads
1004
+ - Use business rules to generate validation logic
1005
+ - Reference domain elements in requirements via appliesTo or refs
1006
+ ========================= -->
1007
+
1008
+ <!--
1009
+ DomainType: Problem space model
1010
+
1011
+ CHILDREN:
1012
+ - overview: High-level context, assumptions, and scope boundaries
1013
+ - entities: Key domain objects and their attributes
1014
+ - businessRules: Invariants and logic that govern the domain
1015
+ -->
1016
+ <xs:complexType name="DomainType">
1017
+ <xs:sequence>
1018
+ <xs:element name="overview" type="TextBlockType" minOccurs="0"/>
1019
+ <xs:element name="entities" type="EntitiesType" minOccurs="0"/>
1020
+ <xs:element name="businessRules" type="BusinessRulesType" minOccurs="0"/>
1021
+ </xs:sequence>
1022
+ </xs:complexType>
1023
+
1024
+ <xs:complexType name="EntitiesType">
1025
+ <xs:sequence>
1026
+ <xs:element name="entity" type="EntityType" minOccurs="0" maxOccurs="unbounded"/>
1027
+ </xs:sequence>
1028
+ </xs:complexType>
1029
+
1030
+ <!--
1031
+ EntityType: Domain object definition
1032
+
1033
+ Entities are the core concepts in the problem domain. They become classes,
1034
+ database tables, API resources, and form the ubiquitous language.
1035
+
1036
+ ATTRIBUTES:
1037
+ - id: Unique identifier (e.g., ENT-PAYMENT, ENT-USER, ENT-ORDER)
1038
+ - name: Entity name (use PascalCase for code generation)
1039
+
1040
+ CHILDREN:
1041
+ - description: Purpose and role of this entity
1042
+ - attr: Attributes (properties/fields) of the entity
1043
+
1044
+ FOR LLMs:
1045
+ - Generate classes/types from entities
1046
+ - Generate database tables from entities
1047
+ - Generate API resource schemas from entities
1048
+ - Entity names become part of the ubiquitous language
1049
+ -->
1050
+ <xs:complexType name="EntityType">
1051
+ <xs:sequence>
1052
+ <xs:element name="description" type="TextBlockType" minOccurs="0"/>
1053
+ <xs:element name="attr" type="AttrType" minOccurs="0" maxOccurs="unbounded"/>
1054
+ </xs:sequence>
1055
+ <xs:attribute name="id" type="IdType" use="required"/>
1056
+ <xs:attribute name="name" type="xs:string" use="required"/>
1057
+ </xs:complexType>
1058
+
1059
+ <!--
1060
+ AttrType: Entity attribute (property/field)
1061
+
1062
+ ATTRIBUTES:
1063
+ - id: Unique identifier (e.g., ATTR-PAYMENT-ID, ATTR-AMOUNT)
1064
+ - name: Attribute name (use camelCase for code generation)
1065
+ - type: Data type token (e.g., "uuid", "string", "decimal", "ISO8601-timestamp", "email")
1066
+ - required: Whether this attribute must have a value (boolean)
1067
+
1068
+ CHILDREN:
1069
+ - description: Purpose and semantics of this attribute
1070
+ - constraints: Validation rules (e.g., "positive", "max 255 chars", "valid email format")
1071
+
1072
+ FOR LLMs:
1073
+ - Generate class properties from attributes
1074
+ - Generate database columns from attributes
1075
+ - Generate validation code from constraints
1076
+ - Use type tokens consistently across the document
1077
+
1078
+ COMMON TYPE TOKENS:
1079
+ - uuid: Universally unique identifier
1080
+ - string: Text value
1081
+ - decimal: Numeric value with precision
1082
+ - integer: Whole number
1083
+ - boolean: True/false
1084
+ - ISO8601-timestamp: Date-time in ISO 8601 format
1085
+ - email: Email address format
1086
+ - url: URL/URI format
1087
+ - enum:value1,value2,value3: Enumerated values
1088
+ -->
1089
+ <xs:complexType name="AttrType">
1090
+ <xs:sequence>
1091
+ <xs:element name="description" type="TextBlockType" minOccurs="0"/>
1092
+ <xs:element name="constraints" type="TextBlockType" minOccurs="0"/>
1093
+ </xs:sequence>
1094
+ <xs:attribute name="id" type="IdType" use="required"/>
1095
+ <xs:attribute name="name" type="xs:string" use="required"/>
1096
+ <xs:attribute name="type" type="xs:token" use="required"/>
1097
+ <xs:attribute name="required" type="xs:boolean" use="optional"/>
1098
+ </xs:complexType>
1099
+
1100
+ <!--
1101
+ BusinessRulesType: Domain logic and invariants
1102
+
1103
+ Business rules are constraints and logic that govern how the domain behaves.
1104
+ They exist independent of any particular system implementation.
1105
+ Aligned with the Business Rules Manifesto.
1106
+ -->
1107
+ <xs:complexType name="BusinessRulesType">
1108
+ <xs:sequence>
1109
+ <xs:element name="rule" type="RuleType" minOccurs="0" maxOccurs="unbounded"/>
1110
+ </xs:sequence>
1111
+ </xs:complexType>
1112
+
1113
+ <!--
1114
+ RuleType: Individual business rule
1115
+
1116
+ ATTRIBUTES:
1117
+ - id: Unique identifier (e.g., BR-DECLINE, BR-DISCOUNT, BR-SHIPPING)
1118
+
1119
+ CHILDREN:
1120
+ - statement: The rule expressed in domain language
1121
+ - examples: Concrete instances showing the rule in action
1122
+
1123
+ FOR LLMs:
1124
+ - Generate validation logic from business rules
1125
+ - Generate test cases from examples
1126
+ - Business rules may become FR (functional) or DR (data) requirements
1127
+ - Rules often translate to if/then logic or constraints
1128
+
1129
+ EXAMPLE:
1130
+ - Rule: "Orders over $100 qualify for free shipping"
1131
+ - Example: "$150 order -> free shipping; $50 order -> $5.99 shipping"
1132
+ -->
1133
+ <xs:complexType name="RuleType">
1134
+ <xs:sequence>
1135
+ <xs:element name="statement" type="TextBlockType"/>
1136
+ <xs:element name="examples" type="TextBlockType" minOccurs="0"/>
1137
+ </xs:sequence>
1138
+ <xs:attribute name="id" type="IdType" use="required"/>
1139
+ </xs:complexType>
1140
+
1141
+ <!-- =========================
1142
+ Goals Section
1143
+
1144
+ Captures WHY the system exists: business objectives, quality targets,
1145
+ and obstacles that threaten success. Goals drive requirements.
1146
+
1147
+ Aligned with KAOS and i* goal-oriented requirements engineering.
1148
+
1149
+ FOR LLMs:
1150
+ - Start elicitation by asking "what are you trying to achieve?"
1151
+ - Decompose high-level goals into sub-goals (refines relationship)
1152
+ - Derive requirements that satisfy goals
1153
+ - Identify obstacles/risks that threaten goals
1154
+ - Quality goals need measurable metrics
1155
+ ========================= -->
1156
+
1157
+ <!--
1158
+ GoalsType: Goal model container
1159
+
1160
+ CHILDREN:
1161
+ - goal: Business/functional objectives
1162
+ - qgoal: Quality/non-functional objectives
1163
+ - obstacle: Threats to goal achievement
1164
+ - goalLink: Relationships between goals, obstacles, and other elements
1165
+ -->
1166
+ <xs:complexType name="GoalsType">
1167
+ <xs:sequence>
1168
+ <xs:element name="goal" type="GoalType" minOccurs="0" maxOccurs="unbounded"/>
1169
+ <xs:element name="qgoal" type="QualityGoalType" minOccurs="0" maxOccurs="unbounded"/>
1170
+ <xs:element name="obstacle" type="ObstacleType" minOccurs="0" maxOccurs="unbounded"/>
1171
+ <xs:element name="goalLink" type="GoalLinkType" minOccurs="0" maxOccurs="unbounded"/>
1172
+ </xs:sequence>
1173
+ </xs:complexType>
1174
+
1175
+ <!--
1176
+ GoalType: Business or functional objective
1177
+
1178
+ Goals express what stakeholders want to achieve. They are intentional
1179
+ (describe desired state) rather than operational (describe how to achieve).
1180
+
1181
+ ATTRIBUTES:
1182
+ - id: Unique identifier (e.g., GOAL-AVAIL, GOAL-REVENUE, GOAL-COMPLIANCE)
1183
+ - title: Short descriptive name
1184
+ - priority: Importance (must/should/may)
1185
+ - status: Lifecycle state
1186
+ - ownerRef: Reference to stakeholder who owns this goal
1187
+
1188
+ CHILDREN:
1189
+ - statement: What should be achieved (use "Maintain...", "Achieve...", "Ensure...")
1190
+ - rationale: Why this goal matters (business justification)
1191
+
1192
+ FOR LLMs:
1193
+ - Ask "why?" to discover goals behind requirements
1194
+ - High-level goals decompose into sub-goals (create goalLink with type="refines")
1195
+ - Requirements satisfy goals (create trace edge with type="satisfies")
1196
+ - Goals without requirements indicate gaps
1197
+
1198
+ EXAMPLES:
1199
+ - "Achieve 99.9% availability during peak shopping periods"
1200
+ - "Maintain compliance with PCI-DSS for all card transactions"
1201
+ - "Ensure new users can complete checkout within 3 minutes"
1202
+ -->
1203
+ <xs:complexType name="GoalType">
1204
+ <xs:sequence>
1205
+ <xs:element name="statement" type="TextBlockType"/>
1206
+ <xs:element name="rationale" type="TextBlockType" minOccurs="0"/>
1207
+ </xs:sequence>
1208
+ <xs:attribute name="id" type="IdType" use="required"/>
1209
+ <xs:attribute name="title" type="xs:string" use="required"/>
1210
+ <xs:attribute name="priority" type="PriorityType" use="optional"/>
1211
+ <xs:attribute name="status" type="StatusType" use="optional"/>
1212
+ <xs:attribute name="ownerRef" type="IdType" use="optional"/>
1213
+ </xs:complexType>
1214
+
1215
+ <!--
1216
+ QualityGoalType: Non-functional quality objective
1217
+
1218
+ Quality goals specify HOW WELL the system should perform. They map to
1219
+ ISO/IEC 25010 quality attributes (performance, security, usability, etc.).
1220
+
1221
+ ATTRIBUTES:
1222
+ - id: Unique identifier (e.g., QGOAL-LATENCY, QGOAL-SECURITY, QGOAL-USABILITY)
1223
+ - title: Short descriptive name
1224
+ - priority: Importance (must/should/may)
1225
+ - status: Lifecycle state
1226
+
1227
+ CHILDREN:
1228
+ - statement: The quality objective
1229
+ - metric: Measurable criteria (CRITICAL for verifiability)
1230
+
1231
+ FOR LLMs:
1232
+ - Quality goals become NFR (non-functional) requirements
1233
+ - Always ask for metrics - vague quality goals are untestable
1234
+ - Generate performance/security/etc. tests from quality goals
1235
+ - Quality goals often conflict - identify trade-offs
1236
+
1237
+ EXAMPLES:
1238
+ - Goal: "Low latency checkout" | Metric: "p95 latency ≤ 500ms under 200 rps"
1239
+ - Goal: "High availability" | Metric: "99.9% uptime monthly"
1240
+ - Goal: "Accessible interface" | Metric: "WCAG 2.1 Level AA compliance"
1241
+ -->
1242
+ <xs:complexType name="QualityGoalType">
1243
+ <xs:sequence>
1244
+ <xs:element name="statement" type="TextBlockType"/>
1245
+ <xs:element name="metric" type="TextBlockType" minOccurs="0"/>
1246
+ </xs:sequence>
1247
+ <xs:attribute name="id" type="IdType" use="required"/>
1248
+ <xs:attribute name="title" type="xs:string" use="required"/>
1249
+ <xs:attribute name="priority" type="PriorityType" use="optional"/>
1250
+ <xs:attribute name="status" type="StatusType" use="optional"/>
1251
+ </xs:complexType>
1252
+
1253
+ <!--
1254
+ ObstacleType: Threat to goal achievement
1255
+
1256
+ Obstacles are conditions or events that could prevent goals from being met.
1257
+ They drive risk mitigation and defensive requirements.
1258
+
1259
+ ATTRIBUTES:
1260
+ - id: Unique identifier (e.g., OBS-DB, OBS-FRAUD, OBS-VENDOR)
1261
+ - title: Short descriptive name
1262
+ - likelihood: Probability of occurrence (e.g., "high", "medium", "low")
1263
+ - severity: Impact if it occurs (e.g., "critical", "high", "medium", "low")
1264
+
1265
+ CHILDREN:
1266
+ - statement: Description of the obstacle
1267
+ - mitigation: How to address it (may reference requirements)
1268
+
1269
+ FOR LLMs:
1270
+ - Create goalLink with type="threatens" to connect obstacles to goals
1271
+ - Generate requirements that mitigate high-likelihood/high-severity obstacles
1272
+ - Link mitigations to requirements via trace edges (type="mitigates")
1273
+ - Unmitigated critical obstacles should be flagged
1274
+ -->
1275
+ <xs:complexType name="ObstacleType">
1276
+ <xs:sequence>
1277
+ <xs:element name="statement" type="TextBlockType"/>
1278
+ <xs:element name="mitigation" type="TextBlockType" minOccurs="0"/>
1279
+ </xs:sequence>
1280
+ <xs:attribute name="id" type="IdType" use="required"/>
1281
+ <xs:attribute name="title" type="xs:string" use="required"/>
1282
+ <xs:attribute name="likelihood" type="xs:token" use="optional"/>
1283
+ <xs:attribute name="severity" type="xs:token" use="optional"/>
1284
+ </xs:complexType>
1285
+
1286
+ <!--
1287
+ GoalLinkType: Relationship between goals and obstacles
1288
+
1289
+ Captures how goals relate to each other and to obstacles.
1290
+ Used for goal decomposition and threat modeling.
1291
+
1292
+ ATTRIBUTES:
1293
+ - id: Unique identifier for this link
1294
+ - from: Source element ID
1295
+ - to: Target element ID
1296
+ - type: Relationship type (TraceType - typically refines, threatens, mitigates, conflictsWith)
1297
+ - confidence: Certainty of this relationship (0.0-1.0)
1298
+
1299
+ COMMON PATTERNS:
1300
+ - Sub-goal refines parent-goal (decomposition)
1301
+ - Obstacle threatens goal (threat)
1302
+ - Goal conflictsWith goal (trade-off)
1303
+ - Requirement mitigates obstacle (addressed by requirement)
1304
+ -->
1305
+ <xs:complexType name="GoalLinkType">
1306
+ <xs:attribute name="id" type="IdType" use="required"/>
1307
+ <xs:attribute name="from" type="IdType" use="required"/>
1308
+ <xs:attribute name="to" type="IdType" use="required"/>
1309
+ <xs:attribute name="type" type="TraceType" use="required"/>
1310
+ <xs:attribute name="confidence" type="ConfidenceType" use="optional"/>
1311
+ </xs:complexType>
1312
+
1313
+ <!-- =========================
1314
+ Scenarios Section
1315
+
1316
+ Narrative descriptions of system usage. Includes positive use cases,
1317
+ negative misuse cases, and boundary edge cases.
1318
+
1319
+ Aligned with Cockburn use cases and Sindre/Opdahl misuse cases.
1320
+
1321
+ FOR LLMs:
1322
+ - Use scenarios to discover requirements through "what happens when..."
1323
+ - Generate acceptance tests from scenario narratives
1324
+ - Misuse cases drive security requirements
1325
+ - Edge cases drive robustness requirements
1326
+ ========================= -->
1327
+
1328
+ <!--
1329
+ ScenariosType: Scenario collection
1330
+
1331
+ CHILDREN:
1332
+ - scenario: Normal/positive use cases
1333
+ - misuseCase: Abuse/attack scenarios
1334
+ - edgeCase: Boundary/exceptional scenarios
1335
+ -->
1336
+ <xs:complexType name="ScenariosType">
1337
+ <xs:sequence>
1338
+ <xs:element name="scenario" type="ScenarioType" minOccurs="0" maxOccurs="unbounded"/>
1339
+ <xs:element name="misuseCase" type="ScenarioType" minOccurs="0" maxOccurs="unbounded"/>
1340
+ <xs:element name="edgeCase" type="ScenarioType" minOccurs="0" maxOccurs="unbounded"/>
1341
+ </xs:sequence>
1342
+ </xs:complexType>
1343
+
1344
+ <!--
1345
+ ScenarioType: Individual scenario definition (used for scenario, misuseCase, edgeCase)
1346
+
1347
+ ATTRIBUTES:
1348
+ - id: Unique identifier (e.g., SCN-CHECKOUT, SCN-FRAUD, SCN-TIMEOUT)
1349
+ - title: Short descriptive name
1350
+ - actorRef: Reference to the actor performing this scenario
1351
+
1352
+ CHILDREN:
1353
+ - narrative: Step-by-step description of what happens
1354
+ - refs: Links to related goals, requirements, or risks
1355
+
1356
+ FOR LLMs:
1357
+
1358
+ For SCENARIOS (positive use cases):
1359
+ - Describe the happy path of user interaction
1360
+ - Include main flow and notable alternative flows
1361
+ - Derive FR (functional) requirements from scenario steps
1362
+ - Generate acceptance tests from scenarios
1363
+
1364
+ For MISUSE CASES (abuse scenarios):
1365
+ - Describe how attackers or malicious users might abuse the system
1366
+ - Derive SR (security) requirements to prevent/detect abuse
1367
+ - Link to risks in catalogs
1368
+ - Generate security tests from misuse cases
1369
+
1370
+ For EDGE CASES (boundary scenarios):
1371
+ - Describe unusual but valid conditions (empty inputs, max values, etc.)
1372
+ - Derive robustness requirements
1373
+ - Generate boundary tests from edge cases
1374
+
1375
+ EXAMPLE NARRATIVE FORMAT:
1376
+ "1. User enters email and password
1377
+ 2. System validates credentials against user store
1378
+ 3. System generates session token
1379
+ 4. System redirects to dashboard"
1380
+ -->
1381
+ <xs:complexType name="ScenarioType">
1382
+ <xs:sequence>
1383
+ <xs:element name="narrative" type="TextBlockType"/>
1384
+ <xs:element name="refs" type="RefsType" minOccurs="0"/>
1385
+ </xs:sequence>
1386
+ <xs:attribute name="id" type="IdType" use="required"/>
1387
+ <xs:attribute name="title" type="xs:string" use="required"/>
1388
+ <xs:attribute name="actorRef" type="IdType" use="optional"/>
1389
+ </xs:complexType>
1390
+
1391
+ <!-- =========================
1392
+ Requirements Section (REQUIRED)
1393
+
1394
+ The core normative content - statements of what the system MUST do.
1395
+ This is the primary driver for implementation.
1396
+
1397
+ Aligned with IEEE 29148 requirements qualities: necessary, verifiable,
1398
+ unambiguous, consistent, complete, feasible, traceable.
1399
+
1400
+ FOR LLMs:
1401
+ - This section drives code generation
1402
+ - Each requirement should map to implementable code
1403
+ - Use acceptance criteria for test generation
1404
+ - Type attribute determines implementation approach
1405
+ ========================= -->
1406
+
1407
+ <!--
1408
+ RequirementsType: Requirements container
1409
+
1410
+ CHILDREN:
1411
+ - reqPackage: Grouping container for related requirements
1412
+ - req: Individual requirement statements
1413
+
1414
+ Requirements can be organized into packages or listed directly.
1415
+ Packages help manage ownership and scope.
1416
+ -->
1417
+ <xs:complexType name="RequirementsType">
1418
+ <xs:sequence>
1419
+ <xs:element name="reqPackage" type="ReqPackageType" minOccurs="0" maxOccurs="unbounded"/>
1420
+ <xs:element name="req" type="ReqTypeItem" minOccurs="0" maxOccurs="unbounded"/>
1421
+ </xs:sequence>
1422
+ </xs:complexType>
1423
+
1424
+ <!--
1425
+ ReqPackageType: Logical grouping of requirements
1426
+
1427
+ Packages organize requirements by feature area, component, or ownership.
1428
+ Similar to Volere requirement categories or agile epics.
1429
+
1430
+ ATTRIBUTES:
1431
+ - id: Unique identifier (e.g., PKG-AUTH, PKG-PAYMENTS, PKG-REPORTING)
1432
+ - title: Package name
1433
+ - ownerRef: Reference to stakeholder responsible for this package
1434
+
1435
+ CHILDREN:
1436
+ - description: Purpose and scope of this package
1437
+ - req: Requirements within this package
1438
+
1439
+ FOR LLMs:
1440
+ - Use packages to organize by feature area or bounded context
1441
+ - Package ownership helps route implementation to the right team
1442
+ - When generating code, package names may map to modules/namespaces
1443
+ -->
1444
+ <xs:complexType name="ReqPackageType">
1445
+ <xs:sequence>
1446
+ <xs:element name="description" type="TextBlockType" minOccurs="0"/>
1447
+ <xs:element name="req" type="ReqTypeItem" minOccurs="0" maxOccurs="unbounded"/>
1448
+ </xs:sequence>
1449
+ <xs:attribute name="id" type="IdType" use="required"/>
1450
+ <xs:attribute name="title" type="xs:string" use="required"/>
1451
+ <xs:attribute name="ownerRef" type="IdType" use="optional"/>
1452
+ </xs:complexType>
1453
+
1454
+ <!--
1455
+ ReqTypeItem: Individual requirement definition
1456
+
1457
+ The fundamental unit of specification. Each requirement is a normative
1458
+ statement about what the system must do or how it must behave.
1459
+
1460
+ ATTRIBUTES:
1461
+ - id: Unique identifier (e.g., REQ-AUTH-001, REQ-PAY-002)
1462
+ - type: Requirement category (ReqType: FR/NFR/IR/DR/SR/CR/PR/UXR/OR)
1463
+ - title: Short descriptive name
1464
+ - status: Lifecycle state (draft/review/approved/deprecated)
1465
+ - priority: Importance (must/should/may)
1466
+ - ownerRef: Reference to responsible stakeholder
1467
+ - appliesTo: Token indicating scope (e.g., entity ID, component name)
1468
+
1469
+ CHILDREN:
1470
+ - statement: The normative requirement (use SHALL/SHOULD/MAY)
1471
+ - rationale: Why this requirement exists
1472
+ - notes: Implementation hints or clarifications
1473
+ - acceptance: BDD-style acceptance criteria
1474
+ - refs: Links to goals, scenarios, or other requirements
1475
+
1476
+ FOR LLMs - REQUIREMENT STATEMENT GUIDELINES:
1477
+ - Use active voice: "The system SHALL..." not "It should be possible to..."
1478
+ - Be specific: "within 200ms" not "quickly"
1479
+ - Be testable: each statement should have clear pass/fail criteria
1480
+ - One requirement per statement: avoid "and" joining unrelated behaviors
1481
+ - Use normative keywords from RFC 2119:
1482
+ * SHALL/MUST: Absolute requirement
1483
+ * SHOULD: Recommended but not mandatory
1484
+ * MAY: Optional
1485
+
1486
+ FOR LLMs - CODE GENERATION BY TYPE:
1487
+ - FR: Application logic, services, controllers, business rules
1488
+ - NFR: Architecture decisions, caching, async processing, optimization
1489
+ - IR: API handlers, protocol implementations, serialization
1490
+ - DR: Models, schemas, validators, data access code
1491
+ - SR: Auth middleware, encryption, audit logging, security filters
1492
+ - CR: Configuration, deployment scripts, dependency management
1493
+ - PR: Compliance features, audit trails, reporting
1494
+ - UXR: UI components, accessibility, internationalization
1495
+ - OR: Logging, monitoring, health checks, alerting
1496
+
1497
+ EXAMPLE STATEMENTS BY TYPE:
1498
+ - FR: "The system SHALL allow users to reset their password via email link"
1499
+ - NFR: "The API SHALL respond within 200ms for 95th percentile requests"
1500
+ - IR: "The system SHALL accept payment requests in ISO 20022 format"
1501
+ - DR: "Email addresses SHALL be validated against RFC 5322 format"
1502
+ - SR: "Failed login attempts SHALL be logged with source IP and timestamp"
1503
+ - CR: "The system SHALL be deployable on Kubernetes 1.28+"
1504
+ - PR: "User data exports SHALL be provided within 30 days per GDPR Art. 20"
1505
+ - UXR: "Form fields SHALL display inline validation errors on blur"
1506
+ - OR: "The system SHALL emit metrics to Prometheus in OpenMetrics format"
1507
+ -->
1508
+ <xs:complexType name="ReqTypeItem">
1509
+ <xs:sequence>
1510
+ <xs:element name="statement" type="TextBlockType"/>
1511
+ <xs:element name="rationale" type="TextBlockType" minOccurs="0"/>
1512
+ <xs:element name="notes" type="TextBlockType" minOccurs="0"/>
1513
+ <xs:element name="acceptance" type="AcceptanceType" minOccurs="0"/>
1514
+ <xs:element name="refs" type="RefsType" minOccurs="0"/>
1515
+ </xs:sequence>
1516
+ <xs:attribute name="id" type="IdType" use="required"/>
1517
+ <xs:attribute name="type" type="ReqType" use="required"/>
1518
+ <xs:attribute name="title" type="xs:string" use="required"/>
1519
+ <xs:attribute name="status" type="StatusType" use="optional"/>
1520
+ <xs:attribute name="priority" type="PriorityType" use="optional"/>
1521
+ <xs:attribute name="ownerRef" type="IdType" use="optional"/>
1522
+ <xs:attribute name="appliesTo" type="xs:token" use="optional"/>
1523
+ </xs:complexType>
1524
+
1525
+ <!--
1526
+ AcceptanceType: Container for acceptance criteria
1527
+
1528
+ Acceptance criteria define when a requirement is satisfied.
1529
+ Based on BDD/Gherkin given-when-then format.
1530
+ -->
1531
+ <xs:complexType name="AcceptanceType">
1532
+ <xs:sequence>
1533
+ <xs:element name="criterion" type="CriterionType" minOccurs="1" maxOccurs="unbounded"/>
1534
+ </xs:sequence>
1535
+ </xs:complexType>
1536
+
1537
+ <!--
1538
+ CriterionType: Individual acceptance criterion
1539
+
1540
+ Uses given-when-then structure from BDD (Behavior-Driven Development).
1541
+ Each criterion is a testable scenario for the requirement.
1542
+
1543
+ ATTRIBUTES:
1544
+ - id: Optional unique identifier for the criterion
1545
+
1546
+ CHILDREN:
1547
+ - given: Preconditions/context (optional - may be implicit)
1548
+ - when: Action/trigger (optional - may be implicit)
1549
+ - then: Expected outcome (required - must be verifiable)
1550
+
1551
+ FOR LLMs:
1552
+ - Generate test cases directly from acceptance criteria
1553
+ - "given" becomes test setup/fixtures
1554
+ - "when" becomes test action
1555
+ - "then" becomes test assertions
1556
+ - Multiple criteria = multiple test cases
1557
+
1558
+ EXAMPLES:
1559
+ Criterion 1:
1560
+ given: "A user with a valid session"
1561
+ when: "The user submits an order with items totaling $150"
1562
+ then: "Free shipping is applied and total reflects no shipping charge"
1563
+
1564
+ Criterion 2:
1565
+ given: "A guest user without a session"
1566
+ when: "The user attempts to access /account"
1567
+ then: "The user is redirected to /login with return URL preserved"
1568
+ -->
1569
+ <xs:complexType name="CriterionType">
1570
+ <xs:sequence>
1571
+ <xs:element name="given" type="TextBlockType" minOccurs="0"/>
1572
+ <xs:element name="when" type="TextBlockType" minOccurs="0"/>
1573
+ <xs:element name="then" type="TextBlockType" minOccurs="1"/>
1574
+ </xs:sequence>
1575
+ <xs:attribute name="id" type="IdType" use="optional"/>
1576
+ </xs:complexType>
1577
+
1578
+ <!-- =========================
1579
+ Behavior Section
1580
+
1581
+ State machines that formalize entity lifecycles derived from requirements.
1582
+ Models valid states and transitions to enable precise behavioral specs.
1583
+
1584
+ Placed after requirements because state machines refine/formalize requirement
1585
+ statements into explicit lifecycle models. Transitions reference requirements.
1586
+
1587
+ Aligned with UML state machine concepts (simplified flat model).
1588
+
1589
+ FOR LLMs:
1590
+ - Use state machines to formalize entity lifecycles (Order, Payment, User, etc.)
1591
+ - Generate state enums, transition functions, and validation logic
1592
+ - Generate state transition tests (happy path, all transitions, invalid transitions)
1593
+ - Link transitions to requirements via refs for traceability
1594
+ - Check guards to generate conditional logic
1595
+ ========================= -->
1596
+
1597
+ <!--
1598
+ BehaviorType: Container for state machines
1599
+
1600
+ CHILDREN:
1601
+ - stateMachine: Individual state machine definitions
1602
+ -->
1603
+ <xs:complexType name="BehaviorType">
1604
+ <xs:sequence>
1605
+ <xs:element name="stateMachine" type="StateMachineType" minOccurs="0" maxOccurs="unbounded"/>
1606
+ </xs:sequence>
1607
+ </xs:complexType>
1608
+
1609
+ <!--
1610
+ StateMachineType: Finite state machine definition
1611
+
1612
+ Models the valid lifecycle of an entity or process. An entity is always
1613
+ in exactly one state; transitions move it between states based on events
1614
+ and guards.
1615
+
1616
+ ATTRIBUTES:
1617
+ - id: Unique identifier (e.g., SM-ORDER, SM-PAYMENT, SM-USER-ACCOUNT)
1618
+ - name: Human-readable state machine name
1619
+ - entityRef: Optional reference to the domain entity this governs
1620
+ - initial: Required reference to the initial state ID
1621
+
1622
+ CHILDREN:
1623
+ - description: Purpose and scope of this state machine
1624
+ - state: State definitions (at least one required)
1625
+ - transition: Transition definitions between states
1626
+
1627
+ FOR LLMs:
1628
+ - Generate state enum/type from all state names
1629
+ - Generate transition validation function
1630
+ - Use entityRef to link to domain entity for the status field
1631
+ - Ensure initial state exists and is reachable
1632
+ - Verify all non-final states have at least one outgoing transition
1633
+
1634
+ EXAMPLE ID PATTERNS:
1635
+ - SM-ORDER (order lifecycle)
1636
+ - SM-PAYMENT (payment processing)
1637
+ - SM-TICKET (support ticket workflow)
1638
+ - SM-DOC-REVIEW (document approval process)
1639
+ -->
1640
+ <xs:complexType name="StateMachineType">
1641
+ <xs:sequence>
1642
+ <xs:element name="description" type="TextBlockType" minOccurs="0"/>
1643
+ <xs:element name="state" type="StateType" minOccurs="1" maxOccurs="unbounded"/>
1644
+ <xs:element name="transition" type="TransitionType" minOccurs="0" maxOccurs="unbounded"/>
1645
+ </xs:sequence>
1646
+ <xs:attribute name="id" type="IdType" use="required"/>
1647
+ <xs:attribute name="name" type="xs:string" use="required"/>
1648
+ <xs:attribute name="entityRef" type="IdType" use="optional"/>
1649
+ <xs:attribute name="initial" type="IdType" use="required"/>
1650
+ </xs:complexType>
1651
+
1652
+ <!--
1653
+ StateType: Individual state in a state machine
1654
+
1655
+ Represents a distinct condition or situation in an entity's lifecycle.
1656
+ States are mutually exclusive; an entity is in exactly one state at a time.
1657
+
1658
+ ATTRIBUTES:
1659
+ - id: Unique identifier (e.g., ST-PENDING, ST-CONFIRMED, ST-CANCELLED)
1660
+ - name: Human-readable state name (use for enum values in code generation)
1661
+ - type: State kind: initial, normal, or final (default: normal)
1662
+
1663
+ CHILDREN:
1664
+ - description: What this state represents and when an entity is in it
1665
+ - onEntry: Actions to perform when entering this state
1666
+ - onExit: Actions to perform when leaving this state
1667
+ - invariant: Conditions that must hold while in this state
1668
+
1669
+ FOR LLMs:
1670
+ - Generate enum values from state names (use PascalCase or snake_case)
1671
+ - onEntry actions become side effects in transition handlers
1672
+ - onExit actions become cleanup logic before transitions
1673
+ - invariant becomes validation logic or assertions
1674
+ - States with type="final" should have no outgoing transitions
1675
+
1676
+ EXAMPLE STATE NAMES:
1677
+ - Pending, Confirmed, Shipped, Delivered, Cancelled (order)
1678
+ - Draft, Review, Approved, Published, Archived (document)
1679
+ - Active, Suspended, Closed (account)
1680
+ -->
1681
+ <xs:complexType name="StateType">
1682
+ <xs:sequence>
1683
+ <xs:element name="description" type="TextBlockType" minOccurs="0"/>
1684
+ <xs:element name="onEntry" type="TextBlockType" minOccurs="0"/>
1685
+ <xs:element name="onExit" type="TextBlockType" minOccurs="0"/>
1686
+ <xs:element name="invariant" type="TextBlockType" minOccurs="0"/>
1687
+ </xs:sequence>
1688
+ <xs:attribute name="id" type="IdType" use="required"/>
1689
+ <xs:attribute name="name" type="xs:string" use="required"/>
1690
+ <xs:attribute name="type" type="StateKindType" use="optional" default="normal"/>
1691
+ </xs:complexType>
1692
+
1693
+ <!--
1694
+ TransitionType: State transition definition
1695
+
1696
+ Defines a valid movement from one state to another, optionally triggered
1697
+ by an event and constrained by a guard condition.
1698
+
1699
+ ATTRIBUTES:
1700
+ - id: Unique identifier (e.g., TR-CONFIRM, TR-SHIP, TR-CANCEL)
1701
+ - from: Source state ID (must exist in same state machine)
1702
+ - to: Target state ID (must exist in same state machine)
1703
+ - event: Optional event name that triggers this transition
1704
+
1705
+ CHILDREN:
1706
+ - description: Human-readable explanation of this transition
1707
+ - trigger: What causes this transition (if not captured by event attribute)
1708
+ - guard: Condition that must be true for transition to fire
1709
+ - action: What happens during the transition (side effects)
1710
+ - refs: Links to requirements this transition implements
1711
+
1712
+ FOR LLMs:
1713
+
1714
+ CODE GENERATION:
1715
+ - Generate transition table/map: { from, to, event, guard? }
1716
+ - Generate event handler functions from event names
1717
+ - Guard text becomes conditional logic (if/when)
1718
+ - Action text becomes side effect code
1719
+ - Use refs to add traceability comments in generated code
1720
+
1721
+ TEST GENERATION:
1722
+ - Generate test for each transition (valid path)
1723
+ - Generate test for transition with guard=true and guard=false
1724
+ - Generate test for invalid transitions (wrong source state)
1725
+ - Generate test for missing event (should reject)
1726
+
1727
+ PATTERNS:
1728
+ - event="confirm" -> onConfirm() handler
1729
+ - guard="payment authorized" -> if (order.paymentAuthorized)
1730
+ - action="send email" -> emailService.send(...)
1731
+
1732
+ EXAMPLE:
1733
+ <transition id="TR-SHIP" from="ST-CONFIRMED" to="ST-SHIPPED" event="ship">
1734
+ <guard>All items picked and packed</guard>
1735
+ <action>Capture payment; generate tracking number</action>
1736
+ <refs><ref ref="REQ-ORDER-SHIP"/></refs>
1737
+ </transition>
1738
+ -->
1739
+ <xs:complexType name="TransitionType">
1740
+ <xs:sequence>
1741
+ <xs:element name="description" type="TextBlockType" minOccurs="0"/>
1742
+ <xs:element name="trigger" type="TextBlockType" minOccurs="0"/>
1743
+ <xs:element name="guard" type="TextBlockType" minOccurs="0"/>
1744
+ <xs:element name="action" type="TextBlockType" minOccurs="0"/>
1745
+ <xs:element name="refs" type="RefsType" minOccurs="0"/>
1746
+ </xs:sequence>
1747
+ <xs:attribute name="id" type="IdType" use="required"/>
1748
+ <xs:attribute name="from" type="IdType" use="required"/>
1749
+ <xs:attribute name="to" type="IdType" use="required"/>
1750
+ <xs:attribute name="event" type="xs:string" use="optional"/>
1751
+ </xs:complexType>
1752
+
1753
+ <!-- =========================
1754
+ Interfaces Section
1755
+
1756
+ System boundaries and contracts with external systems.
1757
+ Describes APIs, events, and other integration points.
1758
+
1759
+ Aligned with ISO/IEC/IEEE 42010 interface specifications.
1760
+
1761
+ FOR LLMs:
1762
+ - Generate API handlers from endpoint definitions
1763
+ - Generate event handlers from event definitions
1764
+ - Generate client SDKs from API specifications
1765
+ - Generate OpenAPI/AsyncAPI specs from interface definitions
1766
+ ========================= -->
1767
+
1768
+ <!--
1769
+ InterfacesType: Interface specifications container
1770
+
1771
+ CHILDREN:
1772
+ - api: Synchronous API definitions (REST, RPC, GraphQL)
1773
+ - event: Asynchronous event definitions (messages, webhooks)
1774
+ -->
1775
+ <xs:complexType name="InterfacesType">
1776
+ <xs:sequence>
1777
+ <xs:element name="api" type="ApiType" minOccurs="0" maxOccurs="unbounded"/>
1778
+ <xs:element name="event" type="EventType" minOccurs="0" maxOccurs="unbounded"/>
1779
+ </xs:sequence>
1780
+ </xs:complexType>
1781
+
1782
+ <!--
1783
+ ApiType: API surface definition
1784
+
1785
+ ATTRIBUTES:
1786
+ - id: Unique identifier (e.g., API-PAYMENTS, API-USERS, API-ADMIN)
1787
+ - name: Human-readable API name
1788
+ - protocol: Communication protocol (e.g., "https", "grpc", "graphql", "websocket")
1789
+ - auth: Authentication method (e.g., "oauth2", "api-key", "jwt", "mtls", "none")
1790
+
1791
+ CHILDREN:
1792
+ - description: Purpose and scope of this API
1793
+ - endpoint: Individual endpoint definitions
1794
+
1795
+ FOR LLMs:
1796
+ - Use protocol to determine implementation pattern
1797
+ - Use auth to generate authentication/authorization middleware
1798
+ - API names may map to controller classes or service modules
1799
+ - Generate OpenAPI specification from api + endpoints
1800
+ -->
1801
+ <xs:complexType name="ApiType">
1802
+ <xs:sequence>
1803
+ <xs:element name="description" type="TextBlockType" minOccurs="0"/>
1804
+ <xs:element name="endpoint" type="EndpointType" minOccurs="0" maxOccurs="unbounded"/>
1805
+ </xs:sequence>
1806
+ <xs:attribute name="id" type="IdType" use="required"/>
1807
+ <xs:attribute name="name" type="xs:string" use="required"/>
1808
+ <xs:attribute name="protocol" type="xs:token" use="optional"/>
1809
+ <xs:attribute name="auth" type="xs:token" use="optional"/>
1810
+ </xs:complexType>
1811
+
1812
+ <!--
1813
+ EndpointType: Individual API endpoint
1814
+
1815
+ ATTRIBUTES:
1816
+ - id: Unique identifier (e.g., EP-CREATE-PAYMENT, EP-GET-USER)
1817
+ - method: HTTP method or operation type (e.g., "GET", "POST", "PUT", "DELETE", "PATCH")
1818
+ - path: URL path with parameters (e.g., "/payments", "/users/{id}", "/orders/{orderId}/items")
1819
+
1820
+ CHILDREN:
1821
+ - summary: Brief description of what this endpoint does
1822
+ - request: Request body/parameters specification
1823
+ - response: Success response specification
1824
+ - errors: Error responses and conditions
1825
+
1826
+ FOR LLMs:
1827
+ - Generate route handlers from method + path
1828
+ - Generate request DTOs/validators from request description
1829
+ - Generate response DTOs from response description
1830
+ - Generate error handling from errors description
1831
+ - Use domain entities as basis for request/response schemas
1832
+
1833
+ PATH PARAMETER CONVENTIONS:
1834
+ - Use {paramName} for path parameters
1835
+ - Use snake_case or camelCase consistently
1836
+ - Example: /users/{userId}/orders/{orderId}
1837
+
1838
+ COMMON PATTERNS:
1839
+ - GET /resources - List resources (paginated)
1840
+ - POST /resources - Create new resource
1841
+ - GET /resources/{id} - Get single resource
1842
+ - PUT /resources/{id} - Replace resource
1843
+ - PATCH /resources/{id} - Update resource partially
1844
+ - DELETE /resources/{id} - Remove resource
1845
+ -->
1846
+ <xs:complexType name="EndpointType">
1847
+ <xs:sequence>
1848
+ <xs:element name="summary" type="TextBlockType" minOccurs="0"/>
1849
+ <xs:element name="request" type="TextBlockType" minOccurs="0"/>
1850
+ <xs:element name="response" type="TextBlockType" minOccurs="0"/>
1851
+ <xs:element name="errors" type="TextBlockType" minOccurs="0"/>
1852
+ </xs:sequence>
1853
+ <xs:attribute name="id" type="IdType" use="required"/>
1854
+ <xs:attribute name="method" type="xs:token" use="required"/>
1855
+ <xs:attribute name="path" type="xs:string" use="required"/>
1856
+ </xs:complexType>
1857
+
1858
+ <!--
1859
+ EventType: Asynchronous event definition
1860
+
1861
+ Events represent messages exchanged asynchronously between systems
1862
+ or components (message queues, event buses, webhooks, etc.).
1863
+
1864
+ ATTRIBUTES:
1865
+ - id: Unique identifier (e.g., EVT-PAYMENT-CREATED, EVT-ORDER-SHIPPED)
1866
+ - name: Event name (use PascalCase for consistency)
1867
+
1868
+ CHILDREN:
1869
+ - description: When this event is emitted and its purpose
1870
+ - payload: Data structure carried by the event
1871
+
1872
+ FOR LLMs:
1873
+ - Generate event classes/types from event definitions
1874
+ - Generate event handlers/subscribers
1875
+ - Generate event publishers/emitters
1876
+ - Use domain entities as basis for payload schemas
1877
+ - Generate AsyncAPI specification from events
1878
+
1879
+ EVENT NAMING CONVENTIONS:
1880
+ - Use past tense for things that happened: PaymentCreated, OrderShipped
1881
+ - Use present tense for commands: ProcessPayment, ShipOrder
1882
+ - Include domain context: PaymentService.PaymentCreated vs OrderService.PaymentReceived
1883
+ -->
1884
+ <xs:complexType name="EventType">
1885
+ <xs:sequence>
1886
+ <xs:element name="description" type="TextBlockType" minOccurs="0"/>
1887
+ <xs:element name="payload" type="TextBlockType" minOccurs="0"/>
1888
+ </xs:sequence>
1889
+ <xs:attribute name="id" type="IdType" use="required"/>
1890
+ <xs:attribute name="name" type="xs:string" use="required"/>
1891
+ </xs:complexType>
1892
+
1893
+ <!-- =========================
1894
+ Verification Section
1895
+
1896
+ How requirements are tested and validated. Captures planned
1897
+ and executed verification activities.
1898
+
1899
+ Aligned with IEEE 29148 verification requirements and V-model testing.
1900
+
1901
+ FOR LLMs:
1902
+ - Generate test code from test case definitions
1903
+ - Map test cases to requirements via refs
1904
+ - Use acceptance criteria (given/when/then) for test implementation
1905
+ - Ensure each requirement has at least one verifiedBy trace
1906
+ ========================= -->
1907
+
1908
+ <!--
1909
+ VerificationType: Verification container
1910
+
1911
+ CHILDREN:
1912
+ - testSuite: Logical grouping of test cases
1913
+ - testCase: Individual verification items
1914
+ -->
1915
+ <xs:complexType name="VerificationType">
1916
+ <xs:sequence>
1917
+ <xs:element name="testSuite" type="TestSuiteType" minOccurs="0" maxOccurs="unbounded"/>
1918
+ <xs:element name="testCase" type="TestCaseType" minOccurs="0" maxOccurs="unbounded"/>
1919
+ </xs:sequence>
1920
+ </xs:complexType>
1921
+
1922
+ <!--
1923
+ TestSuiteType: Logical grouping of test cases
1924
+
1925
+ ATTRIBUTES:
1926
+ - id: Unique identifier (e.g., TS-PAYMENT, TS-AUTH, TS-PERFORMANCE)
1927
+ - title: Suite name
1928
+
1929
+ CHILDREN:
1930
+ - description: Purpose and scope of this test suite
1931
+ - members: References to test cases in this suite
1932
+
1933
+ FOR LLMs:
1934
+ - Generate test suite/describe blocks from test suites
1935
+ - Use suite organization for test execution grouping
1936
+ - Suites may map to test files or test classes
1937
+ -->
1938
+ <xs:complexType name="TestSuiteType">
1939
+ <xs:sequence>
1940
+ <xs:element name="description" type="TextBlockType" minOccurs="0"/>
1941
+ <xs:element name="members" type="RefsType" minOccurs="0"/>
1942
+ </xs:sequence>
1943
+ <xs:attribute name="id" type="IdType" use="required"/>
1944
+ <xs:attribute name="title" type="xs:string" use="required"/>
1945
+ </xs:complexType>
1946
+
1947
+ <!--
1948
+ TestCaseType: Individual verification item
1949
+
1950
+ ATTRIBUTES:
1951
+ - id: Unique identifier (e.g., TC-AUTH-001, TC-PERF-LOAD)
1952
+ - type: Test category (TestType: acceptance/integration/unit/security/performance/inspection)
1953
+ - title: Test name
1954
+
1955
+ CHILDREN:
1956
+ - purpose: What this test verifies (the "why")
1957
+ - steps: How to execute the test (the "how")
1958
+ - expected: Expected outcome (the "what")
1959
+ - refs: Links to requirements/scenarios being verified
1960
+
1961
+ FOR LLMs - TEST GENERATION BY TYPE:
1962
+
1963
+ acceptance:
1964
+ - Generate from requirement acceptance criteria
1965
+ - Use end-to-end test frameworks (Cypress, Playwright, etc.)
1966
+ - Focus on user-facing behavior
1967
+
1968
+ integration:
1969
+ - Test component interactions
1970
+ - Use API testing tools
1971
+ - Mock external dependencies appropriately
1972
+
1973
+ unit:
1974
+ - Test individual functions/methods
1975
+ - Use unit test frameworks (Jest, pytest, JUnit, etc.)
1976
+ - Focus on logic correctness
1977
+
1978
+ security:
1979
+ - Generate from SR requirements
1980
+ - Include auth bypass attempts, injection tests, etc.
1981
+ - Use security testing tools
1982
+
1983
+ performance:
1984
+ - Generate from NFR requirements with metrics
1985
+ - Use load testing tools (k6, JMeter, etc.)
1986
+ - Include baseline and stress scenarios
1987
+
1988
+ inspection:
1989
+ - Document manual review checklists
1990
+ - Include compliance verification points
1991
+ - May not generate automated code
1992
+
1993
+ TEST CASE EXAMPLE:
1994
+ purpose: "Verify password reset flow works for valid users"
1995
+ steps: "1. Request reset for valid email
1996
+ 2. Extract token from email
1997
+ 3. Submit new password with token"
1998
+ expected: "Password is updated and user can login with new password"
1999
+ -->
2000
+ <xs:complexType name="TestCaseType">
2001
+ <xs:sequence>
2002
+ <xs:element name="purpose" type="TextBlockType" minOccurs="0"/>
2003
+ <xs:element name="steps" type="TextBlockType" minOccurs="0"/>
2004
+ <xs:element name="expected" type="TextBlockType" minOccurs="0"/>
2005
+ <xs:element name="refs" type="RefsType" minOccurs="0"/>
2006
+ </xs:sequence>
2007
+ <xs:attribute name="id" type="IdType" use="required"/>
2008
+ <xs:attribute name="type" type="TestType" use="required"/>
2009
+ <xs:attribute name="title" type="xs:string" use="required"/>
2010
+ </xs:complexType>
2011
+
2012
+ <!-- =========================
2013
+ Trace Section
2014
+
2015
+ Explicit relationships between all artifacts for impact analysis
2016
+ and coverage tracking. This is the traceability matrix in graph form.
2017
+
2018
+ Aligned with IEEE 29148 traceability requirements.
2019
+
2020
+ FOR LLMs:
2021
+ - Use traces to answer "what depends on this?" before making changes
2022
+ - Use traces to verify coverage (every goal has satisfying requirements)
2023
+ - Create traces when generating code (implements relationship)
2024
+ - Maintain trace integrity when modifying documents
2025
+ ========================= -->
2026
+
2027
+ <!--
2028
+ TraceTypeContainer: Container for trace edges
2029
+
2030
+ Trace edges form a directed graph connecting all artifacts.
2031
+ Use queries on this graph for impact analysis and coverage reports.
2032
+ -->
2033
+ <xs:complexType name="TraceTypeContainer">
2034
+ <xs:sequence>
2035
+ <xs:element name="traceEdge" type="TraceEdgeType" minOccurs="0" maxOccurs="unbounded"/>
2036
+ </xs:sequence>
2037
+ </xs:complexType>
2038
+
2039
+ <!--
2040
+ TraceEdgeType: Individual traceability link
2041
+
2042
+ Supports both internal references (to elements within the RQML document) and
2043
+ external references (to systems like Jira, Git, files, regulations, etc.).
2044
+ At least one endpoint should be internal for the trace to be useful within RQML.
2045
+
2046
+ ATTRIBUTES:
2047
+ - id: Unique identifier for this edge
2048
+ - from: Source element ID within this document (keyref-validated)
2049
+ - to: Target element ID within this document (keyref-validated)
2050
+ - fromUri: Source as external URI (for tracing from external systems)
2051
+ - toUri: Target as external URI (for tracing to external systems)
2052
+ - type: Relationship type (TraceType)
2053
+ - confidence: Certainty of this relationship (0.0-1.0)
2054
+ - status: Lifecycle state (draft/review/approved/deprecated)
2055
+ - createdBy: Who created this trace (person, role, or tool)
2056
+ - createdAt: When this trace was created (ISO 8601 dateTime)
2057
+ - tags: Space-separated category tags for filtering (e.g., "safety security")
2058
+
2059
+ ENDPOINT RULES:
2060
+ - Use from/to for internal RQML elements (validated by schema)
2061
+ - Use fromUri/toUri for external systems (not validated)
2062
+ - At least one of from or fromUri should be specified
2063
+ - At least one of to or toUri should be specified
2064
+ - Can combine internal and external (e.g., from + toUri)
2065
+
2066
+ CHILDREN:
2067
+ - notes: Explanation of why this relationship exists
2068
+
2069
+ EXTERNAL URI CONVENTIONS:
2070
+ - Jira: jira:PROJ-1234
2071
+ - GitHub: github:owner/repo/issues/42 or github:owner/repo/pull/99
2072
+ - Git commit: git:a1b2c3d4e5f6
2073
+ - File: file:src/auth/login.ts#L42-L87
2074
+ - Confluence: confluence:12345678
2075
+ - Regulation: urn:gdpr:article:17 or urn:iso27001:A.12.3
2076
+ - Full URL: https://jira.example.com/browse/PROJ-1234
2077
+
2078
+ FOR LLMs - COMMON TRACE PATTERNS:
2079
+
2080
+ Internal traces (within RQML):
2081
+ - requirement satisfies goal: from="REQ-001" to="GOAL-001" type="satisfies"
2082
+ - qgoal refines goal: from="QGOAL-001" to="GOAL-001" type="refines"
2083
+ - obstacle threatens goal: from="OBS-001" to="GOAL-001" type="threatens"
2084
+ - requirement mitigates risk: from="REQ-001" to="RISK-001" type="mitigates"
2085
+ - testCase verifies requirement: from="TC-001" to="REQ-001" type="verifiedBy"
2086
+ - requirement dependsOn requirement: from="REQ-002" to="REQ-001" type="dependsOn"
2087
+ - goal conflictsWith goal: from="GOAL-001" to="GOAL-002" type="conflictsWith"
2088
+
2089
+ External traces (to/from external systems):
2090
+ - requirement implements Jira story: from="REQ-001" toUri="jira:PROJ-1234" type="implements"
2091
+ - code implements requirement: fromUri="file:src/auth.ts#L42" to="REQ-001" type="implements"
2092
+ - git commit implements requirement: fromUri="git:a1b2c3d" to="REQ-001" type="implements"
2093
+ - requirement satisfies regulation: from="REQ-GDPR-001" toUri="urn:gdpr:article:17" type="satisfies"
2094
+ - external spec refines goal: fromUri="confluence:12345" to="GOAL-001" type="refines"
2095
+
2096
+ IMPACT ANALYSIS:
2097
+ To find what's affected by changing element X:
2098
+ 1. Find all edges where from=X or to=X (internal) or fromUri/toUri match (external)
2099
+ 2. Recursively follow edges to find transitive impacts
2100
+ 3. Higher confidence edges indicate stronger impacts
2101
+
2102
+ COVERAGE ANALYSIS:
2103
+ To verify all goals are addressed:
2104
+ 1. For each goal, find edges where to=goal_id and type=satisfies
2105
+ 2. Goals without satisfies edges are uncovered
2106
+ 3. Flag uncovered goals for stakeholder attention
2107
+
2108
+ LIFECYCLE MANAGEMENT:
2109
+ - status=draft: Auto-generated or tentative traces awaiting verification
2110
+ - status=review: Traces under stakeholder review
2111
+ - status=approved: Confirmed traces that can be relied upon
2112
+ - status=deprecated: Traces no longer valid but kept for audit history
2113
+ - Use createdBy to track accountability (person, role, or tool like "import-jira")
2114
+ - Use createdAt for audit trails and staleness detection
2115
+ - Filter by status=approved for reliable impact analysis
2116
+
2117
+ CATEGORIZATION:
2118
+ Use tags to categorize traces for filtering and reporting:
2119
+ - safety: Functional safety traces (IEC 61508, ISO 26262)
2120
+ - security: Security-related traces (ISO 27001, OWASP)
2121
+ - compliance: Regulatory compliance traces (GDPR, HIPAA, SOX)
2122
+ - performance: Performance requirement traces
2123
+ - accessibility: Accessibility requirement traces (WCAG)
2124
+ - Custom tags as needed for project-specific concerns
2125
+ Example: tags="safety compliance" for a trace relevant to both domains
2126
+ -->
2127
+ <xs:complexType name="TraceEdgeType">
2128
+ <xs:sequence>
2129
+ <xs:element name="notes" type="TextBlockType" minOccurs="0"/>
2130
+ </xs:sequence>
2131
+ <xs:attribute name="id" type="IdType" use="required"/>
2132
+ <!-- Internal references (keyref-validated when present) -->
2133
+ <xs:attribute name="from" type="IdType"/>
2134
+ <xs:attribute name="to" type="IdType"/>
2135
+ <!-- External references (URI-based, for tracing to external systems) -->
2136
+ <xs:attribute name="fromUri" type="xs:anyURI"/>
2137
+ <xs:attribute name="toUri" type="xs:anyURI"/>
2138
+ <xs:attribute name="type" type="TraceType" use="required"/>
2139
+ <xs:attribute name="confidence" type="ConfidenceType"/>
2140
+ <!-- Lifecycle metadata -->
2141
+ <xs:attribute name="status" type="StatusType"/>
2142
+ <xs:attribute name="createdBy" type="xs:string"/>
2143
+ <xs:attribute name="createdAt" type="xs:dateTime"/>
2144
+ <!-- Categorization -->
2145
+ <xs:attribute name="tags" type="xs:NMTOKENS"/>
2146
+ </xs:complexType>
2147
+
2148
+ <!-- =========================
2149
+ Governance Section
2150
+
2151
+ Change control, accountability, and approval workflows.
2152
+ Tracks issues to resolve and sign-offs obtained.
2153
+
2154
+ Aligned with ISO/IEC/IEEE 12207 configuration management.
2155
+
2156
+ FOR LLMs:
2157
+ - Check governance/issues for open questions before implementing
2158
+ - Approved documents are ready for implementation
2159
+ - Issues may block requirements or indicate uncertainty
2160
+ - Update governance when making document changes
2161
+ ========================= -->
2162
+
2163
+ <!--
2164
+ GovernanceType: Governance container
2165
+
2166
+ CHILDREN:
2167
+ - issue: Open questions, concerns, or deviations
2168
+ - approval: Sign-offs and authorizations
2169
+ -->
2170
+ <xs:complexType name="GovernanceType">
2171
+ <xs:sequence>
2172
+ <xs:element name="issue" type="IssueType" minOccurs="0" maxOccurs="unbounded"/>
2173
+ <xs:element name="approval" type="ApprovalType" minOccurs="0" maxOccurs="unbounded"/>
2174
+ </xs:sequence>
2175
+ </xs:complexType>
2176
+
2177
+ <!--
2178
+ IssueType: Open question or concern
2179
+
2180
+ Issues track things that need resolution: missing information,
2181
+ conflicting requirements, deferred decisions, or risks.
2182
+
2183
+ ATTRIBUTES:
2184
+ - id: Unique identifier (e.g., ISS-PCI, ISS-SCOPE, ISS-RESOURCE)
2185
+ - status: Issue lifecycle (draft/review/approved/deprecated - where approved means resolved)
2186
+ - owner: Person or role responsible for resolution
2187
+
2188
+ CHILDREN:
2189
+ - statement: What needs to be addressed
2190
+ - notes: Progress, context, or resolution details
2191
+
2192
+ FOR LLMs:
2193
+ - Check issues before implementing - they may indicate blocking concerns
2194
+ - Issues with status="review" need stakeholder input
2195
+ - Resolved issues (status="approved") contain decisions to follow
2196
+ - Create issues when encountering ambiguity during elicitation
2197
+ -->
2198
+ <xs:complexType name="IssueType">
2199
+ <xs:sequence>
2200
+ <xs:element name="statement" type="TextBlockType"/>
2201
+ <xs:element name="notes" type="TextBlockType" minOccurs="0"/>
2202
+ </xs:sequence>
2203
+ <xs:attribute name="id" type="IdType" use="required"/>
2204
+ <xs:attribute name="status" type="StatusType" use="optional"/>
2205
+ <xs:attribute name="owner" type="xs:string" use="optional"/>
2206
+ </xs:complexType>
2207
+
2208
+ <!--
2209
+ ApprovalType: Sign-off record
2210
+
2211
+ Approvals track who has reviewed and accepted the specification.
2212
+ Required for regulated environments and formal release processes.
2213
+
2214
+ ATTRIBUTES:
2215
+ - id: Unique identifier (e.g., APR-SEC, APR-LEGAL, APR-PRODUCT)
2216
+ - role: The role required to approve (not a specific person)
2217
+ - status: Approval state (draft=pending, approved=obtained, deprecated=revoked)
2218
+
2219
+ CHILDREN:
2220
+ - description: Scope of this approval (what is being approved)
2221
+
2222
+ FOR LLMs:
2223
+ - Documents need approvals before implementation in regulated contexts
2224
+ - Check approval status before treating requirements as final
2225
+ - Different roles approve different aspects (security, legal, product, etc.)
2226
+ -->
2227
+ <xs:complexType name="ApprovalType">
2228
+ <xs:sequence>
2229
+ <xs:element name="description" type="TextBlockType" minOccurs="0"/>
2230
+ </xs:sequence>
2231
+ <xs:attribute name="id" type="IdType" use="required"/>
2232
+ <xs:attribute name="role" type="xs:string" use="required"/>
2233
+ <xs:attribute name="status" type="StatusType" use="optional"/>
2234
+ </xs:complexType>
2235
+
2236
+ </xs:schema>