link_test_to_spec
Record a test-to-spec link in the coverage matrix index, with automatic timestamp updates on re-link to maintain accurate traceability.
Instructions
Record that a test verifies a spec. Writes into SPEC_PROJECT_ROOT/.mk-spec-master/index.json (data ownership stays with the user). Re-linking the same node_id updates the timestamp instead of duplicating. Call this right after mk-qa-master.generate_test returns a node_id so the coverage matrix stays current. Pass spec_title / spec_source / spec_url (typically already known from earlier fetch_spec) to cache them into the index so get_coverage_matrix can render titles without re-fetching from the source. Pass ac_hash (from parse_spec._meta.ac_hash) to enable drift detection via get_drift_report. Returns {action: 'added'|'updated', spec_id, test_node_id, total_links_for_spec}.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| spec_id | Yes | ||
| test_node_id | Yes | Test framework node id, e.g. tests/test_checkout.py::test_apply_discount | |
| spec_title | No | ||
| spec_source | No | ||
| spec_url | No | ||
| ac_hash | No | SHA-256 of the canonical AC block, as returned by parse_spec._meta.ac_hash. Enables drift detection. |