qfai 2.1.2 → 2.2.1

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.
Files changed (162) hide show
  1. package/README.md +46 -6
  2. package/assets/defaults/agent-routing/qfai-implement.yml +9 -0
  3. package/assets/defaults/agent-routing/qfai-triage.yml +9 -0
  4. package/assets/defaults/workflows/answer-in-session.yml +8 -0
  5. package/assets/defaults/workflows/bump-dependency.yml +4 -1
  6. package/assets/defaults/workflows/decide-design.yml +5 -1
  7. package/assets/defaults/workflows/quarantine-flaky.yml +3 -0
  8. package/assets/defaults/workflows/rename-concept.yml +30 -0
  9. package/assets/defaults/workflows/repair-consistency.yml +1 -0
  10. package/assets/defaults/workflows/resolve-conflicts.yml +14 -0
  11. package/assets/defaults/workflows/retire-feature.yml +26 -0
  12. package/assets/defaults/workflows/run-operation.yml +11 -0
  13. package/assets/defaults/workflows/run-release.yml +12 -0
  14. package/assets/defaults/workflows/write-procedure.yml +18 -0
  15. package/assets/graph/codegraph-native.mjs +174 -0
  16. package/assets/graph/graphify-native.py +72 -0
  17. package/assets/init/.claude/settings.json +11 -29
  18. package/assets/init/.codex/hooks.json +9 -21
  19. package/assets/init/.qfai/assistant/agent/backend-engineer.md +1 -1
  20. package/assets/init/.qfai/assistant/agent/frontend-engineer.md +1 -1
  21. package/assets/init/.qfai/assistant/agent/implementation-reviewer.md +5 -0
  22. package/assets/init/.qfai/assistant/agent/product-surface-reviewer.md +8 -3
  23. package/assets/init/.qfai/assistant/rule/constitution.md +36 -18
  24. package/assets/init/.qfai/assistant/rule/drift-protocol.md +80 -1
  25. package/assets/init/.qfai/assistant/rule/references/codex-delegation.md +27 -0
  26. package/assets/init/.qfai/assistant/rule/references/gate-failure-autorepair.md +1 -1
  27. package/assets/init/.qfai/assistant/rule/references/griller-recommendations.md +21 -9
  28. package/assets/init/.qfai/assistant/rule/review-convergence.md +34 -15
  29. package/assets/init/.qfai/assistant/rule/shared-skill-delegation-baseline.md +12 -2
  30. package/assets/init/.qfai/assistant/rule/shared-skill-operating-baseline.md +14 -7
  31. package/assets/init/.qfai/assistant/rule/ui-definition-protocol.md +2 -1
  32. package/assets/init/.qfai/assistant/rule/workflow.md +2 -1
  33. package/assets/init/.qfai/assistant/skill/qfai-discussion/SKILL.md +11 -2
  34. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/discussion-completion-matrix.md +32 -10
  35. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui-bearing-playbook.md +17 -0
  36. package/assets/init/.qfai/assistant/skill/qfai-discussion/references/ui_ux/trend_scan_playbook.md +3 -1
  37. package/assets/init/.qfai/assistant/skill/qfai-discussion/templates/01_Context.md +4 -1
  38. package/assets/init/.qfai/assistant/skill/qfai-discussion/templates/04_Sources.md +5 -1
  39. package/assets/init/.qfai/assistant/skill/qfai-discussion/templates/uiux/00_index.md +4 -1
  40. package/assets/init/.qfai/assistant/skill/qfai-grilling/SKILL.md +30 -20
  41. package/assets/init/.qfai/assistant/skill/qfai-grilling/references/delegated-session.md +4 -3
  42. package/assets/init/.qfai/assistant/skill/qfai-grilling/references/session-record.md +8 -2
  43. package/assets/init/.qfai/assistant/skill/qfai-implement/SKILL.md +9 -2
  44. package/assets/init/.qfai/assistant/skill/qfai-implement/references/parallelization-policy.md +10 -0
  45. package/assets/init/.qfai/assistant/skill/qfai-implement/references/red-admissibility.md +35 -0
  46. package/assets/init/.qfai/assistant/skill/qfai-implement/references/test-runner-recipes.md +445 -0
  47. package/assets/init/.qfai/assistant/skill/qfai-implement/references/ui-affecting.md +3 -3
  48. package/assets/init/.qfai/assistant/skill/qfai-prototyping/SKILL.md +10 -9
  49. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/generator-prompt.md +33 -2
  50. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/handoff.md +77 -2
  51. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/iteration-loop.md +12 -3
  52. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/review-payload-schema.md +3 -1
  53. package/assets/init/.qfai/assistant/skill/qfai-prototyping/references/reviewer-prompt.md +31 -5
  54. package/assets/init/.qfai/assistant/skill/qfai-run/SKILL.md +48 -46
  55. package/assets/init/.qfai/assistant/skill/qfai-run/references/codex-cloud-install.md +80 -0
  56. package/assets/init/.qfai/assistant/skill/qfai-run/references/extraction.md +202 -126
  57. package/assets/init/.qfai/assistant/skill/qfai-run/references/operator-screens.md +38 -15
  58. package/assets/init/.qfai/assistant/skill/qfai-run/references/plan.md +48 -22
  59. package/assets/init/.qfai/assistant/skill/qfai-run/references/reached-step-observations.md +134 -0
  60. package/assets/init/.qfai/assistant/skill/qfai-run/references/stage-points.md +7 -4
  61. package/assets/init/.qfai/assistant/skill/qfai-run/scripts/codex-cloud-install.mjs +117 -0
  62. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/concrete-abstract-cycle.md +2 -1
  63. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/contract-artifact-rules.md +1 -1
  64. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/design-md-authoring.md +20 -7
  65. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-execution-playbook.md +2 -2
  66. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-phase-checklists.md +2 -2
  67. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-pre-draft-grilling.md +5 -1
  68. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-quality-gate.md +2 -2
  69. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/sdd-triage.md +111 -7
  70. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/spec-traceability-rules.md +1 -1
  71. package/assets/init/.qfai/assistant/skill/qfai-sdd/references/ui-contract-guide.md +58 -8
  72. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/change-request.md +1 -1
  73. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/decisions/page-NNNN.md +6 -0
  74. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/decisions.md +18 -0
  75. package/assets/init/.qfai/assistant/skill/qfai-sdd/templates/spec/open-questions.md +13 -0
  76. package/assets/init/.qfai/assistant/skill/qfai-triage/SKILL.md +10 -7
  77. package/assets/init/.qfai/assistant/skill/qfai-verify/references/verify-output-contract.md +22 -16
  78. package/assets/init/.qfai/assistant/skill/web-research/SKILL.md +1 -1
  79. package/assets/init/.qfai/assistant/step/common-design-md/STEP.md +33 -16
  80. package/assets/init/.qfai/assistant/step/common-gate-run/STEP.md +37 -8
  81. package/assets/init/.qfai/assistant/step/common-grilling-record/STEP.md +25 -4
  82. package/assets/init/.qfai/assistant/step/common-policy-check/STEP.md +1 -0
  83. package/assets/init/.qfai/assistant/step/common-review-cycle/STEP.md +68 -15
  84. package/assets/init/.qfai/assistant/step/discussion-interview/STEP.md +25 -10
  85. package/assets/init/.qfai/assistant/step/discussion-oq/STEP.md +17 -1
  86. package/assets/init/.qfai/assistant/step/discussion-pack/STEP.md +23 -3
  87. package/assets/init/.qfai/assistant/step/discussion-uiux/STEP.md +9 -1
  88. package/assets/init/.qfai/assistant/step/implement-acceptance/STEP.md +3 -0
  89. package/assets/init/.qfai/assistant/step/implement-credentials/STEP.md +4 -0
  90. package/assets/init/.qfai/assistant/step/implement-dep-bump/STEP.md +33 -3
  91. package/assets/init/.qfai/assistant/step/implement-diagnose/STEP.md +12 -3
  92. package/assets/init/.qfai/assistant/step/implement-procedure/STEP.md +98 -0
  93. package/assets/init/.qfai/assistant/step/implement-quarantine/STEP.md +21 -4
  94. package/assets/init/.qfai/assistant/step/implement-refactor/STEP.md +25 -5
  95. package/assets/init/.qfai/assistant/step/implement-regression-fix/STEP.md +3 -3
  96. package/assets/init/.qfai/assistant/step/implement-retire/STEP.md +26 -0
  97. package/assets/init/.qfai/assistant/step/implement-scaffold/STEP.md +28 -5
  98. package/assets/init/.qfai/assistant/step/implement-stress-harness/STEP.md +33 -2
  99. package/assets/init/.qfai/assistant/step/implement-tdd/STEP.md +20 -5
  100. package/assets/init/.qfai/assistant/step/maintain-edit/STEP.md +70 -6
  101. package/assets/init/.qfai/assistant/step/prototyping-grill/STEP.md +39 -6
  102. package/assets/init/.qfai/assistant/step/prototyping-handoff/STEP.md +12 -3
  103. package/assets/init/.qfai/assistant/step/prototyping-loop/STEP.md +56 -6
  104. package/assets/init/.qfai/assistant/step/prototyping-preflight/STEP.md +13 -0
  105. package/assets/init/.qfai/assistant/step/sdd-contract/STEP.md +8 -0
  106. package/assets/init/.qfai/assistant/step/sdd-cycle/STEP.md +9 -4
  107. package/assets/init/.qfai/assistant/step/sdd-story/STEP.md +22 -1
  108. package/assets/init/.qfai/assistant/step/sdd-triage/STEP.md +52 -14
  109. package/assets/init/.qfai/assistant/step/triage-answer/STEP.md +2 -2
  110. package/assets/init/.qfai/assistant/step/triage-close/STEP.md +7 -2
  111. package/assets/init/.qfai/assistant/step/triage-handoff/STEP.md +6 -0
  112. package/assets/init/.qfai/assistant/step/triage-operate/STEP.md +123 -0
  113. package/assets/init/.qfai/assistant/step/verify-commit/STEP.md +35 -10
  114. package/assets/init/.qfai/assistant/step/verify-qfai-gate/STEP.md +8 -1
  115. package/assets/init/.qfai/assistant/step/verify-repeat-run/STEP.md +40 -0
  116. package/assets/init/.qfai/assistant/step/verify-repo-gate/STEP.md +77 -7
  117. package/assets/init/root/.agents/rules/api-budget.md +8 -3
  118. package/assets/init/root/.agents/rules/document-schema.md +17 -0
  119. package/assets/init/root/.agents/rules/documentation-clarity.md +1 -1
  120. package/assets/init/root/.agents/rules/graph-exploration.md +164 -0
  121. package/assets/init/root/.agents/rules/grilling.md +100 -43
  122. package/assets/init/root/.agents/rules/reminders.json +20 -32
  123. package/assets/init/root/.agents/rules/session-feedback.md +6 -11
  124. package/assets/init/root/.agents/rules/untrusted-content.md +2 -2
  125. package/assets/init/root/.agents/rules/user-questions.md +24 -14
  126. package/assets/init/root/.gitattributes +2 -0
  127. package/assets/init/root/.github/workflows/qfai-docs.yml +2 -2
  128. package/assets/init/root/.github/workflows/qfai-tests.yml +88 -35
  129. package/assets/init/root/.github/workflows/qfai-validate.yml +2 -2
  130. package/assets/init/root/AGENTS.md +1 -0
  131. package/assets/mdschema/manifest.yml +3 -0
  132. package/assets/mdschema/story/03_contract/tech.mdschema.yml +1 -1
  133. package/assets/mdschema/story/decisions/page-NNNN.mdschema.yml +32 -0
  134. package/assets/mdschema/story/decisions.mdschema.yml +12 -0
  135. package/assets/schemas/workflow/extraction.schema.json +98 -2
  136. package/assets/schemas/workflow/plan.schema.json +34 -1
  137. package/assets/scripts/check-mdschema.mjs +497 -39
  138. package/dist/cli/index.cjs +7667 -3515
  139. package/dist/cli/index.cjs.map +1 -1
  140. package/dist/cli/index.mjs +8872 -4702
  141. package/dist/cli/index.mjs.map +1 -1
  142. package/dist/graph/cli.cjs +1568 -0
  143. package/dist/graph/cli.cjs.map +1 -0
  144. package/dist/graph/cli.d.cts +9 -0
  145. package/dist/graph/cli.d.ts +9 -0
  146. package/dist/graph/cli.mjs +1541 -0
  147. package/dist/graph/cli.mjs.map +1 -0
  148. package/dist/graph/hook.cjs +817 -0
  149. package/dist/graph/hook.cjs.map +1 -0
  150. package/dist/graph/hook.d.cts +9 -0
  151. package/dist/graph/hook.d.ts +9 -0
  152. package/dist/graph/hook.mjs +792 -0
  153. package/dist/graph/hook.mjs.map +1 -0
  154. package/dist/index.cjs +6436 -3012
  155. package/dist/index.cjs.map +1 -1
  156. package/dist/index.d.cts +185 -1
  157. package/dist/index.d.ts +185 -1
  158. package/dist/index.mjs +6620 -3197
  159. package/dist/index.mjs.map +1 -1
  160. package/dist/process-C21nTvkT.d.cts +12 -0
  161. package/dist/process-C21nTvkT.d.ts +12 -0
  162. package/package.json +1 -1
