Skip to the page
Chapter 03 · The pack

How ee builds a pack.

The pack is what an agent reads at the start of a task: the memories that match it, within a token budget, near-duplicates dropped, each item with its source and score. The same inputs give the same pack.

Read all eight chapters on one page

03.1ee pack, stage by stage

A pipeline of timed stages.

ee pack runs a fixed pipeline. It validates the request, retrieves with lexical and semantic search fused by rank, resolves and admits candidates, selects under quotas, and assembles the pack with provenance. It reports every degradation, and --explain-performance adds each stage's time.
Pack assembly · the trace, in order

Twelve of ee pack's timed stages, in order.

Diagram · not program output

ee pack times each of these stages and names it in its timing trace (--explain-performance). Select a stage to read what it does; Play steps through them.

bars: candidates remaining, illustrative conditional opt-in unavailable

01 / 12Validate the requestrequestValidateevery pack

Parses the task, profile and budget, and caps the token budget and candidate pool to the workspace's runtime profile. Every built-in profile asks for a pool of 64.

Search · lexical and semantic, fused

Lexical · BM25

exact words, names, flags

Reciprocal-rank fusion

Σ 1 / (60 + rank)

weights 0.45 · 0.45

Semantic · Model2Vec

potion-multilingual-128M · 256-d

Both searches run locally. If the model cannot load, a deterministic hash embedder replaces it and gets no semantic credit; lexical scores take the semantic weight, and the response records this in degraded.

Ordering · quality multipliers

score = base × recency × confidence × utility × maturity × harmful × scope + anchor match (±0.08)

  • recencyexp(−age / 30 days), floor 0.5
  • confidencethe memory's confidence, floor 0.1
  • utility0.5 + 0.5 × utility
  • maturityrules: retired 0 · candidate 0.5 · established 1 · proven 1.5
  • harmful1 − 0.1 per harmful report, floor 0.2
  • scope× 1.2 on an exact workspace or scope match

Recency, confidence and harmful reports each have a floor, so they can lower a memory's rank but cannot remove it. Maturity is the only multiplier that reaches 0, for a deprecated or retired rule. Memories that are not rules have maturity 1.

Sources and assumptions
src/core/context.rs · the spans recorded by trace.record_elapsed, apply_memory_tier_candidate_admission (CONTEXT_MEMORY_TIER_HOT_BOOST 0.025, WARM 0.010), filter_candidates_by_instruction_authority, apply_personalized_pagerank_rerank · src/core/search.rs · DEFAULT_SEARCH_LEXICAL_WEIGHT 0.45, DEFAULT_SEARCH_SEMANTIC_WEIGHT 0.45, RRF k = 60 · src/search/scoring.rs · SearchScoreComponents · README · Limitations (personalized PageRank). The trace also records embedderPrepare, the daemon handoff's validation, sub-spans and the total, which the figure leaves out. Candidate counts on the stages are illustrative.
03.2ee's selection rule, on your screen

Build a pack yourself.

Change the profile and the budget, and every candidate says why it is in or out. Switch off the redundancy penalty and near-duplicates crowd out the failure the task needed.
Pack assembly · nineteen candidates

Set a profile and a budget, and see what ee's rule packs.

ee's rule, computed here

$ ee pack "prepare the v0.20 release" --profile balanced --max-tokens 800 --explain

Profile

Selection

Candidates · ranked by relevance

select one to see its arithmetic

  1. Why · m04 · 62 tokens · procedural:rule:release

    • gain = 0.75 × 0.87 − 0.25 × 0.95 = 0.415
    • max similarity 0.95 with m01 (same diversity key procedural:rule:release)
    • room for 30 of its 62 tokens under the procedural_rules quota, and the preview tier (20%) was spent: a link, “Memory m04”, 14 tokens, in the peripheral index

Budget spent

680 / 800

full ≤ 560preview ≤ 160link ≤ 80
  • procedural_rules224/240
  • decisions160/160
  • failures160/160
  • evidence108/160
  • artifacts28/80

Items

14

6 full · 3 preview · 5 link

Omitted

5

each with a reason

Avg relevance

0.70

of what was chosen

Near-duplicates in

1 / 3

redundancy lowers gain

# Context Pack: prepare the v0.20 release

**Profile:** balanced | **Budget:** 680/800 tokens

## What NOT to do

### 1. m02 (110 tokens)

Tag pushed before CHANGELOG.md was updated; the installer checksum went stale for a day.

## procedural_rules

### 2. m01 (60 tokens)

Run cargo fmt --check and the clippy gate before tagging.

### 3. m03 (70 tokens)

Bump Cargo.toml and CHANGELOG.md in the same commit as the version tag.

### 4. m09 (80 tokens)

Publish to crates.io only after the GitHub release assets verify.

## decisions

### 5. m06 (90 tokens)

