apply_token_budget_selection

Function apply_token_budget_selection 

Source
pub async fn apply_token_budget_selection(
    files: Vec<FileInfo>,
    token_budget: usize,
    config: &Config,
) -> Result<Vec<FileInfo>, ScribeError>
Expand description

Apply the library’s tiered token budget selection to a set of files.

The selector prioritizes files in multiple tiers:

  1. Mandatory project metadata (README, config files, entrypoints)
  2. Source files ordered by graph centrality with demotion fallback
  3. Documentation with preference for design/architecture material
  4. Any remaining files while budget remains

The function loads file content and token estimates for the selected files and will attempt demotion (chunk/signature extraction) when a source file would otherwise exceed the available budget.