Add tangle-sync enforcement rule
Some checks failed
Deploy-Agent-V15-Stdin / JOB-V15-STDIN (push) Failing after 2s

- Added check-tangle-sync function to detect stale .lisp files
- Added :tangle-synced to *enforcement-rules*
- Updated .asd to include engineering-standards component
- Added tests for check-tangle-sync (detects stale lisp, passes when synced)
This commit is contained in:
2026-04-25 19:47:02 -04:00
parent f7209a8bb0
commit bcfffe15ee
5 changed files with 255 additions and 60 deletions

View File

@@ -4,9 +4,6 @@
(in-package :opencortex-engineering-standards-tests)
;; Load the skill functions first
(load "library/gen/org-skill-engineering-standards.lisp")
(def-suite engineering-standards-suite
:description "Tests for Engineering Standards enforcement")
@@ -46,8 +43,10 @@
"engineering-standards-gate blocks when git is dirty."
(let ((action (list :type :request
:payload (list :tool :write-file
:file "/tmp/test"
:content "test"))))
:file "/tmp/test"
:content "test"))))
;; Note: This test assumes git is clean in test environment
;; The gate returns :log if dirty
(let ((result (opencortex::engineering-standards-gate action nil)))
(is (listp result))
(when (eq (getf result :type) :log)
@@ -57,7 +56,34 @@
"engineering-standards-gate passes when git is clean."
(let ((action (list :type :request
:payload (list :tool :read-file
:file "/tmp/test"))))
:file "/tmp/test"))))
(let ((result (opencortex::engineering-standards-gate action nil)))
(is (listp result))
(is (eq :request (getf result :type))))))
(is (eq :request (getf result :type))))))
(test tangle-sync-detects-stale-lisp
"check-tangle-sync returns violation when .lisp is newer than .org"
(let ((tmp-org "/tmp/test-skill.org")
(tmp-lisp "/tmp/test-skill.lisp"))
(with-open-file (f tmp-org :direction :output) (write-line "* Test" f))
(sleep 1)
(with-open-file (f tmp-lisp :direction :output) (write-line "(defun test () t)" f))
(let* ((root (uiop:ensure-directory-pathname "/tmp/"))
(result (opencortex::check-tangle-sync root)))
(when result
(is (eq :tangle-synced (opencortex::engineering-violation-rule result))))
(uiop:delete-file-if-exists tmp-org)
(uiop:delete-file-if-exists tmp-lisp)))
(test tangle-sync-passes-when-synced
"check-tangle-sync returns nil when .org is newer than .lisp"
(let ((tmp-org "/tmp/test-skill2.org")
(tmp-lisp "/tmp/test-skill2.lisp"))
(with-open-file (f tmp-lisp :direction :output) (write-line "(defun test () t)" f))
(sleep 1)
(with-open-file (f tmp-org :direction :output) (write-line "* Test" f))
(let* ((root (uiop:ensure-directory-pathname "/tmp/"))
(result (opencortex::check-tangle-sync root)))
(is (null result)))
(uiop:delete-file-if-exists tmp-org)
(uiop:delete-file-if-exists tmp-lisp)))