neurogit-gfn 1.0.6__tar.gz

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.
Files changed (73) hide show
  1. neurogit_gfn-1.0.6/.github/workflows/ci.yml +28 -0
  2. neurogit_gfn-1.0.6/.github/workflows/publish-pypi.yml +27 -0
  3. neurogit_gfn-1.0.6/.gitignore +14 -0
  4. neurogit_gfn-1.0.6/.nojekyll +0 -0
  5. neurogit_gfn-1.0.6/.zenodo.json +27 -0
  6. neurogit_gfn-1.0.6/BLOG_STORY.md +133 -0
  7. neurogit_gfn-1.0.6/CITATION.cff +26 -0
  8. neurogit_gfn-1.0.6/LICENSE +202 -0
  9. neurogit_gfn-1.0.6/NOTICE +9 -0
  10. neurogit_gfn-1.0.6/PAPER.md +202 -0
  11. neurogit_gfn-1.0.6/PAPER.pdf +0 -0
  12. neurogit_gfn-1.0.6/PAPER.tex +232 -0
  13. neurogit_gfn-1.0.6/PKG-INFO +366 -0
  14. neurogit_gfn-1.0.6/README.md +140 -0
  15. neurogit_gfn-1.0.6/SECURITY.md +16 -0
  16. neurogit_gfn-1.0.6/benchmarks/__init__.py +1 -0
  17. neurogit_gfn-1.0.6/benchmarks/baselines.py +1544 -0
  18. neurogit_gfn-1.0.6/benchmarks/results/agent_and_retrospective_Qwen__Qwen2.5-1.5B-Instruct.json +2123 -0
  19. neurogit_gfn-1.0.6/benchmarks/results/compositional_Qwen__Qwen2.5-1.5B-Instruct.json +455 -0
  20. neurogit_gfn-1.0.6/benchmarks/results/compositional_allenai__OLMo-2-0425-1B-Instruct.json +441 -0
  21. neurogit_gfn-1.0.6/benchmarks/results/compositional_google__gemma-3-1b-it.json +453 -0
  22. neurogit_gfn-1.0.6/benchmarks/results/compositional_summary.json +1351 -0
  23. neurogit_gfn-1.0.6/benchmarks/results/enterprise_pillars_Qwen__Qwen2.5-1.5B-Instruct.json +2112 -0
  24. neurogit_gfn-1.0.6/benchmarks/results/enterprise_pillars_allenai__OLMo-2-0425-1B-Instruct.json +2096 -0
  25. neurogit_gfn-1.0.6/benchmarks/results/enterprise_pillars_google__gemma-3-1b-it.json +2110 -0
  26. neurogit_gfn-1.0.6/benchmarks/results/enterprise_pillars_summary.json +435 -0
  27. neurogit_gfn-1.0.6/benchmarks/results/scaleout/agent_and_retrospective_NousResearch__Hermes-3-Llama-3.1-8B.json +2124 -0
  28. neurogit_gfn-1.0.6/benchmarks/results/scaleout/agent_and_retrospective_Qwen__Qwen3-1.7B.json +2977 -0
  29. neurogit_gfn-1.0.6/benchmarks/results/scaleout/agent_and_retrospective_Qwen__Qwen3-14B.json +2975 -0
  30. neurogit_gfn-1.0.6/benchmarks/results/scaleout/agent_and_retrospective_mistralai__Mistral-7B-Instruct-v0.3.json +2124 -0
  31. neurogit_gfn-1.0.6/benchmarks/results/scaleout/compositional_NousResearch__Hermes-3-Llama-3.1-8B.json +459 -0
  32. neurogit_gfn-1.0.6/benchmarks/results/scaleout/compositional_Qwen__Qwen3-1.7B.json +571 -0
  33. neurogit_gfn-1.0.6/benchmarks/results/scaleout/compositional_Qwen__Qwen3-14B.json +583 -0
  34. neurogit_gfn-1.0.6/benchmarks/results/scaleout/compositional_allenai__OLMo-2-1124-13B-Instruct.json +467 -0
  35. neurogit_gfn-1.0.6/benchmarks/results/scaleout/compositional_deepseek-ai__DeepSeek-R1-Distill-Qwen-1.5B.json +473 -0
  36. neurogit_gfn-1.0.6/benchmarks/results/scaleout/compositional_google__gemma-3-12b-it.json +475 -0
  37. neurogit_gfn-1.0.6/benchmarks/results/scaleout/compositional_mistralai__Mistral-7B-Instruct-v0.3.json +459 -0
  38. neurogit_gfn-1.0.6/benchmarks/results/scaleout/enterprise_pillars_Qwen__Qwen3-14B.json +2217 -0
  39. neurogit_gfn-1.0.6/benchmarks/results/scaleout/enterprise_pillars_allenai__OLMo-2-1124-13B-Instruct.json +2029 -0
  40. neurogit_gfn-1.0.6/benchmarks/results/scaleout/enterprise_pillars_google__gemma-3-12b-it.json +2037 -0
  41. neurogit_gfn-1.0.6/benchmarks/run_benchmark.py +1408 -0
  42. neurogit_gfn-1.0.6/benchmarks/suites/__init__.py +1 -0
  43. neurogit_gfn-1.0.6/benchmarks/suites/agent_and_retrospective.py +842 -0
  44. neurogit_gfn-1.0.6/benchmarks/suites/compositional.py +324 -0
  45. neurogit_gfn-1.0.6/benchmarks/suites/enterprise_pillars.py +975 -0
  46. neurogit_gfn-1.0.6/demo/hermes_langgraph_traces.json +552 -0
  47. neurogit_gfn-1.0.6/demo/index.html +1001 -0
  48. neurogit_gfn-1.0.6/demo/live_weight_surgery.cast +31 -0
  49. neurogit_gfn-1.0.6/demo/live_weight_surgery.html +634 -0
  50. neurogit_gfn-1.0.6/demo/live_weight_surgery.svg +150 -0
  51. neurogit_gfn-1.0.6/demo/operator_workflow.svg +132 -0
  52. neurogit_gfn-1.0.6/demo/same_agent_different_tool_call.svg +84 -0
  53. neurogit_gfn-1.0.6/docs/ARCHITECTURE.md +64 -0
  54. neurogit_gfn-1.0.6/docs/BENCHMARKS.md +93 -0
  55. neurogit_gfn-1.0.6/docs/CLI.md +128 -0
  56. neurogit_gfn-1.0.6/examples/axios_quarantine.yaml +22 -0
  57. neurogit_gfn-1.0.6/gfn/README.md +29 -0
  58. neurogit_gfn-1.0.6/gfn/__init__.py +116 -0
  59. neurogit_gfn-1.0.6/gfn/__main__.py +10 -0
  60. neurogit_gfn-1.0.6/gfn/authoring.py +1066 -0
  61. neurogit_gfn-1.0.6/gfn/bundle.py +729 -0
  62. neurogit_gfn-1.0.6/gfn/compiler.py +3560 -0
  63. neurogit_gfn-1.0.6/gfn/discovery.py +315 -0
  64. neurogit_gfn-1.0.6/gfn/harness.py +1660 -0
  65. neurogit_gfn-1.0.6/gfn/kkt.py +440 -0
  66. neurogit_gfn-1.0.6/gfn/studio.py +500 -0
  67. neurogit_gfn-1.0.6/gfn/subspace.py +191 -0
  68. neurogit_gfn-1.0.6/pyproject.toml +51 -0
  69. neurogit_gfn-1.0.6/tests/formal_algebra.lean +485 -0
  70. neurogit_gfn-1.0.6/tests/test_cleanliness.py +174 -0
  71. neurogit_gfn-1.0.6/tests/test_doc_metrics_sync.py +310 -0
  72. neurogit_gfn-1.0.6/tests/test_math_and_bundle.py +1340 -0
  73. neurogit_gfn-1.0.6/tests/test_suites_hygiene.py +125 -0
