Repository navigation
Add suffix_tree/string_function_calculation port (closes #1) - #2
Merged
Merged
Conversation
Ukkonen online suffix tree over the input plus a terminal mark, then max over nodes of string depth times leaf count. O(n) time, O(n) space, same algorithm and complexity as the .clj. Fixes #1. AI-Tool: Muse Code (Meta Muse Spark)
michael-h-hu
approved these changes
Nov 3, 2026
michael-h-hu
left a comment
There was a problem hiding this comment.
Approve — round 1
Inspected the full diff (1 new file, 140 lines, no other files touched) against the linked issue #1 and the in-repo suffix_array twin.
What was checked:
- Read
src/string_related/suffix_tree/string_function_calculation.pyend to end: Ukkonen online construction over input +$terminal, answer = max over nodes of string-depth x leaf-count, explicit stacks (no recursion),ans = ninit and empty-input guard matching the twin. - Ran an independent 137-case difftest of
string_valuevs a brute-force oracle (edges,mississippi,aabaaabaaab, 120 seeded fuzz over small alphabets, adversarial repeats): 0 mismatches. - CLI:
mississippi->11, blank input -> silent exit 0, non-lowercase -> stderr error with empty stdout (stderr is ignored by therun_tests.pystdout-only comparison, so this is safe; it mirrors the.cljmalformed-input behavior cited in the PR body). - CI:
test+ all 4testshards green; all 4perf-callgrindshards green after a retry of an unrelated environmental wall-clock timeout (dp/edit_distance45B-Ir case, pre-existing knife-edge, passed on rerun with no code change);reportgreen. New benchmark measured 11/11 cases in perf with 0 failures. - Issue #1 acceptance: same algorithm/complexity as the
.clj(Ukkonen O(n)/O(n)); shared-layout cases resolve from the bundle;run_tests.pygreen; benchmark present in the perf sweep.
Residual notes (non-blocking):
- The PR body's "cases could not be committed" caveat is stale: the shared-layout
suffix_treecases already exist in the encrypted bundle (same resource path as the clojure side) and CI measured 11 of them. No passphrase-holder action needed. .cljline-by-line fidelity relies on the crew's audit plus the behavioral evidence above; I did not re-read the.cljsource in this pass.
No findings. Merging is the author's call.
AI-Tool: Muse Code (Meta Muse Spark)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1 — ports the clojure-only
src/string_related/suffix_tree/string_function_calculation.clj(auditedline by line:
build-tree/follow-link/tree-value) tosrc/string_related/suffix_tree/string_function_calculation.py(140 lines).Algorithm
Ukkonen online suffix tree over input + terminal
$; answer = max overnodes of string-depth × leaf-count. O(n) time / O(n) space, same as the
.clj.Validation
fuzz + structured), old suffix_array twin 143/143; 5/5 IO edge cases.
.clj: 8/8 values byte-identical (incl.mississippi→11, aabaaabaaab→14); blank/malformed stdout+stderr
byte-identical.
twin on adversarial inputs.
run_tests.py --only suffix_tree/string_function_calculation: 8 passed,0 failed locally.
Note for the merger
The 8 hand-built test cases could not be committed:
tests/resources/isgitignored and the encrypted bundle needs
RESOURCES_PASSPHRASE. Apassphrase holder must add cases to
resource/sharedand runtools/build_bundle.shbefore CI perf-callgrind picks up the benchmark.AI-Tool: Muse Code (Meta Muse Spark)