Elements
graph TD;
%% REQVIRE-AUTOGENERATED-DIAGRAM
%% Graph styling
classDef userRequirement fill:#D1C4E9,stroke:#7E57C2,stroke-width:2px;
classDef systemRequirement fill:#E1D8EE,stroke:#673AB7,stroke-width:1.5px;
classDef verification fill:#DCEDC8,stroke:#4CAF50,stroke-width:2px;
classDef folder fill:#FAFAFA,stroke:#9E9E9E,stroke-width:3px;
classDef file fill:#FFF8E1,stroke:#FFCA28,stroke-width:2px;
classDef default fill:#F5F5F5,stroke:#424242,stroke-width:1.5px;
subgraph 75874bcc96c01d2f["📁 requirements/Functional/Operations/Verifications"]
subgraph 264302f069db5bdb["📄 ElementManipulationVerifications.md"]
9ce04315a8dd0d88["Add Command Duplicate Detection Test"];
class 9ce04315a8dd0d88 verification;
click 9ce04315a8dd0d88 "ElementManipulationVerifications.html#add-command-duplicate-detection-test";
f7d422af274a64cf["Add Command Error Messages Test"];
class f7d422af274a64cf verification;
click f7d422af274a64cf "ElementManipulationVerifications.html#add-command-error-messages-test";
868e15205b620ba2["CLI Add Element Test
📎 requirements/Functional/Operations/Behaviors.md#element-ordering-behavior"];
class 868e15205b620ba2 verification;
click 868e15205b620ba2 "ElementManipulationVerifications.html#cli-add-element-test";
d4a6f578d691e888["CLI Move Element Test
📎 requirements/Functional/Operations/Behaviors.md#element-ordering-behavior"];
class d4a6f578d691e888 verification;
click d4a6f578d691e888 "ElementManipulationVerifications.html#cli-move-element-test";
7d317f5d862a0785["CLI Move File Test"];
class 7d317f5d862a0785 verification;
click 7d317f5d862a0785 "ElementManipulationVerifications.html#cli-move-file-test";
c5f295328df58029["CLI Remove Element Test"];
class c5f295328df58029 verification;
click c5f295328df58029 "ElementManipulationVerifications.html#cli-remove-element-test";
7701c4bcfa966fe6["CLI Rename Element Test"];
class 7701c4bcfa966fe6 verification;
click 7701c4bcfa966fe6 "ElementManipulationVerifications.html#cli-rename-element-test";
221f6c008823a4d0["Create Element Override Test
📎 requirements/Functional/Operations/Behaviors.md#create-element-override-behavior"];
class 221f6c008823a4d0 verification;
click 221f6c008823a4d0 "ElementManipulationVerifications.html#create-element-override-test";
d5bf7d0addaf6d19["Create Element Test"];
class d5bf7d0addaf6d19 verification;
click d5bf7d0addaf6d19 "ElementManipulationVerifications.html#create-element-test";
bfd28e1e74918526["Delete Element Test"];
class bfd28e1e74918526 verification;
click bfd28e1e74918526 "ElementManipulationVerifications.html#delete-element-test";
362774efb36e2279["File Persistence Test
📎 requirements/Functional/Operations/Behaviors.md#element-ordering-behavior"];
class 362774efb36e2279 verification;
click 362774efb36e2279 "ElementManipulationVerifications.html#file-persistence-test";
410dbe84dc2c3481["Link Command Cross-Section Detection Test"];
class 410dbe84dc2c3481 verification;
click 410dbe84dc2c3481 "ElementManipulationVerifications.html#link-command-cross-section-detection-test";
ea3a2bf2fbe74057["Link Command Verification"];
class ea3a2bf2fbe74057 verification;
click ea3a2bf2fbe74057 "ElementManipulationVerifications.html#link-command-verification";
c7b35d6963f1017["Merge Elements Test"];
class c7b35d6963f1017 verification;
click c7b35d6963f1017 "ElementManipulationVerifications.html#merge-elements-test";
9ae2cd53e62b6a33["Move Element Test"];
class 9ae2cd53e62b6a33 verification;
click 9ae2cd53e62b6a33 "ElementManipulationVerifications.html#move-element-test";
af599fec38b8c0bf["Move File Squash Test"];
class af599fec38b8c0bf verification;
click af599fec38b8c0bf "ElementManipulationVerifications.html#move-file-squash-test";
81422a9a6525acd7["Relation Consistency Test"];
class 81422a9a6525acd7 verification;
click 81422a9a6525acd7 "ElementManipulationVerifications.html#relation-consistency-test";
c0a8cdea5e5972df["Target Location Validation Test"];
class c0a8cdea5e5972df verification;
click c0a8cdea5e5972df "ElementManipulationVerifications.html#target-location-validation-test";
9f8ff23aca853fa0["Unlink Command Verification"];
class 9f8ff23aca853fa0 verification;
click 9f8ff23aca853fa0 "ElementManipulationVerifications.html#unlink-command-verification";
end
end
4179509ffe0be04b["test.sh"];
class 4179509ffe0be04b default;
click 4179509ffe0be04b "../../../../tests/test-duplicate-detection/test.sh";
9ce04315a8dd0d88 -->|satisfiedBy| 4179509ffe0be04b;
fe0a74a2cd2af425["test.sh"];
class fe0a74a2cd2af425 default;
click fe0a74a2cd2af425 "../../../../tests/test-add-command-error-messages/test.sh";
f7d422af274a64cf -->|satisfiedBy| fe0a74a2cd2af425;
7f91546dcec3d680["test.sh"];
class 7f91546dcec3d680 default;
click 7f91546dcec3d680 "../../../../tests/test-crud-manipulation/test.sh";
868e15205b620ba2 -->|satisfiedBy| 7f91546dcec3d680;
d4a6f578d691e888 -->|satisfiedBy| 7f91546dcec3d680;
7d317f5d862a0785 -->|satisfiedBy| 7f91546dcec3d680;
661275cf7a337c0e["test.sh"];
class 661275cf7a337c0e default;
click 661275cf7a337c0e "../../../../tests/test-subdirectory-functionality/test.sh";
7d317f5d862a0785 -->|satisfiedBy| 661275cf7a337c0e;
c5f295328df58029 -->|satisfiedBy| 7f91546dcec3d680;
7701c4bcfa966fe6 -->|satisfiedBy| 7f91546dcec3d680;
d5bf7d0addaf6d19 -->|satisfiedBy| 7f91546dcec3d680;
bfd28e1e74918526 -->|satisfiedBy| 7f91546dcec3d680;
3ca44151e0210bb1["test.sh"];
class 3ca44151e0210bb1 default;
click 3ca44151e0210bb1 "../../../../tests/test-crud-file-persistence/test.sh";
362774efb36e2279 -->|satisfiedBy| 3ca44151e0210bb1;
410dbe84dc2c3481 -->|satisfiedBy| 4179509ffe0be04b;
e2ae1addbaec6335["test.sh"];
class e2ae1addbaec6335 default;
click e2ae1addbaec6335 "../../../../tests/test-link-unlink/test.sh";
ea3a2bf2fbe74057 -->|satisfiedBy| e2ae1addbaec6335;
99e20055749fc61e["test.sh"];
class 99e20055749fc61e default;
click 99e20055749fc61e "../../../../tests/test-crud-empty-file-cleanup/test.sh";
9ae2cd53e62b6a33 -->|satisfiedBy| 99e20055749fc61e;
9ae2cd53e62b6a33 -->|satisfiedBy| 7f91546dcec3d680;
6d7253e029455f50["test.sh"];
class 6d7253e029455f50 default;
click 6d7253e029455f50 "../../../../tests/test-crud-mv-file-squash/test.sh";
af599fec38b8c0bf -->|satisfiedBy| 6d7253e029455f50;
87a76fd329b99a81["test.sh"];
class 87a76fd329b99a81 default;
click 87a76fd329b99a81 "../../../../tests/test-crud-relation-consistency/test.sh";
81422a9a6525acd7 -->|satisfiedBy| 87a76fd329b99a81;
cf7b1e3aeef95d4["test.sh"];
class cf7b1e3aeef95d4 default;
click cf7b1e3aeef95d4 "../../../../tests/test-crud-target-location-validation/test.sh";
c0a8cdea5e5972df -->|satisfiedBy| cf7b1e3aeef95d4;
9f8ff23aca853fa0 -->|satisfiedBy| e2ae1addbaec6335;
Add Command Duplicate Detection Test
Test verifies that the add command rejects elements with duplicate entries.
Details
Test cases:
- Duplicate relations: Add element with same relation twice -> Error
- Duplicate attachments: Add element with same attachment twice -> Error
- Cross-section duplicate: Add element with same target in Relations and Attachments -> Error
Metadata
Relations
Add Command Error Messages Test
Test verifies that the add command provides contextual error messages with examples when format parsing fails.
Details
Test Cases:
-
Missing ### header: Provide markdown without element header
- Verify error message includes “Example of correctly formatted element”
- Verify example shows “### Element Name”
-
Multiple ### headers: Provide markdown with multiple element headers
- Verify error message includes example
- Verify example includes Metadata subsection
-
Invalid metadata format: Provide metadata without bullet point
- Verify error message includes “Expected format: ’ * key: value’”
- Verify example shows correct metadata format
-
Invalid relation format: Provide relation without proper markdown link
- Verify error message includes “Expected format: ’ * relationType: Text’”
- Verify example includes Relations subsection
-
Invalid attachment format: Provide attachment without proper markdown link
- Verify error message includes “Expected format: ’ * Text’”
- Verify example includes Attachments subsection
-
Example completeness: Verify example includes all subsections
- Details subsection with markdown formatting
- Metadata subsection with type
- Relations subsection with derivedFrom and satisfiedBy examples
- Attachments subsection
- Separator (—)
Success Criteria:
- Command exits with non-zero code for all invalid inputs
- Error messages include “Example of correctly formatted element”
- Examples show proper structure for all subsections
- Format guidance is specific to the error type
Metadata
Relations
CLI Add Element Test
The test shall verify that the add command creates new elements from stdin or inline string input, validates structure, inserts following Element Ordering Behavior, and outputs git-style diffs.
Details
Test Setup:
- Prepare test model with existing files and sections
- Prepare valid element markdown strings
- Prepare invalid element markdown strings
- Set up test environment with stdin/tty detection
Test Steps - Stdin Input:
- Pipe element markdown to
reqvire add <file>
- Verify element is read from stdin
- Verify element is validated and inserted
- Verify git-style diff is output showing changes
- Verify file is modified on disk
Test Steps - Inline String:
- Run
reqvire add <file> "### Element..."
- Verify element is read from inline argument
- Verify element is validated and inserted
- Verify git-style diff is output
Test Steps - Element Ordering:
- Add child element to file with existing parent
- Verify element is inserted following Element Ordering Behavior (parent before child)
- Add parent element to file with existing children
- Verify file is reordered with parent before children
Test Steps - Dry Run:
- Run
reqvire add --dry-run <file> < element.md
- Verify git-style diff is shown
- Verify no changes are applied to files
Test Steps - JSON Output:
- Run
reqvire add --json <file> < element.md
- Verify JSON output with element details
- Verify changes are applied
Test Steps - Validation Errors:
- Provide invalid element (duplicate name, malformed)
- Verify error is reported
- Verify file is not modified
- Verify exit code is non-zero
Success Criteria:
- Reads from stdin when piped
- Reads from inline argument when provided
- Validates before insertion
- Inserts following Element Ordering Behavior
- Shows git-style diff by default
- Supports –dry-run preview
- Supports –json output
- Reports validation errors
- Returns correct exit codes
Metadata
Attachments
Relations
CLI Move Element Test
The test shall verify that the mv command relocates elements, updates all relations, inserts following Element Ordering Behavior, and outputs git-style diffs.
Details
Test Setup:
- Create test model with multiple files and sections
- Create elements with incoming and outgoing relations
- Document expected relation updates
- Prepare target locations
Test Steps - Basic Move:
- Run
reqvire mv <element-name> <target-file>
- Verify element is removed from source
- Verify element is inserted into target following Element Ordering Behavior
- Verify all incoming relations are updated
- Verify git-style diff shows all affected files
- Verify identifier change is reported
Test Steps - Element Ordering:
- Move child element to file with existing parent
- Verify element is inserted after parent (following hierarchy)
- Move parent element to file with existing children
- Verify file is reordered with parent before children
Test Steps - Dry Run:
- Run
reqvire mv --dry-run <element-name> <file>
- Verify git-style diff is shown for all affected files
- Verify no changes are applied
- Verify relation updates are previewed
Test Steps - JSON Output:
- Run
reqvire mv --json <element-name> <file>
- Verify JSON output with relation updates
- Verify old → new identifier mapping
- Verify changes are applied
Test Steps - Error Cases:
- Try to move non-existent element by name
- Try to move to invalid location
- Try to move with duplicate name at target
- Verify errors are reported
- Verify exit code is non-zero
Success Criteria:
- Moves element to target location
- Updates all incoming relations
- Preserves element content and outgoing relations
- Inserts following Element Ordering Behavior
- Shows git-style diff for all affected files
- Reports identifier change
- Supports –dry-run preview
- Supports –json output with relation mapping
- Reports validation and location errors
- Returns correct exit codes
Metadata
Attachments
Relations
CLI Move File Test
The test shall verify that the mv-file command moves entire specification files with all their elements to a new location, updates all relations referencing elements in the moved file, and outputs git-style diffs.
Details
Test Setup:
- Create test model with multiple specification files
- Create files with multiple elements
- Create elements in other files with relations pointing to elements in the file to be moved
- Document expected relation updates
- Prepare target file paths
Test Steps - Basic Move File:
- Run
reqvire mv-file <source-file> <target-file>
- Verify source file is removed from filesystem
- Verify target file is created with all elements from source
- Verify all elements are preserved with identical content, metadata, and relations
- Verify all incoming relations (from other files) are updated to reference the new file location
- Verify element identifiers are updated to reflect new file path
- Verify git-style diff shows source file deletion and target file creation
- Verify git-style diff shows all affected files with relation updates
Test Steps - Subdirectory Execution:
- Navigate to a subdirectory of the git repository
- Run
reqvire mv-file specifications/File.md specifications/NewFile.md
- Verify paths are resolved relative to current working directory
- Verify target file is created at
<cwd>/specifications/NewFile.md
- Verify source file at
<cwd>/specifications/File.md is removed
- Verify all relations are updated correctly
Test Steps - Dry Run:
- Run
reqvire mv-file --dry-run <source-file> <target-file>
- Verify git-style diff is shown for all affected files
- Verify no changes are applied to filesystem
- Verify relation updates are previewed
- Verify file move is previewed (deletion + creation)
Test Steps - JSON Output:
- Run
reqvire mv-file --json <source-file> <target-file>
- Verify JSON output with list of moved elements
- Verify old → new identifier mappings for all elements
- Verify list of affected files with relation updates
- Verify changes are applied
Test Steps - Error Cases:
- Try to move non-existent source file
- Try to move to a target file that already exists
- Try to move file outside subdirectory scope when running from subdirectory
- Verify errors are reported clearly
- Verify exit code is non-zero
- Verify no changes are applied on error
Success Criteria:
- Source file is deleted from filesystem
- Target file is created with all elements
- All element content, metadata, and outgoing relations are preserved
- All incoming relations are updated to new file location
- Element identifiers are updated (file path component changes)
- Shows git-style diff for source deletion, target creation, and all affected files
- Paths are resolved relative to current working directory
- Supports –dry-run preview
- Supports –json output with element mappings
- Reports errors for non-existent files and existing targets
- Returns correct exit codes
- Works correctly when executed from subdirectories
Test Coverage:
- Move file with single element
- Move file with multiple elements
- Move file with elements that have incoming relations from other files
- Move file with elements that have outgoing relations to other files
- Move file with bidirectional relations (verify/verifiedBy, derive/derivedFrom)
- Execute from git repository root
- Execute from subdirectory (relative path resolution)
- Dry run mode
- JSON output mode
- Error: non-existent source file
- Error: target file already exists
Metadata
Relations
CLI Remove Element Test
The test shall verify that the rm command deletes elements, removes relations, and outputs git-style diffs showing all affected files.
Details
Test Setup:
- Create test model with multiple elements
- Create elements with incoming relations (derivedFrom, verifiedBy, etc.)
- Document expected relation removals
Test Steps - Basic Deletion:
- Run
reqvire rm <element-name>
- Verify element is deleted from file
- Verify all incoming relations are removed
- Verify git-style diff shows all affected files
- Verify changes are applied
Test Steps - Dry Run:
- Run
reqvire rm --dry-run <element-name>
- Verify git-style diff is shown
- Verify no changes are applied to files
- Verify affected files are listed
Test Steps - JSON Output:
- Run
reqvire rm --json <element-name>
- Verify JSON output with removed relations
- Verify changes are applied
Test Steps - Error Cases:
- Try to remove non-existent element by name
- Verify error is reported
- Verify exit code is non-zero
Success Criteria:
- Deletes element from file
- Removes all incoming relations
- Shows git-style diff for all affected files
- Supports –dry-run preview
- Supports –json output with relation details
- Reports errors for non-existent elements
- Returns correct exit codes
Metadata
Relations
CLI Rename Element Test
The test shall verify that the rename command renames elements, updates all relations, and outputs git-style diffs.
Details
Test Setup:
- Create test model with elements
- Create elements with incoming and outgoing relations
- Document expected relation updates
Test Steps - Basic Rename:
- Run
reqvire rename <current-name> <new-name>
- Verify element heading is updated in markdown file
- Verify all incoming relations are updated with new identifier
- Verify git-style diff shows all affected files
- Verify identifier change is reported (old → new)
Test Steps - Dry Run:
- Run
reqvire rename --dry-run <current-name> <new-name>
- Verify git-style diff is shown
- Verify no changes are applied
- Verify relation updates are previewed
Test Steps - JSON Output:
- Run
reqvire rename --json <current-name> <new-name>
- Verify JSON output with relation updates
- Verify old → new identifier mapping
- Verify changes are applied
Test Steps - Error Cases:
- Try to rename non-existent element
- Try to rename to an existing element name
- Verify errors are reported
- Verify exit code is non-zero
Success Criteria:
- Updates element heading text
- Updates all incoming relations
- Preserves element content and outgoing relations
- Shows git-style diff for all affected files
- Reports identifier change
- Supports –dry-run preview
- Supports –json output
- Reports validation errors
- Returns correct exit codes
Metadata
Relations
Create Element Override Test
Test verifies that create element with override mode correctly replaces existing elements:
- Create initial element “Test Element” in target file
- Run create element with override for “Test Element” with new content
- Verify old element content is replaced with new content
- Verify operation reports as “Update”
- Verify element relations are preserved from new content only
Metadata
Attachments
Relations
Create Element Test
The test shall verify that new model elements can be created from a full Markdown definition string after validation, and that invalid element definitions are rejected with appropriate error reporting.
Details
Test Setup:
- Prepare a test model with existing files
- Prepare valid element definition strings in Markdown format (with ### header, metadata, relations, content)
- Prepare invalid element definition strings (malformed structure, duplicate names, invalid relations)
- Identify target file path
Test Steps:
- Attempt to create an element with a valid definition string
- Verify the element was parsed correctly from the string
- Verify the element structure was validated (subsections, relations, format)
- Verify the element name was checked for global uniqueness
- Verify the element was inserted into the correct file
- Verify the element has proper Markdown structure in the file
- Validate the model after element creation
Test Steps for Invalid Cases:
- Attempt to create an element with an invalid definition string
- Verify the validation detects the structural errors
- Verify the operation is rejected before insertion
- Verify appropriate validation error messages are reported
- Verify the target file remains unchanged
Test Steps for Relation Validation:
- Create element with valid relations (targets exist in model)
- Verify relations are normalized to git-root-relative format
- Verify element is created successfully
- Attempt to create element with non-existent relation target
- Verify operation is rejected with clear error message
- Verify error message indicates which relation target was not found
- Verify target file remains unchanged after rejection
Test Steps - Override with Orphaned Children Prevention:
- Create a parent element with child elements having parent hierarchical relations
- Attempt to override the parent element with
--override flag
- Verify the operation is rejected with clear error message
- Verify the error lists all children that would be orphaned
- Verify the error provides resolution guidance
- Create a parent element with children having multiple parent hierarchical relations
- Override the parent element with
--override flag
- Verify the operation succeeds (children have other parents)
- Override an element with no children
- Verify the operation succeeds
Test Coverage:
- Valid element with all subsections (metadata, relations, details)
- Valid element with minimal structure (only ### header and content)
- Invalid element with duplicate name (violates global uniqueness)
- Invalid element with malformed subsections
- Invalid element with invalid relations
- Invalid element with missing ### header
- Valid element with relations to existing elements
- Invalid element with relation to non-existent element
- Relations specified as relative paths (../File.md#element)
- Relations specified as repo-relative paths (specifications/File.md#element)
- Relations specified as same-file references (#element)
- External link relations (http://, https://) are allowed
- Element ordering after creation (parent before children)
Success Criteria:
- Valid element definitions are accepted and created
- Element is parsed from the Markdown string correctly
- Element structure validation runs before insertion
- Global uniqueness is enforced
- Element inserted following Element Ordering Behavior
- Invalid element definitions are rejected
- Validation errors are reported clearly
- Failed operations do not modify target files
- Model validation passes after successful creation
- Relation targets are validated to exist in the model
- Non-existent relation targets cause rejection
- Relation paths are normalized to git-root-relative format
- External links (http://, https://) bypass validation
- Override of parent elements with orphaned children is rejected
- Error message clearly lists orphaned children with resolution guidance
- Override succeeds when children have other parent relations
Metadata
Relations
Delete Element Test
The test shall verify that existing model elements can be deleted, all relations referencing the deleted element are automatically removed, and empty files are removed when no elements remain.
Details
Test Setup:
- Create a test model with multiple elements
- Create an element to be deleted with incoming and outgoing relations
- Document all relations pointing to the element (derivedFrom, verifiedBy, verify, satisfiedBy)
- Create a file with only one element for empty file cleanup testing
Test Steps:
- Delete the target element
- Verify the element was completely removed from the file
- Verify all relations pointing to the deleted element were removed from other elements
- Verify the file structure and formatting remain intact
- Validate the model after element deletion
- Check that no dangling relations exist
Test Steps - Empty File Cleanup:
- Delete the only element in a file
- Verify the element is removed
- Verify the file is deleted from the filesystem
- Verify the file deletion is reported in the operation output
- Delete an element leaving other elements in the file
- Verify the file is NOT deleted (still contains elements)
Test Steps - Orphaned Children Prevention:
- Create a parent element with child elements having parent hierarchical relations
- Attempt to delete the parent element
- Verify the operation is rejected with clear error message
- Verify the error lists all children that would be orphaned
- Verify the error provides resolution guidance
- Create a child element with multiple parent hierarchical relations
- Delete one parent element
- Verify the operation succeeds (child has other parents)
- Delete the last remaining parent
- Verify the operation is rejected (child would be orphaned)
Success Criteria:
- Element is completely removed from the source file
- All incoming relations (relations from other elements to the deleted element) are removed
- File structure remains valid
- Model validation passes
- No dangling relations remain in the model
- Files containing only the deleted element are removed
- Files with remaining elements are preserved
- File deletion is reported when it occurs
- Deletion of parent elements with orphaned children is rejected
- Error message clearly lists orphaned children with resolution guidance
- Deletion succeeds when children have other parent relations
Test Coverage:
- Delete element with
derivedFrom relations pointing to it
- Delete element with
verifiedBy relations pointing to it
- Delete element with
verify relations pointing to it
- Delete element with
satisfiedBy relations pointing to it
- Delete element with multiple types of incoming relations
- Delete last element in file (triggers file deletion)
- Delete element leaving other elements (file preserved)
- Delete parent element with children (single parent - rejected)
- Delete parent element with children having multiple parents (allowed)
- Error message validation for orphaned children prevention
Metadata
Relations
File Persistence Test
The test shall verify that element manipulation operations are persisted to source files in storage, that only modified files are flushed, and that elements are reordered following the Element Ordering Behavior.
Details
Test Setup:
- Create a test model with multiple files and elements
- Record initial file timestamps and content
- Prepare element manipulation operations that affect specific files
- Create files with unordered elements (children before parents)
Test Steps:
- Perform element manipulation operation (create/delete/move)
- Verify that modified files are written to disk
- Verify that file content on disk matches the in-memory model state
- Verify that only files affected by the operation were rewritten
- Verify that unmodified files remain unchanged (check timestamps)
- Read files from disk and parse to confirm changes persisted
- Test file I/O error handling (simulate write failures)
Test Steps - Element Ordering:
- Add element that is a child of an existing element
- Verify that after persistence, parent appears before child
- Add element that is a parent of existing elements
- Verify that after persistence, new parent appears before its children
- Move element into a file with existing hierarchy
- Verify elements are reordered according to Element Ordering Behavior
Success Criteria:
- All changes are persisted to disk after manipulation completes
- File content on disk matches in-memory model state exactly
- Only modified files are written (optimization verified)
- Unmodified files have unchanged timestamps
- File format and structure are maintained
- Errors are handled gracefully with appropriate reporting
- Elements are ordered with parents before children (file-local derivedFrom)
- Siblings at same level are sorted alphabetically
- Hierarchy groups are kept together
Metadata
Attachments
Relations
Link Command Cross-Section Detection Test
Test verifies that link commands detect cross-section conflicts.
Details
Test cases:
- Element has attachment to B ->
link A relation B -> Error (already in Attachments)
- Element has relation to B ->
link A attaching B -> Error (already in Relations)
Metadata
Relations
Link Command Verification
The test shall verify that the link command adds relations to elements following the Relation Operations Specification.
Details
Test Setup:
- Create test model with multiple elements of different types
- Prepare source elements (by name and by file path)
- Prepare target elements
- Document valid and invalid relation type combinations
Test Steps - Basic Link:
- Run
reqvire link <source-element-name> <relation-type> <target-element-name>
- Verify relation entry is added to source element’s Relations subsection (written to file)
- Verify relation format:
* <relation-type>: [target-name](target-path)
- Verify target element’s file does NOT contain opposite relation (opposite exists in-memory only)
- Verify model validates after link (confirms in-memory model is complete)
Test Steps - Source Resolution:
- Link using element name as source
- Verify element is found by name in registry
- Link using internal file path as source
- Verify file is found first, then element resolved
- Link with source that matches both file and element name
- Verify file path takes priority over element name
Test Steps - Relations Subsection Creation:
- Link to element without existing Relations subsection
- Verify Relations subsection is created
- Verify relation entry is added
Test Steps - Duplicate Detection:
- Link same relation twice
- Verify second link fails with error
- Verify error message mentions ‘already exists’
- Verify file is unchanged after failed operation
Test Steps - Dry Run:
- Run
reqvire link --dry-run <source> <relation-type> <target>
- Verify diff is shown
- Verify no changes are applied
Test Steps - Validation:
- Link with invalid relation type
- Verify error is reported
- Link with incompatible element types
- Verify warning is reported
- Link to non-existent target
- Verify error is reported
- Link from non-existent source
- Verify error is reported
Test Steps - External URL Handling:
- Link with relation type (e.g., trace) to external URL
- Verify relation is added with URL as target
- Attempt to attach external URL using ‘attaching’ keyword
- Verify operation fails with clear error message
- Verify error message mentions “external URL” and suggests using ‘trace’ relation
Success Criteria:
- Adds relation to source element’s Relations subsection (written to file)
- Does NOT add opposite relation to target element’s file (opposite exists in-memory only)
- In-memory model is complete with bidirectional relations (verified by successful validation)
- Creates Relations subsection if missing
- Source resolves by file path first, then element name
- Target must be existing element name
- Duplicate relations/attachments return error with ‘already exists’ message
- Validates relation type against supported types
- Validates element type compatibility
- Supports –dry-run preview
- Reports errors for invalid inputs
- External URLs allowed for relations (trace, satisfiedBy, etc.)
- External URLs rejected for ‘attaching’ with helpful error message
Metadata
Relations
Merge Elements Test
Test verifies that the merge command correctly combines elements.
Details
Test cases:
- Basic merge: Merge two requirements, verify content consolidation
- Multi-element merge: Merge 3+ elements into target
- Cross-file merge: Merge elements from different files
- Relation merging: Verify relations are merged and deduplicated
- Attachment merging: Verify attachments are merged and deduplicated
- Type compatibility: Verify error when merging incompatible types
- Cross-section duplicate: Verify error when merged result has cross-section duplicate
- Relation redirection: Verify relations pointing to source are updated to target
- Source deletion: Verify source elements are removed after merge
- Dry-run mode: Verify no changes when –dry-run is used
Metadata
Relations
Move Element Test
The test shall verify that existing model elements can be moved to different locations, all relations referencing the moved element are automatically updated, target locations are created if needed, and empty source files are removed when no elements remain.
Details
Test Setup:
- Create a test model with multiple files
- Create an element to be moved with incoming and outgoing relations
- Document all relations pointing to the element
- Create a file with only one element for empty file cleanup testing
- Prepare non-existent target locations for auto-creation testing
Test Steps:
- Move the element to the target location
- Verify the element was removed from the source location
- Verify the element was inserted into the target location
- Verify all element content, metadata, and outgoing relations are preserved
- Verify the element identifier was updated to reflect the new location
- Verify all incoming relations were updated to reference the new identifier
- Validate the model after element move
- Check that no dangling relations exist
Test Steps - Auto-Creation:
- Move element to non-existent target file
- Verify target file is created with proper structure
Test Steps - Empty Source File Cleanup:
- Move the only element from a file to another location
- Verify the element is moved successfully
- Verify the source file is deleted from the filesystem
- Verify the file deletion is reported in the operation output
- Move an element leaving other elements in the source file
- Verify the source file is NOT deleted (still contains elements)
Success Criteria:
- Element is removed from source location
- Element is inserted into target location
- Element content and metadata are preserved
- Element identifier is updated correctly
- All incoming relations (derivedFrom, verifiedBy, verify, satisfiedBy) are updated to the new identifier
- Outgoing relations (relations from the moved element to other elements) are preserved unchanged
- File structure remains valid in both source and target files
- Model validation passes
- Non-existent target files are created with proper structure
- Empty source files are deleted after move
- Source files with remaining elements are preserved
- File creation and deletion are reported
Test Coverage:
- Move element to a different file
- Move element with
derivedFrom relations pointing to it
- Move element with
verifiedBy relations pointing to it
- Move element with
verify relations pointing to it
- Move element with
satisfiedBy relations pointing to it
- Move element with multiple types of incoming relations
- Move to non-existent target file (auto-create)
- Move last element from file (triggers source file deletion)
- Move element leaving other elements (source file preserved)
- Verify element ordering after move (parent before children)
Metadata
Relations
Move File Squash Test
The test shall verify that the mv-file --squash command moves all elements from a source file to an existing target file’s first section, updates all relations, and removes the source file.
Details
Test Setup:
- Create a source file with multiple elements
- Create a target file that already exists with its own elements and sections
- Create elements in other files with relations pointing to elements in the source file
- Document expected relation updates and element placement
Test Steps - Squash to Existing File:
- Run
reqvire mv-file --squash <source-file> <existing-target-file>
- Verify source file is removed from filesystem
- Verify all elements from source file are added to target file’s first section
- Verify elements from source file are appended to the first level-2 section (##) in target file
- Verify original target file elements remain unchanged
- Verify element ordering from source file is preserved when inserted
- Verify all element identifiers are updated to reflect new file path
- Verify all incoming relations (from other files) are updated to reference the new file location
- Verify git-style diff shows source file deletion and target file modification
- Verify git-style diff shows all affected files with relation updates
Test Steps - Error Without Squash Flag:
- Run
reqvire mv-file <source-file> <existing-target-file> (without –squash)
- Verify operation fails with clear error message
- Verify error message indicates target file already exists
- Verify no changes are applied to any files
- Verify exit code is non-zero
Test Steps - Squash with Dry Run:
- Run
reqvire mv-file --squash --dry-run <source-file> <existing-target-file>
- Verify git-style diff is shown for all affected files
- Verify no changes are applied to filesystem
- Verify preview shows elements being added to target file’s first section
Test Steps - Squash with JSON Output:
- Run
reqvire mv-file --squash --json <source-file> <existing-target-file>
- Verify JSON output with list of moved elements
- Verify old → new identifier mappings for all elements
- Verify list of affected files with relation updates
- Verify changes are applied
Success Criteria:
- Source file is deleted from filesystem
- All elements from source are added to target file’s first section
- Target file’s existing elements remain unchanged
- Element ordering from source file is preserved
- All incoming relations are updated to new file location
- Element identifiers are updated (file path component changes)
- Shows git-style diff for source deletion, target modification, and all affected files
- Supports –dry-run preview
- Supports –json output with element mappings
- Returns correct exit codes
- Without –squash flag, existing target file causes error
Test Coverage:
- Squash file with single element to existing target
- Squash file with multiple elements to existing target
- Squash file with elements that have incoming relations from other files
- Squash file with elements that have outgoing relations to other files
- Verify elements are placed in target file’s first section
- Verify target file’s existing content is preserved
- Dry run mode with –squash
- JSON output mode with –squash
- Error: target file exists without –squash flag
Metadata
Relations
Relation Consistency Test
The test shall verify that bidirectional relation consistency is maintained when elements are manipulated.
Details
Test Criteria
Test Setup:
- Create a test model with elements having bidirectional relations
- Set up test cases for derivedFrom/derive, verifiedBy/verify relations
Test Steps:
- Create an element with relations and verify bidirectional consistency
- Delete an element and verify both forward and backward relations are removed
- Move an element and verify both forward and backward relations are updated
- Validate model consistency after each manipulation operation
Success Criteria:
- After element creation: bidirectional relations are properly established
- After element deletion: both forward and backward relations are removed
- After element move: both forward and backward relations are updated
- Model validation passes after each operation
- No dangling or inconsistent relations exist
Test Coverage:
- Verify derivedFrom/derive relation consistency
- Verify verifiedBy/verify relation consistency
- Test consistency after create operations
- Test consistency after delete operations
- Test consistency after move operations
Metadata
Relations
Target Location Validation Test
The test shall verify that target file path validation and auto-creation work correctly, enforcing safety constraints for gitignore, reqvireignore, and path depth limits.
Details
Test Setup:
- Create
.gitignore with exclusion patterns (e.g., **/build/**, temp-*.md)
- Create
.reqvireignore with exclusion patterns (e.g., **/draft-*.md)
- Prepare valid target paths within depth limits
- Prepare invalid target paths (ignored paths, excessive depth)
Test Steps - Path Validation:
- Attempt to create element in path excluded by
.gitignore
- Verify operation is rejected with appropriate error message
- Attempt to create element in path excluded by
.reqvireignore
- Verify operation is rejected with appropriate error message
- Attempt to create element in path nested more than 10 subdirectories deep
- Verify operation is rejected with depth limit error
- Attempt to create element in valid path
- Verify operation succeeds
Test Steps - Auto-Creation:
- Create element in non-existent file with valid path
- Verify file is created with proper structure (
# Elements header)
- Verify existing file content is preserved when adding elements
Success Criteria:
- Paths excluded by
.gitignore are rejected
- Paths excluded by
.reqvireignore are rejected
- Paths exceeding 10 subdirectory depth are rejected
- Error messages clearly indicate which constraint was violated
- Valid paths are accepted
- Non-existent files are created with proper structure
- Created files follow Reqvire markdown conventions
Test Coverage:
- Gitignore pattern exclusion
- Reqvireignore pattern exclusion
- Path depth limit (exactly 10, 11, 15 subdirectories)
- Auto-create file
- Valid path variations
Metadata
Relations
Unlink Command Verification
The test shall verify that the unlink command removes relations from elements following the Relation Operations Specification.
Details
Test Setup:
- Create test model with elements having various relations
- Prepare source elements with relations to remove
- Document expected state after unlink
Test Steps - Unlink Scenario 1 (Default - Only Source in File):
- Link creates relation on source (written to file), opposite on target (in-memory only)
- Run
reqvire unlink <source-element-name> <target-element-name>
- Verify relation removed from source element’s Relations subsection (from file)
- Verify target element’s file unchanged (opposite was never written to file)
- Verify model validates after unlink
Test Steps - Unlink Scenario 2 (Both Relations in File):
- Run
reqvire format --with-full-relations --fix to write opposites to files
- Verify both source and target have relations in their files
- Run
reqvire unlink <source-element-name> <target-element-name>
- Verify relation removed from source element’s file
- Verify opposite relation also removed from target element’s file
- Verify model validates after unlink
Test Steps - Unlink Scenario 3 (Unlinking from Opposite Side):
- Setup: Only target has user-created relation in file, source has auto-generated opposite in-memory
- Run
reqvire unlink <source-element-name> <target-element-name> (unlink from side with only in-memory opposite)
- Verify target element’s user-created relation is removed from file
- Verify source element’s in-memory opposite is removed
- Verify model validates after unlink
Test Steps - Source Resolution:
- Unlink using element name as source
- Verify element is found by name in registry
- Unlink using internal file path as source
- Verify file is found first, then element resolved
Test Steps - Relations Subsection Cleanup:
- Unlink last relation from element
- Verify Relations subsection is removed
- Unlink from element with multiple relations
- Verify only specified relation is removed, others preserved
Test Steps - Dry Run:
- Run
reqvire unlink --dry-run <source> <relation-type> <target>
- Verify diff is shown
- Verify no changes are applied
Test Steps - Error Cases:
- Unlink non-existent relation
- Verify error is reported
- Unlink from non-existent source
- Verify error is reported
- Unlink to non-existent target
- Verify error is reported
Success Criteria:
- Scenario 1: When only source has relation in file, removes from source file, target file unchanged
- Scenario 2: When both have relations in file (after format –with-full-relations), removes from both files
- Scenario 3: When unlinking from opposite side (only in-memory), removes user-created relation from target file
- All scenarios: In-memory model updated correctly with both relations removed
- Removes Relations subsection when empty
- Source resolves by file path first, then element name
- Target must be existing element name
- Supports –dry-run preview
- Reports errors for non-existent relations
- Reports errors for invalid source/target
Metadata
Relations