Skip to content

add some transient tests#2151

Merged
vindarel merged 1 commit intolem-project:mainfrom
mahmoodsh36:transient-tests
Apr 28, 2026
Merged

add some transient tests#2151
vindarel merged 1 commit intolem-project:mainfrom
mahmoodsh36:transient-tests

Conversation

@mahmoodsh36
Copy link
Copy Markdown
Contributor

some tests for the transient extension

also i didnt stage the change required for registering the vi-mode insert tests in the .asd file for vi-mode in the previous PR. the change is in this PR which might look kinda weird, so if you just want me to open another pr for the change in lem-vi-mode.asd i can, but i guess its not a big deal

@code-contractor-app
Copy link
Copy Markdown
Contributor

code-contractor-app Bot commented Apr 25, 2026

❌ Code Contractor Validation: FAILED

=== Contract: contract ===

✓ Code Contractor Validation Result
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📋 Contract Source: Repository

📊 Statistics:
  Files Changed:    4
  Lines Added:      107
  Lines Deleted:    2
  Total Changed:    109
  Delete Ratio:     0.02 (2%)

Status: FAILED ❌

🤖 AI Providers:
  - codex — model: gpt-5.4

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠️ Violations Found (4):

[ERROR] loop_keywords_rule
  AI check failed: "loop_keywords_rule"
  ❌ Reason:
    Added `loop` forms use bare loop keywords instead of colon-prefixed
    keywords.

[WARNING] docstring_rule
  AI check failed: "docstring_rule"
  ❌ Reason:
    An added exported function is exported from the package without a
    docstring shown in the added code.

[ERROR] internal_symbol_rule
  AI check failed: "internal_symbol_rule"
  ❌ Reason:
    Added code accesses multiple internal symbols via double-colon package
    syntax.

[ERROR] dynamic_symbol_call_rule
  AI check failed: "dynamic_symbol_call_rule"
  ❌ Reason:
    Added ASDF test system uses `symbol-call` without documenting why it is
    unavoidable.
📋 Contract Configuration: contract (Source: Repository)
version: 2

trigger:
  paths:
    - "extensions/**"
    - "frontends/**/*.lisp"
    - "src/**"
    - "tests/**"
    - "contrib/**"
    - "**/*.asd"
  head_branches:
    exclude:
      - 'revert-*'