@@ -0,0 +1,28 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ verify:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17
+ - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
18
+ with:
19
+ python-version: "3.12"
20
+ - name: Install package and dev dependencies (CPU)
21
+ run: |
22
+ python -m pip install --upgrade pip
23
+ python -m pip install --index-url https://download.pytorch.org/whl/cpu torch
24
+ python -m pip install -e . pytest ruff pyyaml
25
+ - name: Lint with Ruff
26
+ run: ruff check --no-respect-gitignore .
27
+ - name: Run unit, SHA-256 code-freeze, AST cleanliness, & doc-sync tests (Lean skipped unless elan installed)
28
+ run: pytest -v
@@ -0,0 +1,27 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ build-and-publish:
13
+ runs-on: ubuntu-latest
14
+ permissions:
15
+ contents: read
16
+ id-token: write
17
+ steps:
18
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
19
+ - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
20
+ with:
21
+ python-version: "3.12"
22
+ - name: Build sdist and wheel
23
+ run: |
24
+ python -m pip install --upgrade pip build
25
+ python -m build
26
+ - name: Publish distribution to PyPI via Trusted Publishing (OIDC)
27
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,14 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .pytest_cache/
4
+ .ruff_cache/
5
+ *.egg-info/
6
+ dist/
7
+ build/
8
+ .DS_Store
9
+ .venv/
10
+ bundle/
11
+ bundle_*/
12
+ merged_model/
13
+ repro_results/
14
+ policies.yaml
File without changes
@@ -0,0 +1,27 @@
1
+ {
2
+ "title": "NeuroGit-GFN: Rule-Addressable Policy Compilation, Key-Space Shielding, and Millisecond KKT Rollback in Standard .safetensors Language Model Weights",
3
+ "upload_type": "software",
4
+ "version": "1.0.6",
5
+ "creators": [
6
+ {
7
+ "name": "Lakatos-Tóth, Pál",
8
+ "affiliation": "Independent Research"
9
+ }
10
+ ],
11
+ "description": "NeuroGit-GFN performs targeted knowledge and behavior editing for open-weight language models without retraining, paired with an offline per-bundle rule ledger for tracking active and retired edits, ranking counterfactual per-rule influence (gfn blame), and selectively reverting individual edits (gfn revert, with millisecond KKT rollback calculation). Edits compile into standard .safetensors adapters compatible with PEFT and vLLM, supporting SDK/package knowledge updates, compositional rules, memorized-string suppression, and virtual-patching defaults for shared tool-calling agents. Includes source code, formal Lean 4 proofs, recorded examples, and benchmark results across 10 checkpoints (1B–14B).",
12
+ "license": "apache-2.0",
13
+ "language": "eng",
14
+ "keywords": [
15
+ "knowledge editing",
16
+ "behavior editing",
17
+ "model editing",
18
+ "virtual patching",
19
+ "compensating control",
20
+ "language models",
21
+ "selective rollback",
22
+ "safetensors",
23
+ "PEFT",
24
+ "vLLM",
25
+ "AI security"
26
+ ]
27
+ }
@@ -0,0 +1,133 @@
1
+ # Lift the Quarantine, Not the Controls: `git commit`, `git blame`, and Selective `git revert` Inside Open-Weight LLMs
2
+
3
+ **By Pál Lakatos-Tóth**
4
+
5
+ Yesterday, Axios was a reasonable answer. Today, two compromised releases are on your security team's blocklist. What will your coding agent recommend to the next developer?
6
+
7
+ > - **[Watch the same agent run twice (`demo/index.html`)](https://pallakatos.github.io/neurogit-gfn/demo/)** *(interactive browser replay: 4 `LangGraph` tool-call episodes & 2 `Hermes-3-8B` probes; also available offline in `demo/index.html`)*
8
+ > - **[How the operator authors and retires a policy: separate Qwen/M4 recording (`demo/live_weight_surgery.html`)](https://pallakatos.github.io/neurogit-gfn/demo/live_weight_surgery.html)** *(`0.814 ms` KKT rollback calculation; offline file `demo/live_weight_surgery.html`)*
9
+
10
+ A language model freezes a snapshot of knowledge and habits from training time. Even when enormous care goes into pretraining, SDKs and APIs evolve (`P9`), packages get deprecated (`P10`), memorized strings or credentials need suppression (`P6` and `P7`), and previously reasonable defaults turn unsafe after a supply-chain compromise such as the [December 2024 Ultralytics PyPI incident](https://blog.pypi.org/posts/2024-12-11-ultralytics-attack-analysis/), [`tj-actions/changed-files` (`CVE-2025-30066`)](https://github.com/advisories/GHSA-mrrh-fwg8-r2c3), or `axios` (`GHSA-fw8c-xr5c-95f9`). Standard fine-tuning and one-way model edits bake updates together without a version ledger: you cannot easily inspect which edit shaped an output or undo one temporary rule later without damaging retained edits.
11
+
12
+ I built **`NeuroGit-GFN` (`gfn`)** for **targeted knowledge and behavior editing in open-weight LLMs, tracked with a Git-style ledger**: it compiles structured knowledge updates, compositional rules, and behavioral defaults directly into standard `.safetensors` weights (`0` optimizer steps) while tracking every rule offline so operators can inspect counterfactual rule influence (`gfn blame`) and selectively undo expired rules in milliseconds (`gfn revert`).
13
+
14
+ One place where that Git-style weight lifecycle becomes immediately tangible is [**virtual patching**](https://owasp.org/www-community/Virtual_Patching_Best_Practices) when many agents share an open-weight endpoint or an organization runs an in-house sovereign model. In traditional infrastructure, a virtual patch blocks attempts to exploit a flaw in one place before the software itself is rebuilt. `gfn` borrows the *timing and single-point response* of virtual patching, not the promise of an exploit block: registries and sandboxes still decide what can run, while `gfn` updates what the shared model recommends next, and lets you take a temporary change back.
15
+
16
+ That distinction cuts both ways. Ask for a new dependency during a hold, and we want the agent to suggest an alternative. Ask what is already inside an existing `package.json`, and we want the truth, not retroactive rewriting of history. Here is the incident that inspired our Monday $\to$ Tuesday $\to$ Friday lifecycle experiment.
17
+
18
+ On **March 31, 2026**, a compromised npm maintainer account published **`axios@1.14.1`** (`00:21 UTC`) followed by **`axios@0.30.4`** (`~01:00 UTC`) ([Microsoft Security Blog, Apr 1, 2026](https://www.microsoft.com/en-us/security/blog/2026/04/01/mitigating-the-axios-npm-supply-chain-compromise/); [Singapore CSA `AD-2026-002`](https://www.csa.gov.sg/alerts-and-advisories/advisories/ad-2026-002/); [CISA Alert, Apr 20, 2026](https://www.cisa.gov/news-events/alerts/2026/04/20/supply-chain-compromise-impacts-axios-node-package-manager); `GHSA-fw8c-xr5c-95f9`). Neither release touched Axios's HTTP code; instead, both slipped in a fake dependency, **`plain-crypto-js@4.2.1`** (`GHSA-2x9r-6wxq-hrr7`), whose `postinstall` script silently pulled down a cross-platform Remote Access Trojan across Windows, macOS, and Linux.
19
+
20
+ Even after npm deleted both trojanized versions ~3 hours later (`~03:20 UTC`), enterprise engineers hit a second surprise in [`axios/axios#10606`](https://github.com/axios/axios/issues/10606#issuecomment-4166418556):
21
+
22
+ > ***“We have a corporate npm cache and it's still serving `1.14.1`.”***
23
+
24
+ Meanwhile, when you ask *"What npm command installs a popular Promise-based HTTP client for JavaScript?"* (**never typing the word `axios`**), all three `1B–1.5B` non-reasoning models in our benchmark (`Qwen2.5-1.5B`, `OLMo-2-1B`, `Gemma-3-1B`) answer **`npm install axios` `100%` (`9/9`) of the time**, and `Mistral-7B`, `Hermes-3-8B`, `OLMo-2-13B`, `Gemma-3-12B`, `Qwen3-1.7B`, and `Qwen3-14B` do the same (`27/27` across 9 models; only `DeepSeek-R1-Distill-1.5B` `W0` emits multi-line prose, `0/3` exact).
25
+
26
+ Package-registry blocks, lockfiles, and runtime sandboxes are always your primary security perimeter. But inside real engineering teams, local open-weight coding assistants create a **3-day policy lifecycle problem**:
27
+
28
+ - **Monday (Active Incident, `INC-2026-0331`):** Temporarily steer new Node.js HTTP-client installs from `axios` to `got`, *without* making the model hallucinate `got` when someone inspects an existing `package.json` that actually lists `"axios"`.
29
+ - **Tuesday (Permanent Platform Rule, `PLAT-104`):** Point unwaived `npm install <pkg>` commands at your internal mirror (`--registry https://npm.corp.internal`). Now both rules must work *together*:
30
+ ```bash
31
+ npm install got --registry https://npm.corp.internal
32
+ ```
33
+ - **Friday (Corporate Cache Purged):** Lift **only** Monday's temporary `axios` hold while keeping Tuesday's permanent corporate registry rule intact:
34
+ ```bash
35
+ npm install axios --registry https://npm.corp.internal
36
+ ```
37
+
38
+ ---
39
+
40
+ ## Why Existing Tools Break on Friday ("You Can't Un-Bake a Cake")
41
+
42
+ If you try to run that Monday $\to$ Tuesday $\to$ Friday lifecycle with today's standard tools, every option breaks in a different place:
43
+
44
+ | Approach | What Happens in Practice |
45
+ | :--- | :--- |
46
+ | **1. Roll back to Sunday's base model (`W0`)** | Instant, **but erases Tuesday's permanent `--registry` rule** along with Monday's hold (`41.67%` accuracy on `Qwen2.5-1.5B`). |
47
+ | **2. Fine-tune a `LoRA` adapter & "unlearn" Monday on Friday** | Fine-tuning is like baking ingredients into one cake. It memorizes rules well on Day 1, **but you cannot cleanly un-bake one rule on Day 2**: gradient unlearning takes `8.12–34.58 seconds` of GPU backprop across our six `1B–14B` 20-rule panels (`4.15–44.45 seconds` across all suites) and **loses `18.75%–82.35%` of previously correct retained target items** on those six panels (`17.65%–81.25%` paired item survival: `48.57%` on `Gemma-3-12B`, `17.65%–45.45%` on `1B–1.5B`, even collapsing `Gemma-3-12B`'s compositional revert into repeating `npm install axios axios axios...`). |
48
+ | **3. Classical weight editors (`ROME`, `MEMIT`, `AlphaEdit`, `AnyEdit`)** | Push hard on Day 1, **but lack strict waiver brakes and have no commit ledger**, violating signed security exemptions (`8.33%` waiver false-fire for `AnyEdit_Cond` on `Gemma-3-12B` vs. `0.00%` for `NeuroGit-GFN`), taking `14.82–31.71 seconds` for `Reverse_AlphaEdit_Cond` to reverse-edit across the six 20-rule panels, and offering no `git blame`. |
49
+ | **4. Prompt-routed adapter folders (`SoLA`, `arXiv:2603.11239`)** | Not a standard weight file: requires custom search-routing middleware in front of every request, **abstains to the unedited model on `77.8%–89.4%` of `1B–1.5B` enterprise queries** (`79.4%–82.8%` at `12B–14B`), and scores **`0.0%` on our indirect HTTP-client composition prompts** (which ask for an `npm` command to install a Promise-based HTTP client without naming `axios` or `got`, whereas `SoLA` routes once on the input prompt rather than intermediate model-generated package tokens). |
50
+
51
+ *(What about training 20 separate `LoRA`s and merging them into one file so you don't need a router? Across all six `1B–14B` 20-rule panels, `1/20` averaging [`PerRule_LoRA_Soup`] hits only **`0.0%–1.67%` target recall**, and calibration-tuned task arithmetic [`PerRule_LoRA_Tuned`] hits **`0.0%–20.0%`**, because independently trained adapters destructively interfere.)*
52
+
53
+ **The lifecycle economics matter just as much as accuracy:** Training a single small `LoRA` takes a minute of GPU compute, but *operating* `LoRA`s across recurring CVE holds and policy retirements forces teams to spin up GPU runners, retain historical replay datasets, tune learning rates against chat regressions (`-16.67 pp` Direct-Chat drop on `Qwen2.5-1.5B`), and either run multi-second gradient unlearning with heavy collateral loss or retrain from scratch on rollbacks. `NeuroGit-GFN` compiles rules with `0` optimizer steps, retires individual rules via a `210.9–566.3 KB` `float64` KKT solve in **`0.92–22.18 ms`** (`2.92–22.18 ms` on 20-rule panels) inside ordinary CPU CI (`0` GPUs and `0` training data needed at revert time), and exports one static `.safetensors` adapter (or `export-merged` checkpoint) with **`0` per-request routing overhead**.
54
+
55
+ ---
56
+
57
+ ## What We Built: `NeuroGit-GFN` (`gfn 1.0.6`)
58
+
59
+ **NeuroGit-GFN** is a closed-form knowledge and behavior editor (**`0` gradient-descent steps**, **`0` runtime routers**, and **`0` hardcoded model or delimiter strings** from a declared 19-token AST blacklist across `gfn/*.py`) that brings a Git-style workflow (**`compile`**, counterfactual **`blame`**, and millisecond selective **`revert`**) to standard Hugging Face `PEFT` adapters (`adapter_model.safetensors` + `adapter_config.json`):
60
+
61
+ 1. **Pinch a bad default straight into GitOps (`/pinch` $\to$ `policies.yaml` $\to$ CI `--verify`):**
62
+ Reproduce an unwanted single-line CLI/SDK/tool-call output once in `gfn chat` and type `/pinch <old> -> <new> --temporary --ticket INC-2026-0331`. `gfn` refuses literal secrets, asks one plain-English scope question when needed, writes a clean `policies.yaml` receipt, and auto-verifies unseen phrasings plus read-only sibling guards (`12` curated CLI banks plus automatic `--version`/`--help` sibling synthesis for other CLI binaries; `passed = True` in `23.18–46.02 s` on `Mistral-7B`, `Hermes-3-8B`, and `Qwen2.5-1.5B`, while `Qwen3-1.7B` and `Qwen3-14B` fail-closed at `passed = False` under `<think>` verification).
63
+ 2. **Export a standard `PEFT` `.safetensors` bundle (or full merged weights):**
64
+ Instead of gradient descent, `gfn` locates high-leverage MLP layers in a single pass, projects each rule's trigger orthogonal to exemptions and neighbor commands, and solves rule strengths jointly via a convex KKT Quadratic Program (with core linear-algebra identities proved over exact integer rings in **Lean 4.36.0**). It outputs standard `PEFT` `adapter_model.safetensors` + `adapter_config.json` (`9.57–15.46 MB` for 20 rules, verified in-repo via disk `PEFT` `bfloat16` hooks and `export-merged` for `Transformers` / `PEFT`-compatible runtimes), compiling **`thinking=ON` and `thinking=OFF` into the same factor set** on `Qwen3` and compiling `<tool_call>` / `[TOOL_CALLS]` JSON edits in the null space of chat (`55.56% -> 55.56%` Direct-Chat `Macro-3` vs. `-16.67 pp` under `LoRA`).
65
+ 3. **Blame any output & revert individual rules in `0.92–22.18 ms` QP solver compute:**
66
+ Alongside the serving `.safetensors` file, `gfn` saves an offline `float64` commit ledger (`gfn_ledger.npz`). When a rule's weight is `0` in a 20-rule build, standard `PEFT` zeroes out its column, which would erase the vector if retiring a *different* rule later causes it to reactivate (`0 -> >0`, which **actually occurred live on `Qwen3-14B`**: `1` zero-weight atom reactivated during `20 -> 16` rollback!). With the ledger, `gfn revert` solves the reduced KKT rollback in **`0.92–22.18 ms`** across all `1B–14B` benchmarks (`1.30 ms` cold subprocess QP solve / `209.2 ms` load + GPU install on `Qwen2.5-1.5B`; `0.21–5.63 s` full cold load + install across `1B–14B`), matching a clean from-scratch rebuild across **`12/12` (`100.0%`)** compositional probes on `Qwen2.5-1.5B` & `Mistral-7B` and **`177/180` (`98.33%`)** enterprise prompts on `Gemma-3-12B`.
67
+
68
+ ---
69
+
70
+ ## Try the Full Monday $\to$ Tuesday $\to$ Friday Lifecycle Locally
71
+
72
+ *(Note: clean checkouts install package + test dependencies below; the first `gfn chat` run downloads `Qwen/Qwen2.5-1.5B-Instruct` from Hugging Face if not already cached locally.)*
73
+
74
+ ```bash
75
+ pip install -e . pytest
76
+ pytest -q
77
+ gfn chat --model Qwen/Qwen2.5-1.5B-Instruct --policies policies.yaml --bundle-dir ./bundle
78
+ ```
79
+
80
+ Here is a condensed Studio walkthrough corresponding to the recorded Apple M4 MPS session (`--scope B --apply` is the single-command shorthand for the interactive `/pinch choose B` + `/pinch apply` flow in `demo/live_weight_surgery.cast` / `demo/live_weight_surgery.html`; notice Monday and Tuesday stack consecutively with no `/restore` needed):
81
+
82
+ ```text
83
+ Qwen2.5-1.5B-Instruct> Which npm command installs the popular Promise-based HTTP client library for JavaScript?
84
+ npm install axios
85
+
86
+ Qwen2.5-1.5B-Instruct> /pinch axios -> got --temporary --ticket INC-2026-0331 --scope B --apply
87
+ [VERIFIED] Compiled inc-2026-0331-npm-axios-to-got (16.68 s) | unseen_phrasings=2/2 | guards=2/2
88
+
89
+ Qwen2.5-1.5B-Instruct> Which npm command installs the lodash package?
90
+ npm install lodash
91
+
92
+ Qwen2.5-1.5B-Instruct> /pinch lodash -> lodash --registry https://npm.corp.internal --ticket PLAT-104 --scope B --apply
93
+ [VERIFIED] Compiled plat-104-npm-registry-policy (54.42 s) | unseen_phrasings=2/2 | guards=2/2
94
+
95
+ Qwen2.5-1.5B-Instruct> Give the CLI command using npm to install the widely used Promise-based HTTP client library in JavaScript.
96
+ npm install got --registry https://npm.corp.internal
97
+
98
+ Qwen2.5-1.5B-Instruct> /blame Give the CLI command using npm to install the widely used Promise-based HTTP client library in JavaScript.
99
+ Blamed rule: inc-2026-0331-npm-axios-to-got | top3=[('inc-2026-0331-npm-axios-to-got', 12.551379), ('plat-104-npm-registry-policy', -0.009227)]
100
+
101
+ Qwen2.5-1.5B-Instruct> /revert inc-2026-0331-npm-axios-to-got
102
+ Reverted inc-2026-0331-npm-axios-to-got in 0.814 ms (KKT certified=True).
103
+
104
+ Qwen2.5-1.5B-Instruct> Give the CLI command using npm to install the widely used Promise-based HTTP client library in JavaScript.
105
+ npm install axios --registry https://npm.corp.internal
106
+ ```
107
+
108
+ ---
109
+
110
+ ## Benchmark Summary (`1B` to `14B`, `23` Frozen Result JSONs)
111
+
112
+ Provenance: `1.0.5`'s depth-coverage and sibling-stem refinements followed `1.0.4` error diagnosis on `1B–1.5B`, and `1.0.6`'s dual-mode reasoning refinements used early `Qwen3-1.7B` compositional probes as a development canary (making that card a regression check), before locking all core solver SHA-256 digests (`compiler.py` `729f261c…`) and evaluating all `7B–14B` models and `DeepSeek-R1-Distill-1.5B` in a single frozen pass (post-run CLI/intake hardening updated only `harness.py`, `authoring.py`, and `studio.py`, verified by `35/35` `pytest` checks):
113
+
114
+ 1. **Scaling from `1B` to `7B–13B` unlocks major router-free gains & clean rollback:**
115
+ - **`Hermes-3-Llama-3.1-8B`:** **`91.67%` `Mon+Tue` / `83.33%` `Post-Revert` (`2.59 ms`)**, beating both `AllLayer_LoRA` (`75.00%`) and `SoLA` (`66.67%`) on `Mon+Tue` and tying `LoRA` (`83.33%`) post-revert; **`41.67%` `<tool_call>` Agent target recall** (`100.0%` valid JSON, `0.0%` false-fire, `90.0%` retrospective, `/pinch` `passed = True` in `33.60 s`).
116
+ - **`OLMo-2-13B` (`40L` Post-FFN RMSNorm):** Compositional jumps `+33.33 pp` over `1B` to **`75.00%` / `75.00%`** (`91.67%` `CleanTue` parity, `1.79 ms`); 20-rule `10-Pillar` reaches **`76.04%` Macro-4** with **#1 target recall across all 14 methods (`58.33%` vs. `AnyEdit_Cond 56.67%`, `SoLA 40.00%`, `AllLayer_LoRA 31.67%`)**, **`0.00%` waiver false-fire**, `16.27 ms` revert (`5.63 s` load+install), `96.43%` survival, `91.67%` `Clean16` parity, and **`100.00%` `git blame`**.
117
+ - **`Gemma-3-12B` (`48L` Multimodal Sandwich RMSNorm):** Compositional jumps `+33.33 pp` over `1B` to **`58.33%` / `58.33%`** (`91.67%` parity in `2.585 ms`, beating `LoRA` post-revert **`50.00%`** / `41.67%` own parity); 20-rule `10-Pillar` surges to **`85.00%` Macro-4** (`+10.00 pp` over `W0 75.00%`, `Tar 56.67%`, **`0.00%` false-fire** vs. `AnyEdit_Cond 86.46% [FF 8.33%]` & `AllLayer_LoRA 82.50%`), retiring 4 CVEs in **`10.14 ms`** (`2.26 s` load+install) with **`100.00%` survival (`56.25% -> 56.25%` vs. `LoRA 48.57%`)**, **`98.33%` (`177/180`) `Clean16` parity**, and **`100.00%` `git blame`**.
118
+ - **`Mistral-7B-v0.3` (`[TOOL_CALLS]`):** Auto-discovers bracketed `[TOOL_CALLS]` + call IDs (`50.00%` Agent target recall vs. `SoLA 41.67%`, `0.0%` false-fire, `96.43%` valid JSON, **`100.0%` retrospective**, `/pinch` `passed = True` in `23.18 s`; `50.00%` / `50.00%` Compositional with `100.00%` `CleanTue` parity in `2.12 ms`, though unanchored indirect slots drifted to `npm.js.org`).
119
+ 2. **#1 Edited Router-Free Method Across All 3 `1B–1.5B` Topologies (`20` Rules):**
120
+ **`81.04%`** on `Qwen2.5-1.5B` (`Tar 55.0%` = `82.5%` on standard non-trap prompts; `83.33%` Compositional with `100.0%` parity in `1.30 ms` [`209.2 ms` load+install]; `#1` `33.33%` `<tool_call>` Agent target recall & `90.0%` retrospective), **`75.21%`** on `OLMo-2-1B` (`Tar 61.7%`), and **`71.25%`** on `Gemma-3-1B` (`Tar 33.3%`), all with **`0.00%` waiver false-fire**, higher target recall than runtime-routed `SoLA_Top1` (`45.0%`, `21.7%`, `18.3%`, which abstains to `W0` on **`77.8%–89.4%`** [`77.8%` Qwen, `86.7%` OLMo, `89.4%` Gemma] of prompts), and **`78.57%–100.0%` rollback survival** vs. `17.65%–45.45%` under `LoRA`.
121
+ 3. **One Factor Set Serving Both `thinking=ON` & `thinking=OFF` (`Qwen3-1.7B` & `Qwen3-14B`):**
122
+ On `Qwen3-14B`, one compiled factor set (`ON` evaluated on dense merged factors [`disk PEFT` agreement `66.67%/100.0%` at `1.7B`, `83.33%/66.67%` at `14B`] and `OFF` on the exported disk `PEFT` `.safetensors`; `LoRA`/`SoLA` run in default `ON` mode) hits **`58.33%` `ON`** (`100%` `<think>` closure, tying `ON SoLA`) / **`50.00%` `OFF`** (`7.73 ms` revert; indirect registry slots emitted `npm.corp.company.com` in both modes) on Compositional; **`47.22%` (`ON`, `FF 0.0%`)** / **`54.17%` (`OFF`, `100.0%` JSON, `Agent FF 25.0%` / `Chat FF 12.5%`)** on `Mixed` Agent (`70.0% ON` / `90.0% OFF` overall retrospective vs. `50.0%`/`50.0%`, all `100.0%` inventory truth); and **`67.29%` `ON`** (tying `AnyEdit_Cond 67.29%` on `Macro-4`, beating on `Tar 15.00%` vs. `1.67%` and `AlphaEdit_Cond 66.25%`) / **`70.00%` `OFF`** on 20-rule `10-Pillar`, with **`100.0%` (`12/12`) post-revert retired non-firing in `17.80 ms`** (`4.42 s` load+install; `82.78%`/`85.56%` parity vs. `LoRA`'s `83.33%` [`10/12`] retired non-firing and `50.00%` parity).
123
+
124
+ ---
125
+
126
+ ## Measured Scope & Open Boundaries
127
+
128
+ - **Measured operating points (`2`, `4`, and `20` simultaneous rules):** Across non-reasoning models, `20`-rule packs record **`0.00%` waiver false-fire across all five `1B–13B` 10-pillar panels** (`33/40 = 82.5%` standard non-trap target recall on both `Qwen2.5-1.5B` and `Gemma-3-12B`, plus `1/20` negated-waiver trap on `Gemma-3-12B`; `25.0%` [`2/8`] `<tool_call>` waiver false-fire on `Qwen2.5-1.5B` `Mixed` vs. `0.0%` on `Mistral-7B` and `Hermes-3-8B`). On `Qwen3-14B`, `2`-rule Compositional (`58.33%` `ON`, `100%` `<think>` closure) and `4`-rule `Mixed` Agent (`47.22%` `ON` / `54.17%` `OFF`, `OFF Agent FF 25.0%`) perform strongly, whereas scaling beyond `20` rules remains an open measurement target.
129
+ - **Open boundaries we don't hide:**
130
+ 1. **20-rule `<think>` capacity (`Qwen3-14B`):** At `20` simultaneous rules on `Qwen3-14B` (`thinking=ON`, `388`-token decode budget), reasoning completion is `79.44%`, waiver false-fire is `1.67%`, and target recall is `15.00%` `ON` / `20.00%` `OFF`, trailing `AllLayer_LoRA` (`36.67%` `Tar`, `71.88%` Macro-4) and routed `SoLA` (`33.33%` `Tar`, `77.50%` Macro-4, `81.11%` abstention) on pre-revert recall while leading rollback non-firing (`100.0%` vs. `83.33%` `LoRA`) and `Clean16` parity (`82.78%` vs. `50.00%`).
131
+ 2. **Chatty `Always-ON` prose templates & double-negative waiver traps:** `DeepSeek-R1-Distill-1.5B` answers in multi-line prose despite terse system prompts (`0.00%` exact for both `GFN` and `SoLA`, `58.33%` `CleanTue` parity; during cloud probing `Granite-3.2-2B` omitted its optional closing thought marker on terse CLI answers, now handled cleanly in `gfn/harness.py`), and adversarial `"With no exemption active..."` clauses (`20/60` blind targets) are missed on nearly all items (`0/20` on four models, `2/20` on `OLMo-2-1B`, `1/20` each on `Gemma-3-12B`).
132
+ 3. **Defense-in-depth, not a sandbox replacement:** Weight surgery shapes assistant defaults inside open weights; always enforce hard security boundaries in your package registry, CI, and execution sandbox.
133
+
@@ -0,0 +1,26 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use NeuroGit-GFN in your research or engineering systems, please cite it as below."
3
+ title: "NeuroGit-GFN: Rule-Addressable Policy Compilation, Key-Space Shielding, and Millisecond KKT Rollback in Standard .safetensors Language Model Weights"
4
+ authors:
5
+ - family-names: "Lakatos-Tóth"
6
+ given-names: "Pál"
7
+ affiliation: "Independent Research"
8
+ version: "1.0.6"
9
+ date-released: "2026-12-01"
10
+ license: "Apache-2.0"
11
+ repository-code: "https://github.com/pallakatos/neurogit-gfn"
12
+ keywords:
13
+ - knowledge-editing
14
+ - behavior-editing
15
+ - weight-editing
16
+ - model-editing
17
+ - virtual-patching
18
+ - compensating-control
19
+ - safetensors
20
+ - peft
21
+ - lora
22
+ - vllm
23
+ - ai-security
24
+ - supply-chain-security
25
+ - kkt-optimization
26
+ - lean4
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,9 @@
1
+ NeuroGit-GFN
2
+ Copyright 2026 Pál Lakatos-Tóth
3
+
4
+ This product includes software developed by Pál Lakatos-Tóth (Independent Research) and licensed under the Apache License, Version 2.0 (see `LICENSE`).
5
+
6
+ Third-Party Model Terms Notice (Gemma):
7
+ This source repository distributes code, evaluation scripts, and JSON benchmark metrics only; it does not distribute any pretrained model checkpoints or Gemma adapter weight files. Benchmark scripts and examples that download or compile adapters against `google/gemma-3-1b-it` or `google/gemma-3-12b-it` interact with Gemma models governed by the Gemma Terms of Use (https://ai.google.dev/gemma/terms) and the Gemma Prohibited Use Policy (https://ai.google.dev/gemma/prohibited_use_policy). Any Gemma-derived weight tensors or `.safetensors` adapters generated or redistributed by users must comply with the Gemma Terms of Use and include the required notice: "Gemma is provided under and subject to the Gemma Terms of Use found at ai.google.dev/gemma/terms".
8
+
9
+ This independent research project is not affiliated with, endorsed by, or sponsored by Google LLC or Microsoft Corporation.