Releases are cut locally with dsr, never with GitHub Actions.

### 6. m10 (70 tokens)

Installers verify SHA-256 sidecars and minisign signatures; ...

## failures

### 7. m08 (50 tokens)

The Homebrew tap was refreshed before the ...

## evidence

### 8. m11 (40 tokens)

cass session, v0.19.0 release ...

### 9. m19 (40 tokens)

cass session: the v0.18.0 release notes were drafted in the same session as the tag.

## Peripheral Index

- `m12` (artifacts)

- `m13` (evidence)

- `m14` (artifacts)

- `m04` (procedural_rules)

- `m15` (evidence)

Sources and assumptions
src/pack/mod.rs · DEFAULT_MMR_RELEVANCE_WEIGHT 0.75, DEFAULT_COVERAGE_FILL_RELEVANCE_FLOOR 0.05, strict_mmr_marginal_gain, candidate_signature_similarity, normalized_terms, quota_for_basis_points, pack_lod_candidate_plan, PackLodBudgetShares::default_70_20_10 · src/models/context_profile.rs · built-in section mixes · src/core/context.rs · diversity_key_for_memory. Candidates, scores and token sizes are invented for this page; ee's submodular profile uses facility location instead of MMR. On a real store, run ee pack "<task>" --explain --json and ee why-not <memory-id> --task "<task>".
03.3Explainable retrieval

Six questions every item answers.

To weigh a memory, an agent needs to know why it was returned. Every returned memory carries its answers to six questions, and ee why and ee pack --explain show the full detail.

01

Why selected?

Score components for each stage of the pipeline.

02

What supports it?

Provenance URIs back to the session, file or command.

03

How fresh?

The recency term: a 30-day time constant, floored at 0.5, the same for every level.

04

How reliable?

Confidence, evidence count, and the weight of harmful feedback.

05

What scores mattered?

The final score, its kind, a normalized relevance, and the raw breakdown.

06

What would change it?

A counterfactual hint, when there is one.

What the scores do not mean

Relevance scores rank results; they are not probabilities that a result answers the task. When results exist, ee reports retrieval quality as unknown rather than inventing a number, because score size, result count and interval coverage do not establish that an answer is correct. Judge a memory by its content and its evidence.

README, “Explainable Retrieval”

03.4Deterministic by default

A pack hash that reproduces.

Given the same snapshots, config, profile, budget and query, ties break the same way and the pack hash reproduces, so a pack can be cited, compared and replayed. The first version of the hash had a collision, which the figure below lets you recreate.
Pack identity · ee.pack.hash_input.v7

The bytes behind a pack's hash.

ee's rule, computed here

A pack's hash is a BLAKE3 digest of ten component digests (nine when the pack leaves out its skipped list), each over labeled fields. The first version fed a provenance's uri and note as raw adjacent bytes, so two different packs could get the same hash. Edit the fields below; the digests are BLAKE3, computed in your browser.

uri ‖ note

Pack A

Bytes fed to the hash

file://abc

10 bytes · blake3

08c2db064656d895354dc8141e164f10869474e638ae198fe5acf14b9a087d81

Pack B

Bytes fed to the hash

file://abc

10 bytes · blake3

08c2db064656d895354dc8141e164f10869474e638ae198fe5acf14b9a087d81

Same hashThese packs differ but get the same hash, so replay, caching and audit would treat them as one pack.

Scores, quantized before hashing

Every score the hash consumes is first rounded to Q20.12 fixed point (round(x × 4096) as a u32), so floating-point noise far below a quantum (1/4096 ≈ 0.000244) usually leaves the bytes, and the hash, unchanged. The exception is two scores on either side of a half-step: they round to different quanta however close they are.

Score A (f32)

0.75

× 4096 = 3072.0000

Score B (f32)

0.75000006

× 4096 = 3072.0002

Q20.12 A

3072

00 0c 00 00

Q20.12 B

3072

00 0c 00 00 · same bytes

Guaranteed

  • Same source and index snapshots, config, profile, budget, seed, query and decision inputs: ties resolve the same way and the pack hash reproduces.
  • The composite is built from tagged component digests, so the component two packs differ in can be found.

Not yet

  • Selection itself still compares raw f32 scores.
  • v7 does not yet establish cross-process or cross-host determinism gates (ADR 0087).
Sources and assumptions
src/core/context.rs · hash_labeled_bytes, hash_pack_hash_provenance (the labels item.provenance.uri and item.provenance.note), compute_context_pack_hash_components (ten components: request, items, omitted, degraded, effective_config, quality_scoring, reference_time, rendered_text, store_scopes, coordination) · src/core/context_test_module.rs · pack_hash_v2_separates_flat_feed_provenance_collision · src/pack/mod.rs · quantize_q20_12 · docs/adr/0087-canonical-deterministic-response-contract.md