Skip to content

feat(t27mcp): find.t27 -- t27_find, intent to ranked corpus specs or an honest miss - #10194

Merged
gHashTag merged 1 commit into
masterfrom
mcp-t27-find
Oct 18, 2026
Merged

gHashTag merged 1 commit into
masterfrom
mcp-t27-find

Conversation

@gHashTag

Copy link
Copy Markdown
Owner

What

specs/t27mcp/find.t27 -- the ranking behind the MCP tool t27_find (epic #10066, first step of the validated-code contract: reuse a validated spec when one exists, write a new one only on a miss).

An agent that needs "a clocked counter" does not know the file is called clocked_counter.t27. verdict(intent, name, path, tags) decides for one manifest row; rank_key(...) orders the rows it admits. The server (gHashTag/t27-mcp) only feeds rows in and sorts by the key.

Rules, all in the spec:

  • Words of the intent are stemmed (ing / ed / er / plural s), stop words and one-letter words dropped, and a few abbreviations added (clock/clk, reset/rst, count/cnt, register/reg, multiply/mul, ...).
  • A word is found only at the start of a token of the file name (score 2) or the path (score 1). count is not found in account.
  • Threshold: up to 3 words every word must be found; from 4 words at least two thirds; and the file name must carry at least half of all words. A path match alone never carries a spec.
  • A row is served only if it is health/ok and has/tests. A relevant row that is not served is counted (skipped.unhealthy, skipped.untested), not returned.
  • Below the threshold the answer is a miss, not the nearest neighbour (CodeRAG-Bench: copied distracting code fails the tests). The contract's own example, "clocked counter with sync reset", is a miss today: the corpus has clocked_counter and reset_sync as two specs.
  • The manifest summary text is never matched on (it is boilerplate).
  • has/tests is a manifest tag, not a receipt. The reply says so and points to the next tool, t27_validate.

Reuses has from t27mcp::check_hints (no copy).

Evidence (Railway lab, t27c 0.5.2, rebased on 290ff17)

  • t27c test-report specs/t27mcp/find.t27: 13 of 13 pass, vacuous passes 0 of 13.
  • Negative controls (one mutation each, run as a throwaway spec in the tree):
    • covers() check removed from verdict: 7 tests fail
    • coverage ratio loosened (3*m < 2*n -> 3*m < 1*n): 2 fail
    • "name carries half the words" rule dropped: 1 fails
    • match inside a word instead of at a token start: 1 fails
    • numbers treated as noise again (the sha-256 weak hit below): 2 fail
  • Trivial solution (return V_HIT; as the first line of verdict) is refused by the compiler ("unreachable code"), so that check is a compile error rather than a failing test.
  • python3 tools/dupe_scan.py --like specs/t27mcp/find.t27: nothing in this file is written elsewhere.
  • Whole-repo python3 tools/dupe_scan.py prints a body written under byte_sum is now copied [2] time(s) and was in no ledger (specs/ml/file_io_contract.t27). It is identical on master without this file; this PR adds no duplicate group. Not touched here.

Real manifest (2402 specs), same wasm the server loads, 5-20 ms per call:

intent result
clocked counter with sync reset miss
clocked counter specs/ternary/clocked_counter.t27
ternary full adder specs/ternary/ternary_full_adder.t27 only
uart echo the two uart_echo* specs
gray code counter / I2C master controller / LFSR pseudo-random generator miss
sha256 specs/tri/crypto/sha256.t27, tri-net/specs/tri_sha256.t27 (a third sha256 spec is skipped: not health/ok)

Known limits (honest)

  • Matching is on file name and path only. A spec whose name does not say what it is (a SHA-256 in duplicate_rules.t27) is not found.
  • SHA-256 (with the hyphen) is a miss while sha256 hits: the hyphen splits the word and 256 is not the start of any token. SHA-256 implementation is a miss too. A miss beats a weak hit (before the last edit of this PR, SHA-256 returned shaping.t27, sha512.t27, blog-share.t27), but this is the first thing to improve.
  • A returned spec can still be a stub: specs/tri/graph/topological_sort.t27 and specs/tri/collections/priority_queue.t27 are health/ok with tests that assert only != undefined. t27_validate is the planned answer.
  • Disclosure: the "numbers are content words" fix came after the before/after measurement in the companion PR; it changes none of the 10 results there.

Companion PR (artifacts + glue): see the gHashTag/t27-mcp PR from branch claude/exciting-gauss-9cbc6e.

Refs #10066

🤖 Generated with Claude Code

…an honest miss (Refs #10066)

First step of the validated-code contract: before anything is written, look
for a spec that already answers the intent. verdict() decides per manifest
row (name, path, tags); rank_key() orders the admitted rows. A row is served
only when it covers the intent (every word up to three words, two thirds of a
longer intent, and the file name carries at least half of them), compiles
clean (health/ok) and carries tests (has/tests). Words are matched at the
start of a name or path token, so "count" is not found in "account". Below the
threshold the answer is a miss, not the nearest neighbour.

Reuses has() from t27mcp::check_hints.

Evidence (lab, t27c 0.5.2): test-report 13 of 13 pass, 0 vacuous; removing
covers() fails 7 tests, loosening the ratio fails 2, dropping the name-half
rule fails 1, matching inside a word fails 1, treating numbers as noise
fails 2; dupe_scan --like: nothing in this file is written elsewhere.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-18 04:00:37 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 49
PRs with All Checks Green 1
READY 0
FAILING 49
PENDING 0
NO CHECKS YET 0

These columns do not partition: 0 + 49 + 0 + 0 = 49, and there are 50 open PRs. A PR is being counted twice or not at all.

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=0f8c66b9ed0e != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

@gHashTag
gHashTag enabled auto-merge (squash) October 18, 2026 04:00
@gHashTag
gHashTag merged commit 2d358a7 into master Oct 18, 2026
28 of 30 checks passed
gHashTag added a commit that referenced this pull request Oct 18, 2026
…ind as pass (Closes #10212) (#10214)

#10198, #10202 and #10194 added these three specs without a row in
docs/reports/t27b_expectations.json, so t27b-native-ratchet reads
"UNLISTED 3" on master and on every open PR (run 39096977680 on
#10185): "the reference passes it and the ledger does not name it
(t27b pass)".

Adds the three rows in path order with the verdict the run measured.
No other row moves.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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