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