Commit graph

94 commits

Author SHA1 Message Date
tobjend
3468813ec8 fix: validate SORE before returning, skip malformed grammars
- Add validate_sore() to gbnf.py — checks parseability without converting
- _infer_group now validates grammar and returns skip_reason='malformed_grammar'
  for SOREs containing raw code (e.g. w_body=, sult=, (+,+:N+...)
- Results: 130 grammars, 130 GBNF OK, 0 GBNF FAIL
  - Flask: 5 OK, 0 FAIL, 3.4s
  - RAGSAK: 19 OK, 0 FAIL, 11 malformed, 12.9s
  - FastAPI: 106 OK, 0 FAIL, 6 malformed, 30.5s
2026-07-12 02:56:13 +02:00
tobjend
bc7d3b6ca1 perf: iDRegEx opt-in, GBNF newline fix, OverflowError fix
- iDRegEx now opt-in via --idregex flag (was running on every group,
  causing 55s+ on Flask alone — src/flask/json took 55s in iDRegEx)
- GBNF tokenizer strips newlines from literals (multi-line symbols)
- Fix OverflowError: lang_size_score produces huge ints for large
  disjunctions, format as string not float
- Flask: 2.7s (was 55s+), RAGSAK: 13s (was 74s)
2026-07-12 02:52:05 +02:00
tobjend
f57c302c91 fix(gbnf): handle disjunction inside parens and compound repetition
The GBNF parser now correctly handles SORE's overloaded + operator:
- + inside (a+b+c) → alternation (not repetition)
- + outside parens → repetition
- +? and +* compound operators → normalized to Star

Also adds implicit concatenation when LPAREN follows a repetition,
so a+(b+c) parses as a+ followed by (b|c).

28 tests pass (13 new disjunction/compound tests). Full suite: 212 passed.
2026-07-12 02:20:58 +02:00
tobjend
6912841b9e fix: wire crx_refined into pipeline, fix hardcoded min_coverage
- Add --crx-method (standard|refined) to CLI and analyze_directory
- Pass crx_method through analyze_by_package → _infer_group
- Fix hardcoded min_coverage=0.2 in 3 places (was ignoring parameter)
- Refined CRX wraps crx_with_confidence into standard result format
2026-07-12 02:09:52 +02:00
tobjend
739000e8c6 feat: CRX refined — cluster-then-infer for tighter grammars
Standard CRX over-approximates when Hasse diagram is non-linear (24% of
RAGSAK packages). Cluster-then-infer groups sequences by (first, last,
length), infers per-cluster, picks largest cluster's grammar.

Results on RAGSAK:
  Avg max disjunction: 2.8 → 1.7 (39% tighter)
  Packages improved: 6/10

Tradeoff: cluster granularity (too coarse = over-approximation,
too fine = no generalization). Current: (first, last, length_bucket).

Exports crx_refined() and crx_with_confidence() from bex package.
20 new tests. All 199 tests pass.
2026-07-12 01:50:40 +02:00
tobjend
8028570ceb feat: frequency threshold sweep — 0.01-0.20 across 4 codebases
Sweet spot: 0.01-0.05. At 0.01 RAGSAK gets 61 SOREs (26.1% cov) with
real conventions like warn.status.body.ErrorResponse. At 0.05 coverage
jumps to 45.4% but that pattern disappears. Flask dies at 0.15+.

Current default min_coverage=0.2 is too aggressive for most codebases.
2026-07-12 01:26:45 +02:00
tobjend
1b98b1d24e chore: add external_refs to .gitignore 2026-07-12 01:14:49 +02:00
tobjend
dd183f6241 feat: 4-codebase evaluation — conventions vs completions tradeoff
Added kotlinx.coroutines (1040 .kt files) and FastAPI (1129 .py files).

Key findings across 4 codebases:
- Coarsening trades per-package coverage for cross-package reach
- FastAPI: coverage IMPROVES (12.4% -> 20.7%), cross-pkg +15
- Coroutines: cross-pkg +15, real exception-handling patterns
- RAGSAK: cross-pkg +18, null-check conventions across 8 packages
- Flask: slight cross-pkg loss, rendering conventions still visible

The conventions vs completions tradeoff is real and measurable.
2026-07-12 01:14:09 +02:00
tobjend
8540947eec docs: Round 6b results — Kotlin capture fix + minimal coarsening 2026-07-12 01:05:19 +02:00
tobjend
d65b78bdf1 fix: bare Kotlin captures + minimal coarsening (RETURN/IF/EXCEPTION/LOOP only)
- Added bare Kotlin captures to BEHAVIORAL_PREFIXES: conditional, exception, repeat, property, type
- Dropped variable (too noisy), kept only 4 high-signal categories in coarsen_token
- RAGSAK: 87 cross-package contexts (up from 69), real null-check patterns
- Flask: k=2 coverage 4.5% -> 15.8%, cross-package rendering conventions
2026-07-12 01:04:51 +02:00
tobjend
592974f039 feat: structural coarsening experiment — keeps function names raw, coarsens keywords
- coarsen_token() maps tree-sitter captures to categories (RETURN, IF, LOOP, etc.)
- Function calls kept as raw text (they ARE the behavioral content)
- Only ~5% structural tokens coarsened
- Results: Flask coverage 17.5% -> 28.8% (+11.3%), RAGSAK unchanged (95% calls)
- Cross-package shapes emerge: ('IF', 'KW', 'RETURN') in 4 Flask packages
2026-07-12 00:56:09 +02:00
tobjend
8e1c7f3767 docs: experiment log + cross-package analysis
- Full experiment history: context strategies, Reduce, scoring, GBNF, cross-package
- Documented failures: per-package sparsity, Reduce at wrong level, exact match rarity
- Designed next experiment: structural coarsening via tree-sitter categories
- Updated RESULTS.md with Round 5 findings and summary table
2026-07-12 00:45:21 +02:00
tobjend
011df391c2 feat: implement SORE → GBNF converter
- Recursive descent parser for SORE syntax (+, ?, *, |, ., parens)
- AST intermediate representation (_Literal, _Concat, _Alt, _Plus, _Optional, _Star)
- to_gbnf(sore) → full GBNF rule string
- to_gbnf_with_rules(sore, name) → named rule for composition
- 15 tests covering all SORE operators and nesting patterns
2026-07-12 00:31:47 +02:00
tobjend
b516b2985d feat: implement Reduce algorithm (Algorithm 4, TODS 2010)
- bex/reduce.py: Faithful implementation of Reduce with support-weighted
  SOA edit distance, adjunction, iterative merging, and Minimize
- experiments/context_eval.py: Multi-codebase support (RAGSAK + Flask),
  Reduce experiments with thresholds 0.05-0.4
- tests/test_reduce.py: 24 tests covering all Reduce components
- Flask cloned to external_refs/flask for cross-validation

Results:
- RAGSAK: 12.0% coverage (First 3 symbols)
- Flask: 10.7% coverage (First 3 symbols)
- Reduce has minimal impact (1-2 merges per codebase at ε=0.3)
- Coverage ceiling appears to be ~10-12% for prefix-based grouping
2026-07-12 00:11:38 +02:00
tobjend
bbdfe93679 experiments: test all context strategies on RAGSAK — behavioral grouping wins
Key findings:
- File path grouping (structural) = baseline (0.6% coverage) — no improvement
- First-k-symbols grouping (behavioral) = 20× improvement (12% coverage at k=3)
- Two-dimensional (path + symbols) = worse than behavioral alone
- Winner: Option B k=3 — 47 SOREs, 12% coverage

Smart filters make experiments fast (<1s vs minutes):
- max_unique_ratio=0.85
- max_alphabet=20
- max_soa_edges=100

Preserved in experiments/results/ for future reference.
2026-07-11 23:40:21 +02:00
tobjend
ab20b03256 feat: add diversity threshold — skip groups with unique_ratio > 0.9 or methods < min_methods
Adds --min-methods CLI flag (default 5). Groups that are too diverse or
too small are skipped with skip_reason in meta. Prevents noisy/meaningless
grammars from diverse packages.
2026-07-11 23:11:54 +02:00
tobjend
dfb56a083a WIP: language size scoring + diversity threshold (step 1 pending) 2026-07-11 22:56:42 +02:00
tobjend
830104b399 feat: add analyze_directory MCP tool — scan codebase, infer conventions, persist to .dervish/
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
ci/woodpecker/pr/woodpecker Pipeline failed
2026-07-11 21:28:35 +02:00
tobjend
e94c52b71a docs: update stale docs — remove kORE from default ensemble, add tag preprocessor CLI
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
ci/woodpecker/pr/woodpecker Pipeline failed
2026-07-11 20:51:10 +02:00
tobjend
ce6521ad5e Revert "parallelize kORE outer (k, n) trials via ProcessPoolExecutor"
This reverts commit 0b5b0e623b.
2026-07-11 20:36:48 +02:00
tobjend
0b5b0e623b parallelize kORE outer (k, n) trials via ProcessPoolExecutor
Add _kore_trial() module-level worker for pickling. infer() accepts
n_workers param — >1 runs all (k x N) trials concurrently instead
of serial. Default 1 preserves existing behavior.

Thread n_workers through _run_kore() and infer_ensemble() to support
--kore flag with parallel kORE inference.
2026-07-04 03:04:54 +02:00
tobjend
5906adfc95 parallelize preprocessing across files via ProcessPoolExecutor
Replace serial file-read + tree-sitter parse loop with _preprocess_files()
using ProcessPoolExecutor. Module-level _preprocess_file() for pickling.

Covers all three callers: analyze_clusters, analyze_by_package, infer.
2026-07-04 02:58:47 +02:00
tobjend
710da56916 drop kORE from default ensemble, add --kore flag to opt in
- Remove kORE from top-level imports, _ALGORITHMS, and infer_ensemble body
- Add include_kore=False parameter, runs kORE only when opted in
- Add --kore CLI flag threaded through all pipeline layers
- Remove koreinference from --prefer choices
- Keep kore.py module in repo for reference/future use
- Update tests: remove test_prefer_koreinference, update algorithm assertions
2026-07-04 02:58:07 +02:00
tobjend
e3ad256321 feat: add --slice package (per-directory grouping), --include/--exclude, --verbose, drop root group inference, run full ensemble on all groups 2026-07-04 02:43:03 +02:00
tobjend
4a506cd39b fix: add bare function fallback to CALL_PREFIXES, fix IMPORT_PATTERNS order, update pipeline diagram
- CALL_PREFIXES: add bare "function" as last fallback — Kotlin uses
  @function for both calls and definitions (no function.call capture)
- _find_arglist_node: remove template_string from arglist detection
- IMPORT_PATTERNS: require_relative before require (Ruby fix)
- pipeline-overview.txt: remove .gitignore, add min_coverage=0.8 + core/outlier
- DEFAULT_COVERAGE=0.8, frequency_filter at fixed 0.2
2026-07-04 01:28:35 +02:00
tobjend
eb2173442b fix: restore frequency_filter at 0.2, add dual 0.8 BEX coverage
- frequency_filter(min_coverage=0.2) strips rare symbols before clustering/inference
- DEFAULT_COVERAGE=0.8 passed to infer_ensemble for sequence-level core/outlier detection
- Both filters active: symbol-level (0.2) then BEX sequence-level (0.8)
- Fix seq_of_file tracking broken by filter creating new list objects
2026-07-04 01:13:48 +02:00
tobjend
55d21af48e docs: pipeline overview ASCII diagram
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
ci/woodpecker/pr/woodpecker Pipeline failed
2026-07-03 22:59:51 +02:00
tobjend
e23922a1b7 feat: adaptive multi-assignment clustering; add ADRs 1-10
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
- Multi-assignment clustering (no greedy 'used' set)
- Adaptive ngram fallback (shrink when (other) > 60%)
- Add docs/adr/ with 10 architecture decision records
- Fix ADR 1 (query modification description)
- Fix ADR 3 (multi-assignment + adaptive shrink)
- Fix ADR 5 (import sort order clarification)
- Fix ADR 6 (remove Kotlin call_suffix references)
- New ADR 9 (adaptive clustering rationale)
- New ADR 10 (universal package mapping via relpath)
2026-07-03 22:58:09 +02:00
tobjend
fd574da53d feat: language-agnostic import/arg/package extraction
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
- Add _classify_arg_node, _find_arglist_node, _iterate_arg_nodes,
  extract_arg_info, _summarize_arg_info (no per-language branches)
- _find_arglist_node: drop call_suffix from fallback list
- _iterate_arg_nodes: generic named-child iterator only
- Add IMPORT_PATTERNS + _extract_imports (regex-based, all languages)
- Add _file_to_package / _top_packages (pure relpath from project root)
- Add --json output format for prompt injection
- analyze_clusters returns 4-tuple with meta (files, imports, arg_patterns, packages)
2026-07-03 22:41:04 +02:00
tobjend
73b94af959 feat: cluster methods by n-gram patterns before inference
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
- _extract_call_tokens filters to call-like captures only
- cluster_methods groups sequences by shared 3-gram call patterns
- analyze_clusters runs per-cluster CRX/iDRegEx/kORE inference
- Lists 17 convention clusters for RAGSAK test code
- iDRegEx and kOREInference now produce ordered grammars per cluster
- (other) cluster captures diverse conventions as CRX vocabulary
- min-cluster-size (default 3) and ngram-size (default 3) CLI flags
2026-07-03 21:41:46 +02:00
tobjend
2620b6e49f feat: method-level sequence extraction via child_by_field_name('body')
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
- _find_method_bodies uses tree-sitter's universal body field (9/10 grammars)
- Kotlin fallback: scan children for body-like types
- preprocess_by_method groups highlight captures by enclosing method body
- Returns per-method sequences for k-ORE ordering analysis
- analyze.py infer() now uses preprocess_by_method
- Document findings in ANALYSIS.md
- 97 tests pass
2026-07-03 21:34:25 +02:00
tobjend
0c7703f63b feat: universal tag-preprocessor orchestrator with frequency filter
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
- Rename bex/tag-preprocessor/ to bex/tag_preprocessor/ (valid Python package)
- Add analyze.py: scan_directory, frequency_filter, infer, analyze_directory
- Frequency filter removes symbols below min_coverage threshold (Phase 1.0 step 4)
- infer() wires preprocess → frequency_filter → ensemble (Phase 1.0 step 5)
- --dir CLI mode for running full pipeline on directories (Phase 1.0 step 6)
- 9 new tests (test_analyze.py), all 94 tests pass
2026-07-03 20:58:18 +02:00
tobjend
8bda174293 docs: document Kotlin and JS/TS special cases in analysis
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-07-03 20:54:03 +02:00
tobjend
70300ff917 chore: add Gemini session chat logs as reference
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-07-03 20:48:50 +02:00
tobjend
ee5ebc9eb4 feat: universal AST preprocessor with nvim-treesitter queries
- Replace old per-language query files with unified tag-preprocessor
- Universal preprocessor uses nvim-treesitter highlights.scm for 10 langs
- Resolves ; inherits: directives (ecma, jsx) for JS/TS
- ts-kotlin bundled query for Kotlin compatibility
- Strips unsupported #set! 3-arg predicates for jsx
- archive old community queries
2026-07-03 20:48:47 +02:00
tobjend
986eaa7f83 feat: add community tags findings audit and kotlin tags query 2026-07-03 18:40:53 +02:00
tobjend
8d06ac2d52 chore: add downloaded community queries for kotlin + typescript
Kotlin (fwcd/tree-sitter-kotlin) and TypeScript packages
don't bundle queries. These are downloaded from upstream repos.
2026-07-03 18:05:19 +02:00
tobjend
069c63f2c8 feat: inspect TreeSitter tag queries for Dervish universal AST extraction
- Fetch TAGS_QUERY and HIGHLIGHTS_QUERY from 8 official TreeSitter language packages
- Save all curated queries as .scm files
- Analysis confirms universal query approach is viable
- TreeSitter silently ignores non-existent node types per language
- Add full conversation references (gemini chat markdown files)
- Add comprehensive conversation summary with roadmap
2026-07-03 17:46:33 +02:00
28f5f897d5 Update README.md
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-07-02 18:17:16 +00:00
d74b36e563 Update README.md
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-07-02 18:14:48 +00:00
197a0a3c22 Update README.md
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-07-02 18:08:42 +00:00
136ae08fe3 Update README.md
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-07-02 18:06:38 +00:00
ea8e2f1db7 Update README.md
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-07-02 16:33:51 +00:00
16cbff61a8 Update README.md
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-07-02 16:33:02 +00:00
tobjend
b037098730 fix: regenerate chart with Comic Neue + path.sketch xkcd style
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-07-01 16:14:24 +02:00
d2d57bc431 Merge pull request 'feat: kOREInference — Algorithm 4 iDRegEx with MDL scoring + ensemble integration' (#1) from feature/kore-inference into main
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-07-01 14:08:18 +00:00
tobjend
90d8c69aa7 fix: broken y-axis bar chart for readability
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
2026-07-01 16:05:49 +02:00
tobjend
2562519718 fix: grouped bar chart with Without Dervish vs With Dervish
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
2026-07-01 16:04:55 +02:00
tobjend
ce4088e705 fix: chart bars use Dervish purple #853E91
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
2026-07-01 16:03:20 +02:00
tobjend
d96e99d84f docs: xkcd-style chart
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
2026-07-01 16:02:14 +02:00