iriq 0.30.2 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/iriq/trace.rb CHANGED
@@ -31,8 +31,9 @@ module Iriq
31
31
  input: iri.canonical,
32
32
  normalized: normalized,
33
33
  scheme: iri.scheme,
34
- host: iri.host,
35
34
  }
35
+ # Fields that don't apply are omitted, not null (matches parse JSON).
36
+ out[:host] = iri.host if iri.host
36
37
  out[:port] = iri.port if iri.port
37
38
 
38
39
  if iri.urn?
@@ -84,25 +85,24 @@ module Iriq
84
85
  payload: { type: entry[:type], variable: entry[:variable], hint: entry[:hint] },
85
86
  )
86
87
 
88
+ # The canonical policy applies even when the value is already canonical
89
+ # (that's what makes the row print the value, not a placeholder); only
90
+ # the note is reserved for an actual rewrite.
87
91
  if entry[:variable]
88
92
  if entry[:type] == :date && (canon = SegmentClassifier.canonical_date(entry[:value]))
89
- if canon != entry[:value]
90
- records << Evidence.segment(
91
- index: idx, value: entry[:value],
92
- source: :policy,
93
- payload: { rule: :canonical_date, before: entry[:value], after: canon },
94
- notes: ["canonical date (#{entry[:value]} → #{canon})"],
95
- )
96
- end
93
+ records << Evidence.segment(
94
+ index: idx, value: entry[:value],
95
+ source: :policy,
96
+ payload: { rule: :canonical_date, before: entry[:value], after: canon },
97
+ notes: canon == entry[:value] ? [] : ["canonical date (#{entry[:value]} #{canon})"],
98
+ )
97
99
  elsif entry[:type] == :currency && (canon = SegmentClassifier.canonical_currency(entry[:value]))
98
- if canon != entry[:value]
99
- records << Evidence.segment(
100
- index: idx, value: entry[:value],
101
- source: :policy,
102
- payload: { rule: :canonical_currency, before: entry[:value], after: canon },
103
- notes: ["currency upcase (#{entry[:value]} → #{canon})"],
104
- )
105
- end
100
+ records << Evidence.segment(
101
+ index: idx, value: entry[:value],
102
+ source: :policy,
103
+ payload: { rule: :canonical_currency, before: entry[:value], after: canon },
104
+ notes: canon == entry[:value] ? [] : ["currency upcase (#{entry[:value]} #{canon})"],
105
+ )
106
106
  else
107
107
  extra = placeholder_decoration_evidence(entry, segments, idx, classifier, hints)
108
108
  records.concat(extra)
@@ -162,23 +162,19 @@ module Iriq
162
162
  )
163
163
 
164
164
  if effective == :date && (canon = SegmentClassifier.canonical_date(value))
165
- if canon != value
166
- records << Evidence.segment(
167
- index: name, value: value,
168
- source: :policy,
169
- payload: { rule: :canonical_date, before: value, after: canon },
170
- notes: ["canonical date (#{value} → #{canon})"],
171
- )
172
- end
165
+ records << Evidence.segment(
166
+ index: name, value: value,
167
+ source: :policy,
168
+ payload: { rule: :canonical_date, before: value, after: canon },
169
+ notes: canon == value ? [] : ["canonical date (#{value} #{canon})"],
170
+ )
173
171
  elsif effective == :currency && (canon = SegmentClassifier.canonical_currency(value))
174
- if canon != value
175
- records << Evidence.segment(
176
- index: name, value: value,
177
- source: :policy,
178
- payload: { rule: :canonical_currency, before: value, after: canon },
179
- notes: ["currency upcase (#{value} → #{canon})"],
180
- )
181
- end
172
+ records << Evidence.segment(
173
+ index: name, value: value,
174
+ source: :policy,
175
+ payload: { rule: :canonical_currency, before: value, after: canon },
176
+ notes: canon == value ? [] : ["currency upcase (#{value} #{canon})"],
177
+ )
182
178
  elsif effective == :ipv4 || effective == :ipv6
