Private beta, by invitation. It may change without warning. While the beta lasts, some paid features are free. See pricing

trumlyspec GitHub
Try trumly

Conformance cases /

rule-require-link

Tests how a rule is read and applied: severity, scope, options and switching rules off.

Our implementation passes this case when its check --json output for the input below equals the expected output.

Input

nodes/a.md
---
id: a
type: svc
plane: p1
links:
  - type: runs_on
    to: e
---
nodes/b.md
---
id: b
type: svc
plane: p1
---
nodes/c.md
---
id: c
type: svc
plane: p1
links:
  - type: runs_on
    to: other
---
nodes/d.md
---
id: d
type: svc
plane: p1
links:
  - type: runs_on
    to: nowhere
---
nodes/e.md
---
id: e
type: env
plane: p2
---
nodes/other.md
---
id: other
type: svc
plane: p2
---
nodes/p1.md
---
id: p1
type: plane
fields:
  order: 1
---
nodes/p2.md
---
id: p2
type: plane
fields:
  order: 2
---
nodes/r.md
---
id: r
type: rule
fields:
  statement: s
  applies_to: {type: svc}
  check: {require_link: {type: runs_on, to_type: env, to_plane: p2}}
---

Expected output

4 ghosts · 0 load errors · 9 nodes · 5 results

expected.json
{
 "ghosts": [
  {
   "link": "runs_on",
   "node": "b",
   "plane": "p2",
   "rule": "r",
   "to_type": "env"
  },
  {
   "link": "runs_on",
   "node": "c",
   "plane": "p2",
   "rule": "r",
   "to_type": "env"
  },
  {
   "link": "runs_on",
   "node": "d",
   "plane": "p2",
   "rule": "r",
   "to_type": "env"
  },
  {
   "link": "runs_on",
   "node": "other",
   "plane": "p2",
   "rule": "r",
   "to_type": "env"
  }
 ],
 "load_errors": [],
 "nodes": [
  {
   "body": "",
   "fields": {},
   "id": "a",
   "links": [
    {
     "to": "e",
     "type": "runs_on"
    }
   ],
   "parent": null,
   "plane": "p1",
   "title": "a",
   "type": "svc"
  },
  {
   "body": "",
   "fields": {},
   "id": "b",
   "links": [],
   "parent": null,
   "plane": "p1",
   "title": "b",
   "type": "svc"
  },
  {
   "body": "",
   "fields": {},
   "id": "c",
   "links": [
    {
     "to": "other",
     "type": "runs_on"
    }
   ],
   "parent": null,
   "plane": "p1",
   "title": "c",
   "type": "svc"
  },
  {
   "body": "",
   "fields": {},
   "id": "d",
   "links": [
    {
     "to": "nowhere",
     "type": "runs_on"
    }
   ],
   "parent": null,
   "plane": "p1",
   "title": "d",
   "type": "svc"
  },
  {
   "body": "",
   "fields": {},
   "id": "e",
   "links": [],
   "parent": null,
   "plane": "p2",
   "title": "e",
   "type": "env"
  },
  {
   "body": "",
   "fields": {},
   "id": "other",
   "links": [],
   "parent": null,
   "plane": "p2",
   "title": "other",
   "type": "svc"
  },
  {
   "body": "",
   "fields": {
    "order": 1
   },
   "id": "p1",
   "links": [],
   "parent": null,
   "plane": null,
   "title": "p1",
   "type": "plane"
  },
  {
   "body": "",
   "fields": {
    "order": 2
   },
   "id": "p2",
   "links": [],
   "parent": null,
   "plane": null,
   "title": "p2",
   "type": "plane"
  },
  {
   "body": "",
   "fields": {
    "applies_to": {
     "type": "svc"
    },
    "check": {
     "require_link": {
      "to_plane": "p2",
      "to_type": "env",
      "type": "runs_on"
     }
    },
    "statement": "s"
   },
   "id": "r",
   "links": [],
   "parent": null,
   "plane": null,
   "title": "r",
   "type": "rule"
  }
 ],
 "results": [
  {
   "node": "a",
   "rule": "r",
   "severity": "warn",
   "status": "pass"
  },
  {
   "node": "b",
   "rule": "r",
   "severity": "warn",
   "status": "fail"
  },
  {
   "node": "c",
   "rule": "r",
   "severity": "warn",
   "status": "fail"
  },
  {
   "node": "d",
   "rule": "r",
   "severity": "warn",
   "status": "fail"
  },
  {
   "node": "other",
   "rule": "r",
   "severity": "warn",
   "status": "fail"
  }
 ],
 "structure": {
  "errors": [
   {
    "kind": "missing_link_target",
    "node": "d",
    "ref": "runs_on->nowhere"
   }
  ],
  "warnings": []
 }
}