package/README.md CHANGED
@@ -59,6 +59,11 @@ pnpm approve-builds # pnpm: adds it to `onlyBuiltDependencies`
59
59
  `npx qfai doctor` runs `mdschema --help` and reports an error, naming these
60
60
  fixes, when the binary does not start.
61
61
 
62
+ QFAI pins this dependency to an exact version. A release that moves the pin
63
+ says so in its [release notes](#keeping-qfai-itself-up-to-date), so a project
64
+ that approves the script for each version can approve the new one before it
65
+ upgrades.
66
+
62
67
  ## Quick start
63
68
 
64
69
  > **Windows users:** `qfai init` creates symlinks internally.
@@ -106,10 +111,12 @@ The `qfai-run` skill reads it into facts: what it asks for, its risks, and how s
106
111
  and returns the route's plan, writing nothing. The session runs each step of the plan in order and
107
112
  asks you only the decisions that are yours and each release. You type no stage name.
108
113
 
109
- `npx qfai init` adds a hook that repeats this on every prompt: a request that names no skill goes
110
- to `qfai-run`. Claude Code reads it from `.claude/settings.json` and Codex from `.codex/hooks.json`.
111
- A question that one command or one file read answers is answered directly, with no plan. Any other
112
- question about the project that changes no file plans a route that answers it and changes nothing.
114
+ `npx qfai init` adds a hook that states this on a session's first prompt and repeats it in one line
115
+ on every later prompt: a request that names no skill goes to `qfai-run`. Claude Code reads it from `.claude/settings.json` and Codex from `.codex/hooks.json`.
116
+ `qfai-run` plans every such request, the lightest included: a question that one command or one
117
+ file read answers gets a plan too, and a question about the project plans an answer without
118
+ changes. A message that is not a request, such as an automated notice, gets no plan; a notice that
119
+ delivers a result a step was waiting for resumes that step.
113
120
  An existing `.codex/hooks.json` gains the hooks the way `.claude/settings.json` does.
114
121
  Codex runs a project's hooks only after you review and trust them with `/hooks`.
115
122
 
@@ -578,6 +585,26 @@ cp node_modules/qfai/assets/init/root/.github/workflows/qfai-docs.yml .github/wo
578
585
  Read your own edits out of the old copy before you replace it. Neither route
579
586
  merges them.
580
587
 
588
+ `npx qfai doctor` warns about each installed workflow whose text differs from
589
+ the packaged copy. The warning gives the number of differing lines, the jobs
590
+ that differ, each pinned action whose version differs and the file's current
591
+ digest. To keep a difference on purpose, list the file with that digest and a
592
+ reason in `qfai.config.yaml`; doctor then reports it as `info` with that reason
593
+ instead of a warning:
594
+
595
+ ```yaml
596
+ workflow:
597
+ acceptedDrift:
598
+ - file: qfai-docs.yml
599
+ digest: <the digest doctor printed, sha256:…>
600
+ reason: We run our own docs lane.
601
+ ```
602
+
603
+ When the file changes again its digest no longer matches, and doctor warns
604
+ again with the new digest. An entry without a digest or a
605
+ reason, or a file outside the shipped set or listed twice, is a configuration
606
+ error and accepts nothing.
607
+
581
608
  On any other CI platform, configure the job yourself and run:
582
609
 
583
610
  ```bash
@@ -864,6 +891,11 @@ Moving a project from the spec-pack layout to the story tree also requires
864
891
  `/qfai-migration-v1-to-v2`. `init --force` refreshes shipped assets; the
865
892
  migration skill moves project content and reports items that need a person.
866
893
 
894
+ The release notes of each version are the body of its GitHub Release, listed
895
+ at <https://github.com/aganesy/QFAI/releases>. Read them before you upgrade:
896
+ they name the files a version retires and any change to the exact version of a
897
+ dependency the package pins, such as `@jackchuka/mdschema`.
898
+
867
899
  To upgrade by hand:
868
900
 
869
901
  1. Install the new version with your package manager, for example
@@ -876,8 +908,12 @@ To upgrade by hand:
876
908
  afterwards.
877
909
  4. Delete the files the release notes of the new version list as retired, once
878
910
  nothing you keep reads them.
879
- 5. Run `npx qfai doctor` and `npx qfai validate`, and fix what they report.
880
- 6. Commit the result in one change.
911
+ 5. `init --force` does not touch the workflows under `.github/workflows/`. For
912
+ each one `npx qfai doctor` reports as differing, copy the packaged file over
913
+ it, or list it under `workflow.acceptedDrift` with the digest doctor prints
914
+ and a reason if you keep your own version.
915
+ 6. Run `npx qfai doctor` and `npx qfai validate`, and fix what they report.
916
+ 7. Commit the result in one change.
881
917
 
882
918
  An agent asked to upgrade `qfai` follows these steps as a dependency update.
883
919
 
@@ -1030,6 +1066,10 @@ file prints nothing. `qfai init` refreshes that file wherever the project has
1030
1066
  not edited it, so a new release's wording reaches an existing project without
1031
1067
  changing `.claude/settings.json`. Remove the entries from that file and from
1032
1068
  `.codex/hooks.json` to turn the reminder off; the rule still applies.
1069
+ The free-text entry reminder prints in full on a session's first prompt and in one line
1070
+ on every later prompt. Every other rule reminder prints at most once per session. Both
1071
+ are counted per `session_id` in the operating system's temporary directory, and there is
1072
+ no setting to change that.
1033
1073
 
1034
1074
  Codex gets the same reminders from `.codex/hooks.json` once you trust the
1035
1075
  project's hooks with `/hooks`. Each is one command line that runs the same under
@@ -216,6 +216,15 @@ routing:
216
216
  rerun_policy: changed-scope-dependents
217
217
  review_profile: default
218
218
 
219
+ - step: implement-procedure
220
+ phases:
221
+ - id: documentation
222
+ mandatory_agents: [doc-steward]
223
+ conditional_agents: []
224
+ parallel_groups: []
225
+ rerun_policy: changed-scope-dependents
226
+ review_profile: default
227
+
219
228
  # Writes the bodies of empty acceptance tests, keeping each annotation.
220
229
  - step: implement-acceptance
221
230
  phases:
@@ -4,6 +4,15 @@
4
4
  routing:
5
5
  # The triage steps change no tracked file, so each has one author and no
6
6
  # build or test phase.
7
+ - step: triage-operate
8
+ phases:
9
+ - id: operate
10
+ mandatory_agents: [devops-ci-engineer]
11
+ conditional_agents: []
12
+ parallel_groups: []
13
+ rerun_policy: changed-scope-dependents
14
+ review_profile: default
15
+
7
16
  - step: triage-owned-cleanup
8
17
  phases:
9
18
  - id: cleanup
@@ -0,0 +1,8 @@
1
+ route: answer-in-session
2
+ family: close
3
+ stages:
4
+ - id: answer
5
+ kind: triage
6
+ steps: [triage-answer]
7
+ decisionPoints: []
8
+ branchPoints: []
@@ -15,4 +15,7 @@ stages:
15
15
  steps: [verify-qfai-gate, verify-repo-gate, verify-commit]
16
16
  after: [note]
17
17
  decisionPoints: []
18
- branchPoints: []
18
+ branchPoints:
19
+ - step: implement-dep-bump
20
+ outcomes:
21
+ - { outcome: contract-finding, routes: [apply-settled] }
@@ -17,4 +17,8 @@ decisionPoints: [discussion-interview]
17
17
  branchPoints:
18
18
  - step: triage-close
19
19
  outcomes:
20
- - { outcome: adopted, routes: [add-feature, prototype-feature, change-compatibility] }
20
+ - {
21
+ outcome: adopted,
22
+ routes:
23
+ [add-feature, prototype-feature, change-compatibility, retire-feature, rename-concept],
24
+ }
@@ -29,6 +29,9 @@ stages:
29
29
  after: [note]
30
30
  decisionPoints: []
31
31
  branchPoints:
32
+ - step: implement-quarantine
33
+ outcomes:
34
+ - { outcome: failing-consistently, routes: decision-table }
32
35
  - step: implement-diagnose
33
36
  outcomes:
34
37
  - { outcome: product-race, routes: [fix-intermittent] }
@@ -0,0 +1,30 @@
1
+ route: rename-concept
2
+ family: change
3
+ stages:
4
+ - id: spec
5
+ kind: sdd
6
+ steps:
7
+ - sdd-triage
8
+ - { step: sdd-flow, passThrough: true }
9
+ - { step: sdd-story, passThrough: true }
10
+ - { step: sdd-contract, passThrough: true }
11
+ review: spec
12
+ - id: rename
13
+ kind: implement
14
+ steps: [implement-refactor]
15
+ after: [spec]
16
+ - id: note
17
+ kind: verify
18
+ steps:
19
+ - { step: verify-change-note, passThrough: true }
20
+ after: [rename]
21
+ review: code
22
+ - id: verify
23
+ kind: verify
24
+ steps: [verify-qfai-gate, verify-repo-gate, verify-commit]
25
+ after: [note]
26
+ decisionPoints: [sdd-triage]
27
+ branchPoints:
28
+ - step: implement-refactor
29
+ outcomes:
30
+ - { outcome: behaviour-change, routes: [add-feature, change-compatibility] }
@@ -11,6 +11,7 @@ stages:
11
11
  - { step: sdd-flow, passThrough: true }
12
12
  - { step: sdd-story, passThrough: true }
13
13
  - { step: sdd-contract, passThrough: true }
14
+ - { step: common-design-md, passThrough: true }
14
15
  - { step: sdd-cycle, passThrough: true }
15
16
  after: [diagnose]
16
17
  review: spec
@@ -0,0 +1,14 @@
1
+ route: resolve-conflicts
2
+ family: change
3
+ stages:
4
+ - id: edit
5
+ kind: maintenance
6
+ steps: [maintain-edit]
7
+ review: code
8
+ serves: [spec, contract]
9
+ - id: verify
10
+ kind: verify
11
+ steps: [verify-qfai-gate, verify-repo-gate, verify-commit]
12
+ after: [edit]
13
+ decisionPoints: []
14
+ branchPoints: []
@@ -0,0 +1,26 @@
1
+ route: retire-feature
2
+ family: change
3
+ stages:
4
+ - id: spec
5
+ kind: sdd
6
+ steps:
7
+ - sdd-triage
8
+ - sdd-story
9
+ - { step: sdd-contract, passThrough: true }
10
+ review: spec
11
+ - id: remove
12
+ kind: implement
13
+ steps: [implement-retire]
14
+ after: [spec]
15
+ - id: note
16
+ kind: verify
17
+ steps:
18
+ - { step: verify-change-note, passThrough: true }
19
+ after: [remove]
20
+ review: code
21
+ - id: verify
22
+ kind: verify
23
+ steps: [verify-qfai-gate, verify-repo-gate, verify-commit]
24
+ after: [note]
25
+ decisionPoints: [sdd-triage]
26
+ branchPoints: []
@@ -0,0 +1,11 @@
1
+ route: run-operation
2
+ family: upkeep
3
+ stages:
4
+ - id: operate
5
+ kind: triage
6
+ steps: [triage-operate]
7
+ decisionPoints: []
8
+ branchPoints:
9
+ - step: triage-operate
10
+ outcomes:
11
+ - { outcome: needs-change, routes: decision-table }
@@ -0,0 +1,12 @@
1
+ route: run-release
2
+ family: release
3
+ stages:
4
+ - id: release
5
+ kind: triage
6
+ steps: [triage-operate]
7
+ decisionPoints: []
8
+ releasePoint: triage-operate
9
+ branchPoints:
10
+ - step: triage-operate
11
+ outcomes:
12
+ - { outcome: needs-change, routes: decision-table }
@@ -0,0 +1,18 @@
1
+ route: write-procedure
2
+ family: change
3
+ stages:
4
+ - id: documentation
5
+ kind: documentation
6
+ steps: [implement-procedure]
7
+ - id: note
8
+ kind: verify
9
+ steps:
10
+ - { step: verify-change-note, passThrough: true }
11
+ after: [documentation]
12
+ review: code
13
+ - id: verify
14
+ kind: verify
15
+ steps: [verify-qfai-gate, verify-repo-gate, verify-commit]
16
+ after: [note]
17
+ decisionPoints: []
18
+ branchPoints: []
@@ -0,0 +1,174 @@
1
+ import process from "node:process";
2
+ import path from "node:path";
3
+ import { readFile, writeFile } from "node:fs/promises";
4
+ import { pathToFileURL } from "node:url";
5
+
6
+ async function main() {
7
+ const sdk = await import(pathToFileURL(process.argv[2]).href);
8
+ const { default: CodeGraph, setLogger, silentLogger } = sdk.default;
9
+ setLogger(silentLogger);
10
+ const mode = process.argv[4];
11
+ const corpus = process.argv[3];
12
+ const graph = mode
13
+ ? await CodeGraph.open(process.argv[3], { readOnly: true })
14
+ : await CodeGraph.init(process.argv[3], { index: false });
15
+ try {
16
+ if (mode === "inventory") {
17
+ process.stdout.write(
18
+ JSON.stringify({ files: graph.getFiles().map((file) => file.path) }) + "\n",
19
+ );
20
+ } else if (mode === "coverage") {
21
+ process.stdout.write(JSON.stringify(await coverage(graph, corpus)) + "\n");
22
+ } else if (mode === undefined) {
23
+ const result = await graph.indexAll();
24
+ const build = graph.getIndexBuildInfo();
25
+ await writeFile(
26
+ path.join(corpus, ".codegraph", "qfai-native-evidence.json"),
27
+ JSON.stringify({
28
+ engineVersion: build.version,
29
+ extractionVersion: build.extractionVersion,
30
+ lastIndexedAt: graph.getLastIndexedAt(),
31
+ result: {
32
+ success: result.success,
33
+ filesDiscovered: result.filesDiscovered ?? null,
34
+ filesIndexed: result.filesIndexed,
35
+ filesSkipped: result.filesSkipped,
36
+ filesErrored: result.filesErrored,
37
+ filesSkippedUnsupported: result.filesSkippedUnsupported ?? 0,
38
+ topUnsupportedExtensions: result.topUnsupportedExtensions ?? [],
39
+ errors: result.errors.map((error) => ({
40
+ code: error.code ?? "unclassified",
41
+ severity: error.severity,
42
+ filePath: safeRelativeInput(corpus, error.filePath),
43
+ })),
44
+ },
45
+ }) + "\n",
46
+ );
47
+ process.stdout.write("CodeGraph native indexing completed.\n");
48
+ } else {
49
+ throw new Error("Unsupported native operation");
50
+ }
51
+ } finally {
52
+ graph.close();
53
+ }
54
+ }
55
+
56
+ function safeRelativeInput(corpus, file) {
57
+ if (typeof file !== "string" || !file) return "Unidentified native input";
58
+ const relative = (path.isAbsolute(file) ? path.relative(corpus, file) : file).replaceAll(
59
+ "\\",
60
+ "/",
61
+ );
62
+ if (
63
+ path.posix.isAbsolute(relative) ||
64
+ path.win32.isAbsolute(relative) ||
65
+ relative.split("/").some((part) => !part || part === "." || part === "..") ||
66
+ /(?:^|\/)(?:\.env(?:\.|$)|\.npmrc$|\.pypirc$|\.netrc$|credentials?(?:\.|$)|secrets?(?:\.|$))|\.(?:pem|key|p12|pfx)$/i.test(
67
+ relative,
68
+ )
69
+ )
70
+ return "Unidentified native input";
71
+ return relative;
72
+ }
73
+
74
+ async function coverage(graph, corpus) {
75
+ const unknown = { complete: false, unsupported: [], unreadable: [], unparsed: [] };
76
+ let evidence;
77
+ try {
78
+ evidence = JSON.parse(
79
+ await readFile(path.join(corpus, ".codegraph", "qfai-native-evidence.json"), "utf8"),
80
+ );
81
+ } catch {
82
+ return unknown;
83
+ }
84
+ const build = graph.getIndexBuildInfo();
85
+ const result = evidence?.result;
86
+ const counts = [
87
+ "filesDiscovered",
88
+ "filesIndexed",
89
+ "filesSkipped",
90
+ "filesErrored",
91
+ "filesSkippedUnsupported",
92
+ ];
93
+ if (
94
+ !record(evidence) ||
95
+ Object.keys(evidence).length !== 4 ||
96
+ evidence.engineVersion !== build.version ||
97
+ evidence.extractionVersion !== build.extractionVersion ||
98
+ !Number.isSafeInteger(evidence.lastIndexedAt) ||
99
+ evidence.lastIndexedAt !== graph.getLastIndexedAt() ||
100
+ !record(result) ||
101
+ Object.keys(result).length !== 8 ||
102
+ typeof result.success !== "boolean" ||
103
+ counts.some((key) => !Number.isSafeInteger(result[key]) || result[key] < 0) ||
104
+ !Array.isArray(result.errors) ||
105
+ !Array.isArray(result.topUnsupportedExtensions)
106
+ )
107
+ return unknown;
108
+ const unsupported = [];
109
+ const unreadable = [];
110
+ const unparsed = [];
111
+ let documentedInputs = 0;
112
+ for (const group of result.topUnsupportedExtensions) {
113
+ if (
114
+ !record(group) ||
115
+ typeof group.ext !== "string" ||
116
+ !Number.isSafeInteger(group.count) ||
117
+ group.count < 0
118
+ )
119
+ return unknown;
120
+ if (
121
+ /^\.(?:md|mdx|txt|rst|adoc|pdf|png|jpe?g|gif|svg|webp|ico|woff2?|ttf|mp[34]|wav)$/i.test(
122
+ group.ext,
123
+ )
124
+ ) {
125
+ documentedInputs += group.count;
126
+ } else {
127
+ unsupported.push(`${group.ext} (${group.count} inputs)`);
128
+ }
129
+ }
130
+ const namedUnsupported = result.topUnsupportedExtensions.reduce(
131
+ (count, group) => count + group.count,
132
+ 0,
133
+ );
134
+ if (namedUnsupported < result.filesSkippedUnsupported)
135
+ unsupported.push("Other unsupported native inputs");
136
+ if (
137
+ namedUnsupported > result.filesSkippedUnsupported ||
138
+ documentedInputs > result.filesSkippedUnsupported
139
+ )
140
+ return unknown;
141
+ for (const error of [
142
+ ...result.errors,
143
+ ...graph.getFiles().flatMap((file) => file.errors ?? []),
144
+ ]) {
145
+ if (!record(error) || !["error", "warning"].includes(error.severity)) return unknown;
146
+ const file = safeRelativeInput(corpus, error.filePath);
147
+ if (error.code === "read_error") unreadable.push(file);
148
+ else unparsed.push(file);
149
+ }
150
+ if (result.filesErrored > 0 && unreadable.length === 0 && unparsed.length === 0)
151
+ unparsed.push("Unidentified native extraction errors");
152
+ const complete =
153
+ result.success &&
154
+ result.filesIndexed + result.filesSkipped + result.filesErrored >= result.filesDiscovered &&
155
+ result.filesErrored === 0 &&
156
+ unsupported.length === 0 &&
157
+ unreadable.length === 0 &&
158
+ unparsed.length === 0;
159
+ return {
160
+ complete,
161
+ unsupported,
162
+ unreadable: [...new Set(unreadable)],
163
+ unparsed: [...new Set(unparsed)],
164
+ };
165
+ }
166
+
167
+ function record(value) {
168
+ return typeof value === "object" && value !== null && !Array.isArray(value);
169
+ }
170
+
171
+ main().catch(() => {
172
+ process.stderr.write("CodeGraph native indexing failed.\n");
173
+ process.exitCode = 1;
174
+ });
@@ -0,0 +1,72 @@
1
+ """Inspect the managed corpus with Graphify's native freshness operation."""
2
+
3
+ import json
4
+ import sys
5
+ from pathlib import Path
6
+
7
+ from graphify.detect import detect_incremental
8
+
9
+
10
+ def input_inventory(output, graph):
11
+ manifest = json.loads((output / "manifest.json").read_text(encoding="utf-8"))
12
+ if not isinstance(manifest, dict):
13
+ raise ValueError("Invalid native manifest")
14
+ files = set(manifest.keys())
15
+ groups = [graph["nodes"]]
16
+ for name in ("edges", "links", "hyperedges"):
17
+ if name in graph:
18
+ groups.append(graph[name])
19
+ nested = graph.get("graph", {})
20
+ if not isinstance(nested, dict):
21
+ raise ValueError("Invalid native graph attributes")
22
+ if "hyperedges" in nested:
23
+ groups.append(nested["hyperedges"])
24
+ for group in groups:
25
+ if not isinstance(group, list):
26
+ raise ValueError("Invalid native graph references")
27
+ for item in group:
28
+ if not isinstance(item, dict):
29
+ raise ValueError("Invalid native graph reference")
30
+ for field in ("source_file", "definition_file", "path"):
31
+ value = item.get(field)
32
+ if value is None or value == "":
33
+ continue
34
+ if not isinstance(value, str):
35
+ raise ValueError("Invalid native input path")
36
+ files.add(value)
37
+ return sorted(files)
38
+
39
+
40
+ def main():
41
+ root = Path(sys.argv[1])
42
+ kind = sys.argv[2]
43
+ output = root / "graphify-out"
44
+ graph = json.loads((output / "graph.json").read_text(encoding="utf-8"))
45
+ if not isinstance(graph, dict) or not isinstance(graph.get("nodes"), list):
46
+ raise ValueError("Invalid native graph")
47
+ if kind == "inventory":
48
+ print(json.dumps({"files": input_inventory(output, graph)}))
49
+ return
50
+ if kind not in ("semantic", "ast"):
51
+ raise ValueError("Unsupported native inspection")
52
+ state = detect_incremental(
53
+ root,
54
+ manifest_path=str(output / "manifest.json"),
55
+ kind=kind,
56
+ cache_root=output,
57
+ )
58
+ print(json.dumps({
59
+ "current": state["new_total"] == 0
60
+ and not state["deleted_files"]
61
+ and not state["excluded_files"],
62
+ "unsupported": state.get("unclassified", []),
63
+ "unreadable": state.get("unreadable", []),
64
+ }))
65
+
66
+
67
+ if __name__ == "__main__":
68
+ try:
69
+ main()
70
+ except Exception:
71
+ sys.stderr.write("Graphify freshness inspection failed.\n")
72
+ sys.exit(1)