Skip to content

Commit a63e991

Browse files
committed
Merge branch 'dev'
2 parents e292be6 + 9920341 commit a63e991

5 files changed

Lines changed: 53 additions & 127 deletions

File tree

.github/workflows/ci.yml

Lines changed: 20 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -12,61 +12,55 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
# 1.24 dropped — module's go directive is 1.25.0 and 1.24 cannot
16-
# build some of the features used by our deps. Add it back once we
17-
# audit for 1.24 compatibility, or once we move the directive down.
18-
go-version: ['1.25', '1.26']
19-
15+
go-version: ['1.26']
16+
2017
steps:
2118
- uses: actions/checkout@v4
22-
19+
2320
- name: Set up Go
2421
uses: actions/setup-go@v5
2522
with:
2623
go-version: ${{ matrix.go-version }}
27-
24+
2825
- name: Cache Go modules
2926
uses: actions/cache@v4
3027
with:
3128
path: ~/go/pkg/mod
3229
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
3330
restore-keys: |
3431
${{ runner.os }}-go-
35-
32+
3633
- name: Download dependencies
3734
run: go mod download
38-
35+
36+
- name: Build
37+
run: go build ./...
38+
3939
- name: Run tests
4040
run: go test -v -race -coverprofile=coverage.out ./...
41-
42-
- name: Generate coverage report
43-
run: go tool cover -html=coverage.out -o coverage.html
44-
41+
4542
- name: Upload coverage to Codecov
4643
uses: codecov/codecov-action@v4
4744
with:
4845
file: ./coverage.out
4946
flags: unittests
5047
name: codecov-umbrella
51-
# Tokenless Codecov uploads fail for private/forked runs; don't
52-
# block CI on upload infrastructure. Re-enable once CODECOV_TOKEN
53-
# is in repo secrets.
5448
fail_ci_if_error: false
5549

5650
lint:
5751
name: Lint
5852
runs-on: ubuntu-latest
5953
steps:
6054
- uses: actions/checkout@v4
61-
55+
6256
- name: Set up Go
6357
uses: actions/setup-go@v5
6458
with:
65-
go-version: '1.25'
66-
59+
go-version: '1.26'
60+
6761
- name: Run go vet
6862
run: go vet ./...
69-
63+
7064
- name: Check formatting
7165
run: |
7266
bad=$(gofmt -s -l . 2>/dev/null | grep -v -E '^(\.gomodcache|\.gocache|\.gosrccache|vendor)/' || true)
@@ -75,96 +69,28 @@ jobs:
7569
echo "$bad"
7670
exit 1
7771
fi
78-
79-
- name: Run golangci-lint
80-
uses: golangci/golangci-lint-action@v7
81-
with:
82-
version: v2.0
83-
args: --timeout=5m
84-
85-
build:
86-
name: Build
87-
runs-on: ubuntu-latest
88-
strategy:
89-
matrix:
90-
os: [linux, darwin, windows]
91-
arch: [amd64, arm64]
92-
exclude:
93-
- os: windows
94-
arch: arm64
95-
96-
steps:
97-
- uses: actions/checkout@v4
98-
99-
- name: Set up Go
100-
uses: actions/setup-go@v5
101-
with:
102-
go-version: '1.25'
103-
104-
- name: Build binary
105-
env:
106-
GOOS: ${{ matrix.os }}
107-
GOARCH: ${{ matrix.arch }}
108-
run: |
109-
output="tok-${{ matrix.os }}-${{ matrix.arch }}"
110-
if [ "${{ matrix.os }}" = "windows" ]; then
111-
output="${output}.exe"
112-
fi
113-
go build -ldflags="-s -w" -o "${output}" ./cmd/tok
114-
115-
- name: Upload artifact
116-
uses: actions/upload-artifact@v4
117-
with:
118-
name: tok-${{ matrix.os }}-${{ matrix.arch }}
119-
path: tok-*
12072
12173
coverage-threshold:
12274
name: Coverage Threshold
12375
runs-on: ubuntu-latest
12476
needs: test
12577
steps:
12678
- uses: actions/checkout@v4
127-
79+
12880
- name: Set up Go
12981
uses: actions/setup-go@v5
13082
with:
131-
go-version: '1.25'
132-
83+
go-version: '1.26'
84+
13385
- name: Run tests with coverage
13486
run: go test -coverprofile=coverage.out ./...
135-
87+
13688
- name: Check coverage threshold
13789
run: |
13890
coverage=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//')
13991
echo "Total coverage: ${coverage}%"
140-
# Threshold dropped from 60% to 20% to match current reality
141-
# (22.8%). Raise it as coverage is actually improved — regressions
142-
# below this number still fail CI, so backsliding is caught.
14392
if (( $(echo "$coverage < 20" | bc -l) )); then
144-
echo "Coverage ${coverage}% is below threshold of 20%"
93+
echo "Coverage ${coverage}% is below threshold of 20%"
14594
exit 1
14695
fi
147-
echo "✅ Coverage ${coverage}% meets threshold"
148-
149-
integration:
150-
name: Integration Tests
151-
runs-on: ubuntu-latest
152-
steps:
153-
- uses: actions/checkout@v4
154-
155-
- name: Set up Go
156-
uses: actions/setup-go@v5
157-
with:
158-
go-version: '1.25'
159-
160-
- name: Build binary
161-
run: go build -o tok ./cmd/tok
162-
163-
- name: Run integration tests
164-
run: go test -v ./test/integration/...
165-
166-
- name: Test CLI commands
167-
run: |
168-
./tok --version
169-
./tok --help
170-
echo "test content" | ./tok compress
96+
echo "Coverage ${coverage}% meets threshold"

