Module: OKF::Pro
- Defined in:
- lib/okf/pro.rb,
lib/okf/pro/cli.rb,
lib/okf/pro/log.rb,
lib/okf/pro/audit.rb,
lib/okf/pro/board.rb,
lib/okf/pro/event.rb,
lib/okf/pro/state.rb,
lib/okf/pro/budget.rb,
lib/okf/pro/guards.rb,
lib/okf/pro/target.rb,
lib/okf/pro/writes.rb,
lib/okf/pro/closing.rb,
lib/okf/pro/pairing.rb,
lib/okf/pro/records.rb,
lib/okf/pro/version.rb,
lib/okf/pro/conserve.rb,
lib/okf/pro/friction.rb,
lib/okf/pro/log/edit.rb,
lib/okf/pro/scaffold.rb,
lib/okf/pro/snapshot.rb,
lib/okf/pro/reconcile.rb,
lib/okf/pro/board/edit.rb,
lib/okf/pro/attestation.rb,
lib/okf/pro/bundle_root.rb,
lib/okf/pro/conformance.rb,
lib/okf/pro/shell_guard.rb
Defined Under Namespace
Modules: Attestation, Audit, Board, Budget, BundleRoot, CLI, Closing, Conformance, Conserve, Friction, Guards, Log, Pairing, Reconcile, Records, Scaffold, ShellGuard, Snapshot, State, Writes Classes: Event, Target
Constant Summary collapse
- PASS =
The hook protocol's vocabulary. 0 and 2 are the only codes it reads as meaning anything; everything else is a non-blocking error, which is why FAIL is reserved for
audit, the one entry point that is not a hook. 0- BLOCK =
PreToolUse: denies. PostToolUse: stderr returns to the agent. Stop: refuses to finish.
2- FAIL =
audit only — CI's exit codes, not the hook protocol's.
1- STOP_WORDS =
Words too common to reconcile on. A search for "the" returns the corpus.
%w[the a an of and or for to in on with my is not].freeze
- NO_RECONCILE =
Files whose vocabulary is structural rather than conceptual. They are excluded twice over — from being reconciled, and from being reported as collisions — because they quote concepts rather than assert against them, and a gate that reports the README every time is one people scroll past.
%w[index.md log.md board.md CLAUDE.md README.md].freeze
- VERSION =
"1.0.0"
Class Method Summary collapse
-
.newline_terminated(text) ⇒ Object
A final newline, guaranteed, before any transform splices a line in.
-
.read_contained(root, path) ⇒ Object
The same read, contained.
-
.read_text(path) ⇒ Object
Every raw read the checker makes goes through here.
Class Method Details
.newline_terminated(text) ⇒ Object
A final newline, guaranteed, before any transform splices a line in.
Without it an append after the file's last line concatenates onto it, and
a file whose last line is a board entry is exactly where an append lands.
Delta-free by construction: Conserve compares lines chomped, so adding
the terminator changes no key it can see.
159 160 161 162 163 164 |
# File 'lib/okf/pro.rb', line 159 def self.newline_terminated(text) body = text.to_s return body if body.empty? || body.end_with?("\n") "#{body}\n" end |
.read_contained(root, path) ⇒ Object
The same read, contained. Where the caller already HOLDS the bundle root,
this is the one to use: SafeRead.read! resolves the path and refuses one
whose symlinks leave the root, which is the kernel's containment primitive
and not a second implementation of it. .scrub stays ours, for the reason
above — read! tags the encoding without validating it.
Not used where there is no root to contain against. BundleRoot is
deciding WHERE the root is, so it has none; and there a raise would be a
permanent lockout while a rescue would answer "not a root", mis-rooting
the bundle and disarming the journal guard.
Callers rescue Path::Error themselves and choose the safe answer for
their own question, because "this file escapes the bundle" means something
different to a closure marker than it does to a journal entry.
150 151 152 |
# File 'lib/okf/pro.rb', line 150 def self.read_contained(root, path) ::OKF::SafeRead.read!(root, path).scrub end |
.read_text(path) ⇒ Object
Every raw read the checker makes goes through here. Read as bytes, forced to UTF-8, scrubbed — because the alternative failed open twice over: with LANG unset (common in CI and git hooks) default_external is US-ASCII and even a clean em dash raises on the first regex; and one invalid byte anywhere raised ArgumentError out of match?, exiting the checker with a code the hook protocol reads as NON-BLOCKING. A crash is a pass, from the protocol's side — so the reader must not crash, and (belt to this suspender) CLI.run refuses on anything that still does.
132 133 134 |
# File 'lib/okf/pro.rb', line 132 def self.read_text(path) File.read(path, mode: "rb").force_encoding(Encoding::UTF_8).scrub end |