validation:
  limits:
    max_total_changed_lines: 400
    max_delete_ratio: 0.5
    max_files_changed: 10
    severity: warning

  ai:
    system_prompt: |
      You are a senior Common Lisp engineer reviewing code for Lem editor.
      Lem is a text editor with multiple frontends (ncurses, SDL2, webview).
      Focus on maintainability, consistency with existing code, and Lem-specific conventions.
    rules:
      # === File Structure ===
      - name: defpackage_rule
        prompt: |
          First form must be `defpackage` or `uiop:define-package`.
          Package name should match filename (e.g., `foo.lisp` → `:lem-ext/foo` or `:lem-foo`).
          Extensions must use `lem-` prefix (e.g., `:lem-python-mode`).

      - name: file_structure_rule
        prompt: |
          File organization (top to bottom):
          1. defpackage
          2. defvar/defparameter declarations
          3. Key bindings (define-key, define-keys)
          4. Class/struct definitions
          5. Functions and commands

      # === Style ===
      - name: loop_keywords_rule
        prompt: |
          Loop keywords must use colons: `(loop :for x :in list :do ...)`
          NOT: `(loop for x in list do ...)`

      - name: naming_conventions_rule
        prompt: |
          Naming conventions:
          - Functions/variables: kebab-case (e.g., `find-buffer`)
          - Special variables: *earmuffs* (e.g., `*global-keymap*`)
          - Constants: +plus-signs+ (e.g., `+default-tab-size+`)
          - Predicates: -p suffix for functions (e.g., `buffer-modified-p`)
          - Do NOT use -p suffix for user-configurable variables

      # === Documentation ===
      - name: docstring_rule
        prompt: |
          Required docstrings for:
          - Exported functions, methods, classes
          - `define-command` (explain what the command does)
          - Generic functions (`:documentation` option)
          Important functions should explain "why", not just "what".
        severity: warning

      # === Lem-Specific ===
      - name: internal_symbol_rule
        prompt: |
          Use exported symbols from `lem` or `lem-core` package.
          Avoid `lem::internal-symbol` access.
          If internal access is necessary, document why.

      - name: error_handling_rule
        prompt: |
          - `error`: Internal/programming errors
          - `editor-error`: User-facing errors (displayed in echo area)
          Always use `editor-error` for messages shown to users.

      - name: frontend_interface_rule
        prompt: |
          Frontend-specific code must use `lem-if:*` protocol.
          Do not call frontend implementation directly from core.
        severity: warning

      # === Functional Style ===
      - name: functional_style_rule
        prompt: |
          Prefer explicit function arguments over dynamic variables.
          Avoid using `defvar` for state passed between functions.
          Exception: Well-documented cases like `*current-buffer*`.

      - name: dynamic_symbol_call_rule
        prompt: |
          Avoid `uiop:symbol-call`. Rethink architecture instead.
          If unavoidable, document the reason.

      # === Libraries ===
      - name: alexandria_usage_rule
        prompt: |
          Alexandria utilities allowed: `if-let`, `when-let`, `with-gensyms`, etc.
          Avoid: `alexandria:curry` (use explicit lambdas)
          Avoid: `alexandria-2:*` functions not yet used in codebase

      # === Macros ===
      - name: macro_style_rule
        prompt: |
          Keep macros small. For complex logic, use `call-with-*` pattern:
          ```lisp
          (defmacro with-foo (() &body body)
            `(call-with-foo (lambda () ,@body)))
          ```
          Prefer `list` over backquote outside macros.

💬 Feedback

Reply to a violation comment with:

  • /dismiss <reason> - Report false positive or not applicable
📚 About Code Contractor

Declarative Code Standards That Learn and Improve

Define domain-specific validation rules in YAML.
Your contracts document team knowledge and evolve into more accurate AI enforcement.

Want this for your repo?
Install Code Contractor

Copy link
Copy Markdown
Contributor

@code-contractor-app code-contractor-app Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Contractor validation failed ❌ — see the sticky comment for full results.


(defun segments->string (segments)
"flatten rendered segment lines to a plain string."
(with-output-to-string (s)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Contractor: loop_keywords_rule

Contract: contract

AI check failed: "loop_keywords_rule"

Reason:
Added loop forms use bare loop keywords instead of colon-prefixed keywords.


💬 Reply /dismiss <reason> to dismiss this violation.

:prefix-active-p
:prefix-suffix
:transient-mode
:find-prefix-by-id
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Contractor: docstring_rule

Contract: contract

AI check failed: "docstring_rule"

Reason:
An added exported function is exported from the package without a docstring shown in the added code.


💬 Reply /dismiss <reason> to dismiss this violation.

(dolist (seg line)
(write-string (car seg) s)))))

(deftest keymap-creation
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Contractor: internal_symbol_rule

Contract: contract

AI check failed: "internal_symbol_rule"

Reason:
Added code accesses multiple internal symbols via double-colon package syntax.


💬 Reply /dismiss <reason> to dismiss this violation.

(defsystem "lem-transient/tests"
:depends-on ("lem-transient" "rove")
:components ((:file "tests/main"))
:perform (test-op (op c) (symbol-call :rove '#:run c))) No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Contractor: dynamic_symbol_call_rule

Contract: contract

AI check failed: "dynamic_symbol_call_rule"

Reason:
Added ASDF test system uses symbol-call without documenting why it is unavoidable.


💬 Reply /dismiss <reason> to dismiss this violation.

@vindarel vindarel merged commit 0465bff into lem-project:main Apr 28, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants