tork-governance 0.1.0 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66f973f8bfa19b713628ce8bb3942b67fba1bbdf6a138c55ec56060ffb2e0c2e
4
- data.tar.gz: 4f9d8086d72580bac59d31397cb62d5ce21a3ca053f6b54ba9b4df69d73a410a
3
+ metadata.gz: 963fab3e6129b3371a40e11682ea3d87832a0040b360175046fb702dae7e31d8
4
+ data.tar.gz: 6e9fd5e7cca5c8c54587246ecd3aecdab617968178b158e3ed0f548ca034cebf
5
5
  SHA512:
6
- metadata.gz: fc1120abb85021b2e921f577925e469a6b4a6daa69389136ab96be1720e99f715977bc8041277b3931c0d109d19c2f107ea2c81ee0b4fe0af3e1e2ae0197552e
7
- data.tar.gz: 967c1f7abdfdf9274c994487921de2e314fef6dcdaf7849164d5b72a99191138e099e17967b8b6085b03ec6882b29aaa676f11e8cc56469aa0e24d35008c3c1e
6
+ metadata.gz: 0e52006b757b95ee64813d40e572a1f46de079af72e71735a76ac93a515abd6a6afc12f72ba4e8ae45eb45ca06c62fbbc8ff556a51f725b8c164ba00c79467ed
7
+ data.tar.gz: 4fba63c3b41717c4d45c4c1553c899bab508168223ae8cf6963a31da4558dfeb0f94f973cec45b69ec4b9ddff30c4b6a744d74fd556e1e581b58440e67b90114
data/CHANGELOG.md ADDED
@@ -0,0 +1,107 @@
1
+ # Changelog
2
+
3
+ ## 0.4.0 - 2026-09-25
4
+
5
+ ### Added
6
+ - **PII registry bundle 1.2.0 (24 countries, incl. AU TFN/ABN/Medicare).**
7
+ - **The country layer: 24 country profiles, 54 patterns, 20 check digits.**
8
+ Patterns, keywords, redaction labels and checksum gates are generated from
9
+ Tork's own country registry and consumed verbatim from the SDK bundle
10
+ (`Registry-Version: 1.2.0`, content `cfd4f61ebaf45e74`). Countries: AU, US, GB, EU, AE, SA, NG, IN, JP,
11
+ CN, KR, BR, CA, ZA, GH, IT, KE, MU, MX, MY, PK, SG, TH, ID.
12
+ - **Rule 1a: `au_tfn`, `au_abn` and `au_medicare` now run on every document,**
13
+ not just when Australia activates -- the ABN's own corpus sentence
14
+ activates no region at all. `au_tfn` and `au_abn` gate on a required
15
+ checksum (a failing TFN falls back to a generic near-miss redaction; a
16
+ failing ABN simply does not match); `au_medicare`'s checksum is advisory
17
+ only and never blocks a match. Closes the bundle 1.1.0 gap where
18
+ `checksums.json` named these three but `patterns` shipped none of them.
19
+ - New namespace `Tork::Governance::Pii`: `PATTERNS` (the bundle's 54 patterns),
20
+ `SIGNALS` and `COUNTRY_PATTERNS` (the 51 activation signals and the country
21
+ map), `Checksums` (20 algorithms) and `Country` (the matcher). All pure and
22
+ local: no network, no clock.
23
+ - `PIIResult` gains `country_matches`, `country_labels` and `regions`, all
24
+ defaulting to empty so existing construction still works.
25
+ `PIIDetector.detect(text, regions)` forces a set of country profiles on; the
26
+ single-argument form is unchanged.
27
+ - **Nine check digits ported by hand.** The bundle names twenty algorithms and
28
+ specifies the eleven that reduce to a weight vector and a modulus; the other
29
+ nine (`br_cpf`, `br_cnpj`, `cn_resident_id`, `de_steuer_id`, `fr_nir`,
30
+ `it_codice_fiscale`, `jp_my_number`, `kr_rrn`, `sg_nric`) are ported from the
31
+ cloud's `lib/pii/checksums.ts`, each tested against the issuing authority's
32
+ own worked example where one is published.
33
+
34
+ ### Fixed
35
+ - **SDK-RUBY-PARTIAL-REDACTION.** Until 0.3.0 each type was redacted with its
36
+ own `gsub` over text a previous type had already rewritten, while `matches`
37
+ carried indices into the *original* text. Two types matching overlapping
38
+ spans could leave half an identifier standing beside a redaction token --
39
+ digits exposed in output the caller had been told was redacted. Every match
40
+ is now collected against the original text, overlaps are resolved before
41
+ anything is rewritten, and the surviving spans are spliced right to left in
42
+ one pass. `no partial redaction` asserts the invariant across all 268
43
+ vectors.
44
+ - **The gemspec read the wrong version constant.** `tork-governance.gemspec`
45
+ took `spec.version` from `lib/tork/version.rb` -- `Tork::VERSION`, which
46
+ belongs to the separate `Tork` API client that also lives in this repository.
47
+ It now reads `TorkGovernance::VERSION` from
48
+ `lib/tork_governance/version.rb`. The two happened to agree; nothing kept
49
+ them in step, so a bump to one would have shipped the other's number.
50
+
51
+ ### Notes
52
+ - This release folds in 0.3.0, which is in this repository but was never
53
+ published to RubyGems (RubyGems is at 0.2.0).
54
+ - **`bundle exec rspec` does not run green, for a reason that predates this
55
+ release and is untouched by it.** `spec/tork_spec.rb` covers the separate
56
+ `Tork` API client and needs a `stub_tork_request` helper that exists nowhere
57
+ in the repository, and `spec/spec_helper.rb` never requires `lib/tork`, so
58
+ the whole run aborts with "uninitialized constant Tork" before any example.
59
+ The governance suite -- `spec/tork_governance_spec.rb`,
60
+ `spec/pii_type_parity_spec.rb`, `spec/tool_result_scan_spec.rb` and the new
61
+ `spec/pii_country_spec.rb` -- runs green at 464 examples, 0 failures. Fixing
62
+ the orphaned spec means adding the missing helper (WebMock is already a
63
+ development dependency) and is a separate piece of work.
64
+ - **`PIIMatch#value` still carries the RAW matched value here**, where every
65
+ other Tork SDK stores the literal `"[REDACTED]"` so a caller cannot log the
66
+ sensitive value straight out of a detection result. It is asserted by
67
+ `spec/tork_governance_spec.rb:166`, so changing it is a deliberate breaking
68
+ change rather than something to slip into a minor. Flagged, not changed.
69
+ - **The bundle now states the whole contract, and this SDK implements it.**
70
+ Bundle 1.0.0's README documented three rules; measured against the cloud's
71
+ golden snapshot they disagreed with it on 14 of 86 country-corpus cases, so
72
+ this SDK carried two more of its own. Bundle **1.1.0 documents seven**, marks
73
+ each SDK or cloud-only, and ships the data all seven need in every language
74
+ file -- the activation signals, the country map, the asymmetric 60/40 window,
75
+ the symmetric 60 context window, the whole-word vocabulary, the near-miss
76
+ policy, the table constants and the reference labels. So the locally generated
77
+ activation layer is **deleted**, no window is hard-coded any more, and rules 6
78
+ (near miss), 7 (column header) and 7b (nearest label) are implemented here for
79
+ the first time. Every rule now reads its data off the placed bundle.
80
+ - Advisory checksums never reject a match: `ca_sin`, `emirates_id`,
81
+ `de_tax_id`, `kr_rrn`, `sa_national_id`. Korea stopped issuing check digits on
82
+ 20 Oct 2020.
83
+ - Not ported, and still cloud-only: the slot, context,
84
+ gravity and name layers, industry profiles, and org configuration.
85
+ - **Indonesia is the country 1.1.0 added, and it is the one that proves the
86
+ whole-word rule.** `id_nik`'s only short spellings -- NIK, KTP, NPWP -- are
87
+ `wholeWordKeywords`, not ordinary keywords, because `nik` sits inside
88
+ *teknik*, *elektronik*, *klinik* and *pabrik*. Matching them by substring
89
+ would open the gate on an Indonesian sales ledger; matching them on a word
90
+ boundary catches "NIK 3171010101900001" and leaves *teknik* alone. An SDK that
91
+ merged the two lists would be shipping a false-positive bug, so the boundary
92
+ test is implemented rather than the shortcut, and four unit cases assert both
93
+ halves.
94
+ - **FLAGGED, upstream: bundle 1.1.0 cannot detect Australia's TFN, ABN or
95
+ Medicare number.** `checksums.json` declares `au_tfn` and `au_abn` as
96
+ `requiredBy` and `au_medicare` as `advisoryFor` patterns of those names, and
97
+ `patterns` ships none of them -- the AU profile carries only `au_acn` and
98
+ `au_phone_intl`. The AU activation signals are still keyed on "tfn", "tax
99
+ file" and "medicare", so the bundle switches Australia on for identifiers it
100
+ then has no pattern to catch. The cloud detects all three. This is a recall
101
+ gap no SDK can close from the bundle, and the six parity cases it costs are
102
+ recorded in the fixture as `BUNDLE GAP` rather than silently accepted.
103
+
104
+ ## 0.2.2 - 2026-03-09
105
+
106
+ ### Added
107
+ - feat: agent/session context fields (agent_id, agent_role, session_id, session_turn)
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Tork Network Pty Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.