183
179
  records << Evidence.segment(
184
180
  index: name, value: value,
data/lib/iriq/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Iriq
2
- VERSION = "0.30.2"
2
+ VERSION = "0.35.0"
3
3
  end
data/lib/iriq.rb CHANGED
@@ -19,6 +19,7 @@ require "iriq/trace"
19
19
  require "iriq/cluster"
20
20
  require "iriq/clusterer"
21
21
  require "iriq/position_stats"
22
+ require "iriq/position_evidence"
22
23
  require "set"
23
24
 
24
25
  require "iriq/observation"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iriq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.30.2
4
+ version: 0.35.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Pepper
@@ -86,16 +86,10 @@ extensions: []
86
86
  extra_rdoc_files: []
87
87
  files:
88
88
  - CHANGELOG.md
89
- - CLAUDE.md
90
- - Gemfile
91
- - Gemfile.lock
92
89
  - LICENSE.txt
93
- - Makefile
94
90
  - README.md
95
91
  - completions/_iriq
96
92
  - completions/iriq.bash
97
- - docs/ARCHITECTURE.md
98
- - docs/ROADMAP.md
99
93
  - exe/iriq
100
94
  - iriq.gemspec
101
95
  - lib/iriq.rb
@@ -116,6 +110,7 @@ files:
116
110
  - lib/iriq/parser.rb
117
111
  - lib/iriq/path_shape.rb
118
112
  - lib/iriq/position.rb
113
+ - lib/iriq/position_evidence.rb
119
114
  - lib/iriq/position_stats.rb
120
115
  - lib/iriq/recognizer.rb
121
116
  - lib/iriq/recognizer_proposal.rb
@@ -153,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
148
  - !ruby/object:Gem::Version
154
149
  version: '0'
155
150
  requirements: []
156
- rubygems_version: 4.0.11
151
+ rubygems_version: 3.6.9
157
152
  specification_version: 4
158
153
  summary: IRI extraction, normalization, and clustering.
159
154
  test_files: []
data/CLAUDE.md DELETED
@@ -1,208 +0,0 @@
1
- # Iriq development conventions
2
-
3
- > **⚠️ Behavior changes touch ALL THREE runtimes.** Ruby is the reference; Go
4
- > + Rust mirror it. Before committing any change to
5
- > parser/normalizer/extractor/CLI/etc:
6
- >
7
- > 1. Update Ruby + specs.
8
- > 2. `bundle exec ruby script/generate_fixtures.rb` (regenerate JSON parity fixtures).
9
- > 3. Port the change to Go (the Go module lives in `go/`).
10
- > 4. `go -C go test ./...` — fixture tests should still pass.
11
- > 5. `make build && script/cli_parity.sh` — Ruby ↔ Go CLI parity should still pass.
12
- > 6. Port the change to Rust under `rust/`.
13
- > 7. `cd rust && cargo test --workspace` — Rust fixture tests should still pass
14
- > (SQLite is a default feature).
15
- > 8. `cd rust && cargo build --release --bin iriq && cd .. && script/rust_parity.sh`
16
- > — Rust ↔ Go CLI parity (covers Ruby transitively).
17
- > 9. Commit the regenerated fixtures alongside the code change.
18
- >
19
- > CI's parity + Rust jobs will fail if any step is skipped. The **Rust gate**
20
- > (fmt + clippy + tests) is automated — run `make hooks` once to install the
21
- > committed pre-push hook that runs `make check`. Full multi-runtime pre-push
22
- > for a behavior change:
23
- > `bundle exec rspec && go -C go test ./... && script/cli_parity.sh && make check && script/rust_parity.sh`.
24
-
25
- ## Repo layout — Ruby at the root, Go and Rust in subdirs
26
-
27
- The Ruby gem lives at the repo root (it's the reference implementation and the
28
- published gem); the two mirror implementations are compartmentalized into
29
- `go/` and `rust/`. Earlier the Go code was intermixed at the root; it now sits
30
- in `go/`, symmetric with `rust/`, so the root reads as "Ruby + two ports."
31
-
32
- ```
33
- iriq/
34
- lib/ exe/ spec/ ← Ruby gem (library, CLI, specs) — the reference
35
- completions/ ← shell-completion scripts shipped by the gem
36
- iriq.gemspec
37
- Gemfile
38
-
39
- go/ ← Go module github.com/dpep/iriq/go
40
- go.mod go.sum
41
- *.go ← Go package `iriq`
42
- cmd/iriq/ ← Go CLI binary
43
- completions/ ← Go's own embedded copy (go:embed can't reach ../)
44
-
45
- rust/ ← Cargo workspace
46
- Cargo.toml ← workspace root
47
- iriq/ ← one crate: library + `iriq` CLI binary; inlines completions
48
- REPORT.md ← Go → Rust port spike notes + perf
49
- target/ ← Rust build artifacts (gitignored)
50
-
51
- bin/ ← built Go binary (gitignored)
52
- script/ ← shared dev scripts (fixture gen, parity, benches)
53
- spec/fixtures/ ← golden JSON shared by Ruby specs + Go + Rust tests
54
- .github/workflows/ ← Ruby CI, Go CI, Rust CI, parity CIs
55
- ```
56
-
57
- Notes on this layout:
58
-
59
- - Go's import path is now `github.com/dpep/iriq/go` (the `/go` suffix matches
60
- the subdir). Consumers import `github.com/dpep/iriq/go`.
61
- - One version tag (`vX.Y.Z`) serves all three runtimes — Ruby's gemspec, Go's
62
- module, and Rust's `Cargo.toml` use the same tag stream.
63
- - The gemspec ships only Ruby + `completions/`, excluding `go/` and `rust/`:
64
- `git ls-files * ':!:spec' ':!:script' ':!:bin' ':!:rust' ':!:go'`.
65
- - Completion scripts exist in three places (gem root `completions/`, `go/completions/`
66
- for `go:embed`, and inlined in the Rust CLI) — keep them in sync like fixtures.
67
-
68
- ## Building
69
-
70
- ```sh
71
- # Ruby gem
72
- bundle install
73
- bundle exec exe/iriq --help # runs the CLI from source
74
-
75
- # Go binary — convenience targets in the Makefile
76
- make build # → ./bin/iriq
77
- make install # go install into $GOBIN
78
- make uninstall # remove from $GOBIN
79
- make clean # remove ./bin/
80
- make test # go test ./...
81
-
82
- # Rust — one crate (library + `iriq` binary), SQLite bundled by default
83
- cd rust && cargo build --release --bin iriq # → ./rust/target/release/iriq
84
- cd rust && cargo install --path iriq # install into ~/.cargo/bin
85
- cd rust && cargo test --workspace
86
-
87
- # Via Homebrew (builds the Rust CLI from main)
88
- brew install dpep/tools/iriq
89
-
90
- # Via crates.io
91
- cargo install iriq
92
- ```
93
-
94
- ## Keeping the three runtimes in sync
95
-
96
- Ruby is the **reference implementation**. Go and Rust mirror its public API
97
- and behavior. Three layers of parity testing keep them aligned:
98
-
99
- 1. **Golden JSON fixtures** (`spec/fixtures/*.json`)
100
- Generated by `script/generate_fixtures.rb` from the Ruby implementation
101
- over a curated set of inputs. Go's `fixtures_test.go` and Rust's
102
- `rust/iriq/tests/fixtures.rs` both load each file and assert the same
103
- outputs.
104
-
105
- 2. **Ruby ↔ Go CLI parity harness** (`script/cli_parity.sh`)
106
- Runs the same input through `bundle exec exe/iriq` and the Go binary and
107
- diffs stdout. Lives in CI as the `Ruby ↔ Go parity` job.
108
-
109
- 3. **Rust ↔ Go CLI parity harness** (`script/rust_parity.sh`)
110
- Same idea — runs every Phase 1 + Phase 2 scenario (single-input,
111
- pipe-mode, JSON corpus, SQLite corpus, --stats, --reinfer,
112
- --propose-recognizers, --cross-host-shapes, --host=reg) through the
113
- Go and Rust binaries and diffs stdout. Lives in CI as the
114
- `Rust ↔ Go parity` job. Rust transitively inherits Ruby parity via Go.
115
-
116
- When changing behavior:
117
-
118
- 1. Update the Ruby code + specs first.
119
- 2. Regenerate fixtures: `bundle exec ruby script/generate_fixtures.rb`.
120
- 3. Port the change to Go.
121
- 4. `go test ./...` (uses the updated fixtures).
122
- 5. `script/cli_parity.sh` should pass.
123
- 6. Port the change to Rust under `rust/`.
124
- 7. `cd rust && cargo test --workspace`.
125
- 8. `cd rust && cargo build --release --bin iriq && cd .. && script/rust_parity.sh` should pass.
126
- 9. Commit fixtures with the change — CI will fail if they're stale.
127
-
128
- ## Tests
129
-
130
- ```sh
131
- bundle exec rspec # Ruby suite (305+ examples)
132
- go test ./... # Go suite (native + fixture parity)
133
- script/cli_parity.sh # Ruby ↔ Go CLI parity
134
- cd rust && cargo test --workspace
135
- cd rust && cargo fmt --check # formatting (CI-gated)
136
- cd rust && cargo clippy --workspace --all-targets -- -D warnings
137
- make check # the three Rust checks above, in one shot
138
- script/rust_parity.sh # Rust ↔ Go CLI parity (~59 scenarios)
139
- ```
140
-
141
- ## Releases
142
-
143
- Versioning is single-stream: one `vX.Y.Z` covers all three runtimes. Bump the
144
- three version constants **together** — the `--version` parity checks fail
145
- if they drift:
146
-
147
- 1. `lib/iriq/version.rb` (`VERSION`), `go/version.go` (`Version`), and the two
148
- `version = "X.Y.Z"` / `pub const VERSION` lines in `rust/iriq/Cargo.toml` and
149
- `rust/iriq/src/lib.rs` — same string.
150
- 2. `Gemfile.lock` — re-resolve so the pinned `iriq (X.Y.Z)` matches
151
- (`bundle install`, or it regenerates on the next `bundle exec`). Commit it.
152
- 3. Run `cd rust && cargo update -p iriq` to refresh `Cargo.lock`.
153
- 4. Tag `vX.Y.Z` and push. Go consumers pick it up via
154
- `go get github.com/dpep/iriq/go@vX.Y.Z`.
155
- 5. `gem push iriq-X.Y.Z.gem` to publish to RubyGems.
156
- 6. `cd rust && cargo publish -p iriq` to publish to crates.io (the crate ships
157
- both the library and the `iriq` binary).
158
-
159
- ### Keep Homebrew in sync — bump on EVERY version change
160
-
161
- The tap (`~/code/lib/homebrew-tools`) ships a single `Formula/iriq.rb` that
162
- builds the Rust CLI (`cargo install --path rust/iriq`) from `branch: "main"`.
163
- SQLite is on by default (the `iriq` crate's `default` feature set), so there is
164
- no longer a separate `iriq-sqlite` formula.
165
-
166
- The formula pins a static `version "X.Y.Z"` label. Because the build tracks
167
- `main` rather than a tagged tarball, `brew upgrade` only rebuilds when that
168
- label changes. So on every bump here, update the `version` string in
169
- `Formula/iriq.rb` to match `version.rb`, then commit + push the tap. Leaving it
170
- stale means brew users never get the new code even though it's already on `main`.
171
-
172
- ## Corpus storage backends
173
-
174
- The `Corpus` class delegates state to a `Storage` backend; three backends ship:
175
-
176
- - **Memory** — default, in-process only.
177
- - **JSON** — Memory wrapped with atomic load/save against a JSON file
178
- (`.json` by default). Same shape both runtimes have always written.
179
- - **SQLite** — incremental UPSERTs against a `.db` / `.sqlite` / `.sqlite3`
180
- file with WAL journaling. Supports concurrent observers and avoids
181
- loading the whole corpus into memory.
182
-
183
- `Corpus.open(path)` (Ruby) / `iriq.OpenCorpus(path)` (Go) picks the backend
184
- by file extension. `corpus.save(other_path)` exports as JSON regardless of
185
- the live backend; `corpus.save(same_path)` is idempotent (no clobbering a
186
- SQLite file with JSON, etc.).
187
-
188
- The Ruby `sqlite3` gem is loaded lazily (only when a `.db` path is opened),
189
- keeping the iriq install footprint minimal for users that stick with JSON.
190
- On the Go side we use `modernc.org/sqlite` (pure Go — no cgo). The Rust
191
- side uses `rusqlite` with the `bundled` feature (statically links C SQLite,
192
- ~3-4 MB binary cost). Schema v4 is shared across all three runtimes — a
193
- `.db` written by any binary opens cleanly in any other.
194
-
195
- When adding a new backend, replicate the contract in all three languages
196
- and add parity scenarios in `script/cli_parity.sh`'s `corpus_pair`
197
- section + `script/rust_parity.sh`'s `corpus_pair`.
198
-
199
- ## What lives where in scripts
200
-
201
- - `script/benchmark.rb` — Ruby-only throughput benchmark.
202
- - `script/memory.rb` — Ruby-only memory profile.
203
- - `script/generate_fixtures.rb` — produces `spec/fixtures/*.json` for cross-runtime parity.
204
- - `script/cli_parity.sh` — Ruby ↔ Go CLI diff.
205
- - `script/rust_parity.sh` — Rust ↔ Go CLI diff.
206
- - `script/bench_three_way.sh` — Go vs Rust wall-clock comparison.
207
- - `script/bench_compare.sh` — Ruby vs Go CLI wall-time comparison.
208
- - `script/bench_storage.sh` — JSON vs SQLite backend timing (single-process, incremental, concurrent).
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
data/Gemfile.lock DELETED
@@ -1,103 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- iriq (0.30.2)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- date (3.5.1)
10
- debug (1.11.1)
11
- irb (~> 1.10)
12
- reline (>= 0.3.8)
13
- diff-lcs (1.6.2)
14
- docile (1.4.1)
15
- erb (6.0.4)
16
- io-console (0.8.2)
17
- irb (1.17.0)
18
- pp (>= 0.6.0)
19
- prism (>= 1.3.0)
20
- rdoc (>= 4.0.0)
21
- reline (>= 0.4.2)
22
- mini_portile2 (2.8.9)
23
- pp (0.6.3)
24
- prettyprint
25
- prettyprint (0.2.0)
26
- prism (1.9.0)
27
- psych (5.3.1)
28
- date
29
- stringio
30
- rdoc (7.2.0)
31
- erb
32
- psych (>= 4.0.0)
33
- tsort
34
- reline (0.6.3)
35
- io-console (~> 0.5)
36
- rspec (3.13.2)
37
- rspec-core (~> 3.13.0)
38
- rspec-expectations (~> 3.13.0)
39
- rspec-mocks (~> 3.13.0)
40
- rspec-core (3.13.6)
41
- rspec-support (~> 3.13.0)
42
- rspec-debugging (0.0.4)
43
- rspec-expectations (>= 3)
44
- rspec-expectations (3.13.5)
45
- diff-lcs (>= 1.2.0, < 2.0)
46
- rspec-support (~> 3.13.0)
47
- rspec-mocks (3.13.8)
48
- diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.13.0)
50
- rspec-support (3.13.7)
51
- simplecov (0.22.0)
52
- docile (~> 1.1)
53
- simplecov-html (~> 0.11)
54
- simplecov_json_formatter (~> 0.1)
55
- simplecov-html (0.13.2)
56
- simplecov_json_formatter (0.1.4)
57
- sqlite3 (2.9.5)
58
- mini_portile2 (~> 2.8.0)
59
- stringio (3.2.0)
60
- tsort (0.2.0)
61
-
62
- PLATFORMS
63
- ruby
64
-
65
- DEPENDENCIES
66
- debug (>= 1)
67
- iriq!
68
- rspec (>= 3.10)
69
- rspec-debugging
70
- simplecov (>= 0.22)
71
- sqlite3 (>= 1.6)
72
-
73
- CHECKSUMS
74
- date (3.5.1) sha256=750d06384d7b9c15d562c76291407d89e368dda4d4fff957eb94962d325a0dc0
75
- debug (1.11.1) sha256=2e0b0ac6119f2207a6f8ac7d4a73ca8eb4e440f64da0a3136c30343146e952b6
76
- diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962
77
- docile (1.4.1) sha256=96159be799bfa73cdb721b840e9802126e4e03dfc26863db73647204c727f21e
78
- erb (6.0.4) sha256=38e3803694be357fe2bfe312487c74beaf9fb4e5beb3e22498952fe1645b95d9
79
- io-console (0.8.2) sha256=d6e3ae7a7cc7574f4b8893b4fca2162e57a825b223a177b7afa236c5ef9814cc
80
- irb (1.17.0) sha256=168c4ddb93d8a361a045c41d92b2952c7a118fa73f23fe14e55609eb7a863aae
81
- iriq (0.30.2)
82
- mini_portile2 (2.8.9) sha256=0cd7c7f824e010c072e33f68bc02d85a00aeb6fce05bb4819c03dfd3c140c289
83
- pp (0.6.3) sha256=2951d514450b93ccfeb1df7d021cae0da16e0a7f95ee1e2273719669d0ab9df6
84
- prettyprint (0.2.0) sha256=2bc9e15581a94742064a3cc8b0fb9d45aae3d03a1baa6ef80922627a0766f193
85
- prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85
86
- psych (5.3.1) sha256=eb7a57cef10c9d70173ff74e739d843ac3b2c019a003de48447b2963d81b1974
87
- rdoc (7.2.0) sha256=8650f76cd4009c3b54955eb5d7e3a075c60a57276766ebf36f9085e8c9f23192
88
- reline (0.6.3) sha256=1198b04973565b36ec0f11542ab3f5cfeeec34823f4e54cebde90968092b1835
89
- rspec (3.13.2) sha256=206284a08ad798e61f86d7ca3e376718d52c0bc944626b2349266f239f820587
90
- rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d
91
- rspec-debugging (0.0.4) sha256=7a8e2dc240c140f0ed27b452a5661a56474ee8cf7b84c5bcbefd827ad36f0a6f
92
- rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836
93
- rspec-mocks (3.13.8) sha256=086ad3d3d17533f4237643de0b5c42f04b66348c28bf6b9c2d3f4a3b01af1d47
94
- rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c
95
- simplecov (0.22.0) sha256=fe2622c7834ff23b98066bb0a854284b2729a569ac659f82621fc22ef36213a5
96
- simplecov-html (0.13.2) sha256=bd0b8e54e7c2d7685927e8d6286466359b6f16b18cb0df47b508e8d73c777246
97
- simplecov_json_formatter (0.1.4) sha256=529418fbe8de1713ac2b2d612aa3daa56d316975d307244399fa4838c601b428
98
- sqlite3 (2.9.5) sha256=04572973a3f943ad50a8adfffc8dd752a5f06e4c3db2026f71838fed8a982606
99
- stringio (3.2.0) sha256=c37cb2e58b4ffbd33fe5cd948c05934af997b36e0b6ca6fdf43afa234cf222e1
100
- tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f
101
-
102
- BUNDLED WITH
103
- 4.0.9
data/Makefile DELETED
@@ -1,113 +0,0 @@
1
- # Iriq Go binary — build/install/clean/uninstall helpers.
2
- #
3
- # make - same as `make help`
4
- # make build - dev build into ./bin/iriq (no SQLite, debug info)
5
- # make build-sqlite - dev build with SQLite backend included
6
- # make release - stripped + trimpath build (no SQLite)
7
- # make release-sqlite - stripped + trimpath build with SQLite
8
- # make install - go install into $GOBIN
9
- # make test - go test ./... (both tag states)
10
- # make clean - remove ./bin/
11
- # make uninstall - remove the binary from $GOBIN
12
- #
13
- # The default build excludes the SQLite backend to keep the binary lean.
14
- # Pass `-tags sqlite` (or use the *-sqlite targets) to compile it in. The
15
- # CLI's `--version` output tells you which backends are baked in.
16
- #
17
- # Ruby gem build/install is handled by Bundler/RubyGems; see CLAUDE.md.
18
-
19
- GO ?= go
20
- GO_DIR := go
21
- BIN_DIR := bin
22
- BIN := $(BIN_DIR)/iriq
23
- # Absolute output path: builds run inside $(GO_DIR) via `go -C`, so a
24
- # relative -o would land under go/. Keep the binary at the repo-root bin/.
25
- ABS_BIN := $(CURDIR)/$(BIN)
26
- PKG := ./cmd/iriq
27
-
28
- # Rust crate lives under rust/; CI gates fmt + clippy + tests there.
29
- CARGO ?= cargo
30
- RUST_DIR := rust
31
-
32
- # Release flags strip the symbol table (-s), debug info (-w), and bake
33
- # reproducible paths (-trimpath). Drops binary size ~30% with no
34
- # functional impact; stack-trace function names are gone but file:line
35
- # resolution still works.
36
- RELEASE_FLAGS := -ldflags "-s -w" -trimpath
37
-
38
- # Resolve $GOBIN, falling back to $GOPATH/bin (Go's default install location).
39
- GOBIN := $(shell $(GO) env GOBIN)
40
- ifeq ($(GOBIN),)
41
- GOBIN := $(shell $(GO) env GOPATH)/bin
42
- endif
43
- INSTALLED := $(GOBIN)/iriq
44
-
45
- .DEFAULT_GOAL := help
46
- .PHONY: help build build-sqlite release release-sqlite install test clean uninstall check fmt hooks
47
-
48
- help:
49
- @echo "Iriq Go targets:"
50
- @echo " make build slim dev build into $(BIN)"
51
- @echo " make build-sqlite dev build with SQLite backend"
52
- @echo " make release stripped slim build into $(BIN)"
53
- @echo " make release-sqlite stripped build with SQLite backend"
54
- @echo " make install go install into $(GOBIN)"
55
- @echo " make test run go test ./... in both tag states"
56
- @echo " make check Rust gate: cargo fmt --check + clippy + test (run before merging)"
57
- @echo " make fmt cargo fmt the Rust crate"
58
- @echo " make hooks enable the committed git hooks (pre-push runs 'make check')"
59
- @echo " make clean remove $(BIN_DIR)/"
60
- @echo " make uninstall remove $(INSTALLED)"
61
-
62
- build:
63
- @mkdir -p $(BIN_DIR)
64
- $(GO) -C $(GO_DIR) build -o $(ABS_BIN) $(PKG)
65
- @echo "built $(BIN) (slim, debug)"
66
-
67
- build-sqlite:
68
- @mkdir -p $(BIN_DIR)
69
- $(GO) -C $(GO_DIR) build -tags sqlite -o $(ABS_BIN) $(PKG)
70
- @echo "built $(BIN) (sqlite, debug)"
71
-
72
- release:
73
- @mkdir -p $(BIN_DIR)
74
- $(GO) -C $(GO_DIR) build $(RELEASE_FLAGS) -o $(ABS_BIN) $(PKG)
75
- @echo "built $(BIN) (slim, stripped)"
76
-
77
- release-sqlite:
78
- @mkdir -p $(BIN_DIR)
79
- $(GO) -C $(GO_DIR) build -tags sqlite $(RELEASE_FLAGS) -o $(ABS_BIN) $(PKG)
80
- @echo "built $(BIN) (sqlite, stripped)"
81
-
82
- install:
83
- $(GO) -C $(GO_DIR) install $(PKG)
84
- @echo "installed $(INSTALLED)"
85
-
86
- test:
87
- $(GO) -C $(GO_DIR) test ./...
88
- $(GO) -C $(GO_DIR) test -tags sqlite ./...
89
-
90
- # The Rust gate — mirrors CI's Rust job. Run before merging/pushing (the
91
- # pre-push hook runs this for you once `make hooks` is enabled).
92
- check:
93
- cd $(RUST_DIR) && $(CARGO) fmt --check
94
- cd $(RUST_DIR) && $(CARGO) clippy --workspace --all-targets -- -D warnings
95
- cd $(RUST_DIR) && $(CARGO) test --workspace
96
-
97
- fmt:
98
- cd $(RUST_DIR) && $(CARGO) fmt
99
-
100
- hooks:
101
- git config core.hooksPath .githooks
102
- @echo "git hooks enabled (.githooks) — pre-push now runs 'make check'"
103
-
104
- clean:
105
- rm -rf $(BIN_DIR)
106
- @echo "removed $(BIN_DIR)/"
107
-
108
- uninstall:
109
- @if [ -f "$(INSTALLED)" ]; then \
110
- rm "$(INSTALLED)" && echo "removed $(INSTALLED)"; \
111
- else \
112
- echo "not installed at $(INSTALLED)"; \
113
- fi