codeflash/tiles/codeflash-rules/rules/optimization-patterns.md
Kevin Turcios 6718e66582 feat: add private tessl tiles for codeflash rules, docs, and skills
Three private tiles in the codeflash workspace:
- codeflash-rules: 6 steering rules (code-style, architecture, optimization-patterns, git-conventions, testing-rules, language-rules)
- codeflash-docs: 7 doc pages (domain-types, optimization-pipeline, context-extraction, verification, ai-service, configuration)
- codeflash-skills: 2 skills (debug-optimization-failure, add-codeflash-feature)
2026-02-14 20:55:06 -05:00

1.2 KiB

Optimization Pipeline Patterns

  • All major operations return Result[SuccessType, ErrorType] — construct with Success(value) / Failure(error), check with is_successful() before calling unwrap()
  • Code context has token limits (OPTIMIZATION_CONTEXT_TOKEN_LIMIT=16000, TESTGEN_CONTEXT_TOKEN_LIMIT=16000 in code_utils/config_consts.py) — exceeding them rejects the function
  • read_writable_code (modifiable code) can span multiple files; read_only_context_code is reference-only dependency code
  • Code is serialized as markdown code blocks: ```language:filepath\ncode\n``` — see CodeStringsMarkdown in models/models.py
  • Candidates form a forest (DAG): refinements/repairs reference parent_id on previous candidates via OptimizedCandidateSource (OPTIMIZE, REFINE, REPAIR, ADAPTIVE, JIT_REWRITE)
  • Test generation and optimization run concurrently — coordinate through CandidateEvaluationContext
  • Generated tests are instrumented with codeflash_capture.py to record return values and traces
  • Minimum improvement threshold is 5% (MIN_IMPROVEMENT_THRESHOLD=0.05) — candidates below this are rejected
  • Stability thresholds: STABILITY_WINDOW_SIZE=0.35, STABILITY_CENTER_TOLERANCE=0.0025, STABILITY_SPREAD_TOLERANCE=0.0025