Skip to content

feat(query): (crosslang ...) + (since ...) forms (issue #33 S3b+c)#58

Merged
hyperpolymath merged 1 commit into
mainfrom
feat/issue-33-s3b-crosslang-query
May 27, 2026
Merged

feat(query): (crosslang ...) + (since ...) forms (issue #33 S3b+c)#58
hyperpolymath merged 1 commit into
mainfrom
feat/issue-33-s3b-crosslang-query

Conversation

@hyperpolymath
Copy link
Copy Markdown
Owner

Summary

Adds two query forms to `panic-attack query`, closing the S3 follow-ups called out in #57:

  1. `(since 2026-04-12)` — matches findings whose `first_seen_run` (when ISO-formatted) or hexad `created_at` is ≥ the cutoff. RFC-3339 strings sort lexicographically, so the string `>=` compare is exact for any well-formed timestamp. Combined with `and`, this expresses the `(diff :since DATE :category CAT)` use case the issue calls out:
    ```scheme
    (and (since 2026-04-12) (category CryptoMisuse))
    ```

  2. `(crosslang :from FROM_CAT :to TO_CAT)` — co-occurrence proxy for FFI/cross-language reachability. Matches a `TO`-category finding in a repo that also has at least one `FROM`-category finding. Most FFI-driven proof drift surfaces in the same repo, so this is the operationally useful approximation until `kanren::crosslang` facts are persisted as hexads.
    Both shapes parse:
    ```scheme
    (crosslang :from UnsafeFFI :to ProofDrift)
    (crosslang UnsafeFFI ProofDrift)
    ```

Stacked on #57 — diff against `main` includes the S1+S2+S3 changes until they land.

Test plan

  • `cargo test --lib` — 248 green (9 new).
  • `cargo clippy --all-targets -- -D warnings` — clean.

Refs #33. Stacked on #57.

🤖 Generated with Claude Code

Adds two query forms to the panic-attack query subcommand:

1. (since 2026-04-12) — match findings whose first_seen_run (when ISO-
   formatted) or hexad created_at is >= the cutoff. RFC-3339 strings
   sort lexicographically, so a string >= compare is exact for any
   well-formed timestamp. Combined with `and`, expresses the
   "(diff :since DATE :category CAT)" use case the issue calls out:
       (and (since 2026-04-12) (category CryptoMisuse))

2. (crosslang :from FROM_CAT :to TO_CAT)  — co-occurrence proxy for
   FFI/cross-language reachability. Matches a TO-category finding in a
   repo that also has at least one FROM-category finding. Most
   FFI-driven proof drift surfaces in the same repo, so this is the
   operationally useful approximation until kanren-crosslang facts are
   persisted as hexads (a later slice). Both keyword and positional
   shapes accepted:
       (crosslang :from UnsafeFFI :to ProofDrift)
       (crosslang UnsafeFFI ProofDrift)

Implementation:

- New Query variants Since(String) and Crosslang { from, to }.
- Parser extended with `since` and `crosslang` heads; crosslang
  accepts both positional and `:from`/`:to` keyword forms.
- Evaluator's load_context now also builds a repo→categories index so
  (crosslang ...) is O(1) per row.

Tests: 9 new (5 parser positive + 2 rejection cases, 2 crosslang
evaluator, 1 since evaluator). Lib total: 248 green. Clippy clean
with -D warnings.

Refs #33. Stacked on #57 (S3) — diff against main includes the
S1+S2+S3 changes until they land.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hyperpolymath hyperpolymath force-pushed the feat/issue-33-s3b-crosslang-query branch from 17bd2a0 to 0821b94 Compare May 27, 2026 13:26
@hyperpolymath hyperpolymath merged commit 5e86c1e into main May 27, 2026
15 of 19 checks passed
@hyperpolymath hyperpolymath deleted the feat/issue-33-s3b-crosslang-query branch May 27, 2026 13:26
hyperpolymath added a commit that referenced this pull request May 27, 2026
… follow-up) (#61)

## Summary
- Adds a `HexadSemantic.crosslang: Option<CrosslangSemantic>` facet and
a
  `build_crosslang_hexads(...)` helper that drives the kanren
`CrossLangAnalyzer` per repo (ingest → extract → load_rules → analyze →
  query_interactions) and emits one hexad per derived
  `CrossLangInteraction`.
- New env var `PANIC_ATTACK_STORE_CROSSLANG_HEXADS` (separate from
  `PANIC_ATTACK_STORE_FINDING_HEXADS`) opts a run into emission;
  `persist_assemblyline_report` writes to `<dir>/hexads/crosslang/`
  file-side only.
- Adds `load_crosslang_hexads(base_dir)` so the paired query-evaluator
PR
  can match against persisted facts; falls back to empty `Vec` when the
dir is missing (the evaluator treats that as "use co-occurrence proxy").

## Why
Tightens the `(crosslang :from :to)` query from a same-repo
co-occurrence
proxy to a true FFI/cross-language reachability check against
persisted kanren-derived facts. PR 1 of a 2-PR stack; PR 2 switches the
evaluator over while preserving fall-back semantics.

## Test plan
- [x] `cargo test --lib` — 252 tests pass, including 4 new
      `storage::tests::*crosslang*` cases (build-empty, build-from-FFI,
      write/read roundtrip + missing-dir, env-var default-off + opt-in).
- [x] `cargo clippy --all-targets -- -D warnings` clean.
- [x] `cargo fmt --all` no diff.

Stacks under: issue #33 S1/S2/S3 PRs (#55, #56, #57, #58). Filed against
`main` per orphan-trap rule.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

🔍 Hypatia Security Scan

Findings: 74 issues detected

Severity Count
🔴 Critical 7
🟠 High 16
🟡 Medium 51

⚠️ Action Required: Critical security issues found!

View findings
[
  {
    "reason": "Issue in boj-build.yml",
    "type": "unknown",
    "file": "boj-build.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in cargo-audit.yml",
    "type": "unknown",
    "file": "cargo-audit.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in casket-pages.yml",
    "type": "unknown",
    "file": "casket-pages.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in casket-pages.yml",
    "type": "unknown",
    "file": "casket-pages.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in codeql.yml",
    "type": "unknown",
    "file": "codeql.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in coverage.yml",
    "type": "unknown",
    "file": "coverage.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dependency-review.yml",
    "type": "unknown",
    "file": "dependency-review.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "unknown",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "unknown",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in dogfood-gate.yml",
    "type": "unknown",
    "file": "dogfood-gate.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  }
]

Powered by Hypatia Neurosymbolic CI/CD Intelligence

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.

1 participant