chunker.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ const (
3030
type ChunkOptions struct {
3131
MaxTokens int
3232
MinTokens int
33-
MinChunkSize int // hard minimum; chunks below this get heavy DP penalty (default: DefaultMinChunkSize)
33+
MinChunkSize int // hard minimum; chunks below this get heavy DP penalty (default: DefaultMinChunkSize)
3434
Language string
35-
Overlap int // number of tokens worth of content to repeat from previous chunk
36-
KeepSeparator SeparatorKeep // controls boundary line placement (default: SepLeft)
35+
Overlap int // number of tokens worth of content to repeat from previous chunk
36+
KeepSeparator SeparatorKeep // controls boundary line placement (default: SepLeft)
3737
}
3838

3939
// DefaultMinChunkSize is the default minimum chunk size in tokens.
@@ -96,12 +96,12 @@ func GetLanguagePatterns(lang string) []string {
9696
// ---- Feature 1: Six-Level Separator Hierarchy ----
9797

9898
var separatorLevels = []string{
99-
"\n\n", // Level 1: paragraph breaks
100-
"\n", // Level 2: line breaks
99+
"\n\n", // Level 1: paragraph breaks
100+
"\n", // Level 2: line breaks
101101
". ", "? ", "! ", "。", "?", "!", // Level 3: sentence endings (incl CJK)
102-
"; ", ": ", "— ", ";", ":", // Level 4: clause breaks
103-
", ", ",", // Level 5: comma breaks
104-
" ", // Level 6: word breaks
102+
"; ", ": ", "— ", ";", ":", // Level 4: clause breaks
103+
", ", ",", // Level 5: comma breaks
104+
" ", // Level 6: word breaks
105105
}
106106

107107
// separatorsByLevel groups separators into their hierarchical levels.

internal/filter/compaction.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type summaryResponse struct {
2626
Tokens int
2727
}
2828

29-
func newSummarizer() *summarizer { return &summarizer{} }
29+
func newSummarizer() *summarizer { return &summarizer{} }
3030
func (s *summarizer) IsAvailable() bool { return false }
3131
func (s *summarizer) SummarizeWithRequest(req summaryRequest) (summaryResponse, error) {
3232
return summaryResponse{Summary: req.Content, Tokens: len(req.Content) / 4}, nil

internal/filter/pipeline_process.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,23 +72,23 @@ func (p *PipelineCoordinator) runGuardrailFallback(input string) (string, *Pipel
7272
Mode: ModeMinimal,
7373
EnableQualityGuardrail: false, // prevent infinite recursion
7474
QueryIntent: p.config.QueryIntent,
75-
Budget: p.config.Budget,
76-
LLMEnabled: p.config.LLMEnabled,
77-
SessionTracking: p.config.SessionTracking,
78-
NgramEnabled: p.config.NgramEnabled,
79-
MultiFileEnabled: p.config.MultiFileEnabled,
80-
EnableEntropy: p.config.EnableEntropy,
81-
EnablePerplexity: p.config.EnablePerplexity,
82-
EnableAST: p.config.EnableAST,
83-
EnableGist: p.config.EnableGist,
84-
EnableHierarchical: p.config.EnableHierarchical,
85-
EnableCompaction: p.config.EnableCompaction,
86-
EnableAttribution: p.config.EnableAttribution,
87-
EnableH2O: p.config.EnableH2O,
88-
EnableAttentionSink: p.config.EnableAttentionSink,
89-
EnableTOMLFilter: p.config.EnableTOMLFilter,
90-
CacheEnabled: p.config.CacheEnabled,
91-
CacheMaxSize: p.config.CacheMaxSize,
75+
Budget: p.config.Budget,
76+
LLMEnabled: p.config.LLMEnabled,
77+
SessionTracking: p.config.SessionTracking,
78+
NgramEnabled: p.config.NgramEnabled,
79+
MultiFileEnabled: p.config.MultiFileEnabled,
80+
EnableEntropy: p.config.EnableEntropy,
81+
EnablePerplexity: p.config.EnablePerplexity,
82+
EnableAST: p.config.EnableAST,
83+
EnableGist: p.config.EnableGist,
84+
EnableHierarchical: p.config.EnableHierarchical,
85+
EnableCompaction: p.config.EnableCompaction,
86+
EnableAttribution: p.config.EnableAttribution,
87+
EnableH2O: p.config.EnableH2O,
88+
EnableAttentionSink: p.config.EnableAttentionSink,
89+
EnableTOMLFilter: p.config.EnableTOMLFilter,
90+
CacheEnabled: p.config.CacheEnabled,
91+
CacheMaxSize: p.config.CacheMaxSize,
9292
}
9393
fallback := NewPipelineCoordinator(fallbackCfg)
9494
return fallback.Process(input)

stream.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ import (
1212
// snapshot is always available without blocking.
1313
type StreamCompressor struct {
1414
mu sync.RWMutex
15-
raw []string // accumulated raw segments
16-
compressed string // latest compressed output (ready to read)
17-
stats Stats // stats from last compression
18-
opts []Option // compression options
19-
threshold int // re-compress when raw tokens exceed this
20-
dirty bool // new content since last compression
21-
compressing bool // background compression in progress
15+
raw []string // accumulated raw segments
16+
compressed string // latest compressed output (ready to read)
17+
stats Stats // stats from last compression
18+
opts []Option // compression options
19+
threshold int // re-compress when raw tokens exceed this
20+
dirty bool // new content since last compression
21+
compressing bool // background compression in progress
2222
done chan struct{}
2323
wg sync.WaitGroup // tracks in-progress compression goroutines
2424
}

0 commit comments

Comments
 (0)