Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d4744d8
Restore ratified spec bytes and carry #24's text as candidate amendme…
shanebarakat Nov 16, 2026
1186776
Refuse a malformed kinbase .kin/config instead of skipping it
shanebarakat Nov 16, 2026
332ae66
Add candidate spec amendment 006 for the .kin/kinbase.toml rename
shanebarakat Nov 16, 2026
1b1e5c6
Resolve an omitted --as-of to the recorded proof clock
shanebarakat Nov 16, 2026
2a09239
Order GitHub exports by one clock
shanebarakat Nov 16, 2026
2d333ec
Record agent-trailer commits as ai_generated and report provenance on…
shanebarakat Nov 16, 2026
2ad65bb
Ask about contested keys and let a shrug close the question it settles
shanebarakat Nov 16, 2026
d269996
Treat a hook prompt and its transcript copy as one message
shanebarakat Nov 16, 2026
647dd4a
Admit Company candidates after the local destinations of a message
shanebarakat Nov 16, 2026
72156e8
Re-read the nonce reservation under the admission lock
shanebarakat Nov 16, 2026
4b85563
Tolerate losing the race to add the quarantine identity column
shanebarakat Nov 16, 2026
5fb1142
Stop asking a Company endpoint that already ran out its read budget
shanebarakat Nov 16, 2026
438ecc6
Address review: one read of .kin/config, generic wording, and a full …
shanebarakat Nov 16, 2026
a3cf6d9
Adopt a hook prompt's id only for user messages
shanebarakat Nov 16, 2026
0ce1fa3
Attribute a commit to an agent only from its authorship metadata
shanebarakat Nov 16, 2026
dfffb18
Scope shrug closure, keep it from refusing projection, and ask a conf…
shanebarakat Nov 16, 2026
ca57f76
Flag a timeout only when the Company read actually timed out
shanebarakat Nov 16, 2026
3e24c4a
Admit Company candidates last in the checkpoint too
shanebarakat Nov 16, 2026
b46d8e0
Prefer any bound reservation bytes under the admission lock
shanebarakat Nov 16, 2026
7a94e0d
Merge the Unreleased changelog headings after rebasing onto #64
shanebarakat Nov 16, 2026
30c93f2
Report a spent read budget from every phase of a Company answer
shanebarakat Nov 16, 2026
398a37f
Skip a conflict that already has a question so the next one is asked
shanebarakat Nov 16, 2026
6f0e0b0
Walk past a blocker already asked under this decision
shanebarakat Nov 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
with:
pattern: kinbase-*
merge-multiple: true
# wandercom releases are immutable once published, so the assets go onto a
# Releases here are immutable once published, so the assets go onto a
# draft first. A re-run after a partial publish finds the draft and finishes it.
- env:
GH_TOKEN: ${{ github.token }}
Expand Down
42 changes: 34 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ Notable changes to Kinbase. Dates are UTC.

## Unreleased

### Fixed

- `hooks dispatch` no longer exits 4 (`CONFIG_INVARIANT`, "inherited
descriptor(s) outside the frozen allowlist") when the host leaks an open
descriptor into the hook. Startup attestation closes such descriptors for a
hook and names them on stderr; one under the Personal root still fails it.
Candidate spec amendment 004 records the change.

### Changed

- A statement goes to the Company only when it claims organization-wide
Expand All @@ -21,6 +13,40 @@ Notable changes to Kinbase. Dates are UTC.
organization word ("company policy", "the organization's roadmap").
"The governance guard blocks the edit" and "incorporate" no longer route to
the Company. (#43)
- Omitting `--as-of` on `status`, `fsck`, `explain`, `corpus rebuild` and
`recall` uses the repository's recorded proof clock again
(`as_of_source=recorded-proof-clock`), not the cached authority snapshot's
`issued_at`. `project` and SessionStart still advance to the snapshot.
- A git commit carrying an agent `Co-authored-by:` trailer is recorded as
`ai_generated` whoever its author is, so its standing stays capped; existing
repositories re-record such commits on their next ingest. Ingest output now
reports each observation's `provenance` and `standing`.
- A contested key with no answering authority opens a question, and a later
shrug on that key closes it.
- `session observe` admits a message's Personal and Codebase candidates
before its Company candidate, so a Company failure leaves an apology in every
destination that already committed.
- Once a Company endpoint has used up its read budget, the rest of that
command fails further requests to it at once with `COMPANY_UNREACHABLE`;
they stay pending and a later run retries them.

### Fixed
Comment thread
shanebarakat marked this conversation as resolved.
Resolved

- `hooks dispatch` no longer exits 4 (`CONFIG_INVARIANT`, "inherited
descriptor(s) outside the frozen allowlist") when the host leaks an open
descriptor into the hook. Startup attestation closes such descriptors for a
hook and names them on stderr; one under the Personal root still fails it.
Candidate spec amendment 004 records the change.
- A malformed kinbase config at `.kin/config` (one naming `kinbase-repo/`)
refuses with exit 5 instead of being skipped as Kindex's file.
- GitHub exports are ordered by one clock: when any export has no date of its
own, all are ordered by file modification time.
- Two concurrent checkpoints no longer fail on adding the quarantine identity
column, and concurrent retries of one admission commit one event.
- A prompt the `UserPromptSubmit` hook captured and the transcript's copy of
the same message are one message: the transcript copy takes the hook's id,
so it mints no second set of candidates and receipts, and a Stop returns
each receipt once.

## 0.1.2 - 2026-10-30

Expand Down
5 changes: 3 additions & 2 deletions crates/kinbase/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,9 @@ fn resolve_as_of(
}
}
};
// The verified authority snapshot is recorded proof of a later instant.
Ok(crate::repository::advance_as_of(launcher, &recorded))
// Omitted --as-of is the recorded proof clock (ruling R-1/C12). The
// projector and hook advance to the signed snapshot on their own.
Ok(recorded)
}

fn store_to_kind(store: Store) -> crate::StoreKind {
Expand Down
20 changes: 11 additions & 9 deletions crates/kinbase/src/codebase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,18 +316,20 @@ pub const CONFIG_FILE: &str = "kinbase.toml";
/// only when it is genuinely a kinbase config.
fn config_path_for(kin: &std::path::Path) -> Option<std::path::PathBuf> {
let ours = kin.join(CONFIG_FILE);
if ours.exists() {
return Some(ours);
}
let legacy = kin.join("config");
if legacy.exists()
&& std::fs::read_to_string(&legacy)
.ok()
.is_some_and(|text| RepoConfig::parse(&text).is_ok())
{
// A `.kin/config` naming our schema is kinbase's own, so malformed bytes there
// must refuse with exit 5 (spec/cli.md first-run table), not be skipped as
// Kindex's; Kindex's YAML never names `kinbase-repo/`.
const MARKER: &[u8] = b"kinbase-repo/";
let bytes = std::fs::read(&legacy).unwrap_or_default();
let legacy_names_ours = bytes.windows(MARKER.len()).any(|window| window == MARKER);
let legacy_parses = || {
std::str::from_utf8(&bytes).is_ok_and(|text| RepoConfig::parse(text).is_ok())
};
if legacy_names_ours && (!ours.exists() || !legacy_parses()) {
return Some(legacy);
}
None
ours.exists().then_some(ours)
}

impl Repository {
Expand Down
32 changes: 30 additions & 2 deletions crates/kinbase/src/company/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ use std::time::Duration;

static SEQUENCE: AtomicU64 = AtomicU64::new(0);

/// `host:port` of each Company endpoint that ran out a read budget in this
/// process.
static UNANSWERED: std::sync::OnceLock<std::sync::Mutex<std::collections::BTreeSet<String>>> =
std::sync::OnceLock::new();

/// A snapshot is a reduction over the whole Company event log, so it costs
/// what the log costs: 2.5 s against one deployment's 2,720 events and rising.
/// At 1,500 ms -- a bound sized for proof fixtures -- every repository in the
Expand Down Expand Up @@ -163,9 +168,21 @@ impl Client {
if self.oidc.is_some() || self.gateway_key.is_some() {
headers.insert(1, ("X-Kinbase-Token".to_owned(), self.token.token.clone()));
}
// An endpoint that let one request run out its read budget is not
// asked again by this process: an observation fanning out 44 Company
// candidates to a silent endpoint waited 20 s for each, 15 minutes in
// all, and every later attempt is retried by a later pass anyway.
let endpoint = format!("{}:{}", self.host, self.port);
let silent = UNANSWERED.get_or_init(Default::default);
if silent.lock().is_ok_and(|silent| silent.contains(&endpoint)) {
Comment thread
shanebarakat marked this conversation as resolved.
Resolved
return Err(ContractError::unreachable(
"Company endpoint did not answer within the read budget earlier in this process; not asked again",
)
.with_detail(json!({"timeout_observed": true, "omitted_count": 1})));
}
self.bytes_sent
.set(self.bytes_sent.get() + body_bytes.len() as u64 + 256);
http::request(
let response = http::request(
self.scheme,
&self.host,
self.port,
Expand All @@ -174,7 +191,18 @@ impl Client {
&headers,
&body_bytes,
read_timeout,
)
);
if let Err(error) = &response
&& error
.detail
.as_ref()
.and_then(|detail| detail.get("timeout_observed"))
== Some(&Value::Bool(true))
Comment thread
shanebarakat marked this conversation as resolved.
Resolved
&& let Ok(mut silent) = silent.lock()
{
silent.insert(endpoint);
}
response
}

pub fn get(&self, path: &str) -> Result<Response, ContractError> {
Expand Down
10 changes: 4 additions & 6 deletions crates/kinbase/src/corpus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@
}
}

fn store_kind(name: &str) -> crate::StoreKind {

Check warning on line 966 in crates/kinbase/src/corpus.rs

View workflow job for this annotation

GitHub Actions / build (ubuntu-24.04, x86_64-unknown-linux-gnu)

function `store_kind` is never used

Check warning on line 966 in crates/kinbase/src/corpus.rs

View workflow job for this annotation

GitHub Actions / build (ubuntu-24.04, x86_64-unknown-linux-gnu)

function `store_kind` is never used
match name {
"personal" => crate::StoreKind::Personal,
"company" => crate::StoreKind::Company,
Expand Down Expand Up @@ -1209,12 +1209,10 @@
// document would arrive with exactly the weight of the commits it is
// meant to outrank. Provenance still clamps this, so an agent-written
// document claiming `north_star` cannot reach `ratified`.
standing: match observation.atom_kind.as_deref() {
Some("north_star") | Some("invariant") | Some("directional") => {
"ratified".to_owned()
}
_ => "present".to_owned(),
},
standing: crate::model::observation_standing(
observation.atom_kind.as_deref(),
&observation.provenance,
),
provenance: observation.provenance.clone(),
governs_paths: observation.governs_paths.clone(),
anchors: observation.anchors.clone(),
Expand Down
109 changes: 88 additions & 21 deletions crates/kinbase/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,14 +615,10 @@ pub fn request(
let mut reader = BufReader::new(stream);
let mut status_line = String::new();
reader.read_line(&mut status_line).map_err(|error| {
ContractError::unreachable(format!(
"Company endpoint did not answer within the read budget ({})",
error.kind()
))
.with_detail(serde_json::json!({
"timeout_observed": true,
"omitted_count": 1
}))
read_failure(
"Company endpoint did not answer within the read budget",
error.kind(),
)
})?;
if status_line.is_empty() {
return Err(ContractError::unreachable(
Expand All @@ -640,12 +636,9 @@ pub fn request(
let mut chunked = false;
loop {
let mut line = String::new();
let read = reader.read_line(&mut line).map_err(|error| {
ContractError::unreachable(format!(
"Company endpoint headers unreadable ({})",
error.kind()
))
})?;
let read = reader
.read_line(&mut line)
.map_err(|error| read_failure("Company endpoint headers unreadable", error.kind()))?;
if read == 0 || line.trim().is_empty() {
break;
}
Expand Down Expand Up @@ -676,8 +669,10 @@ pub fn request(
if chunked || content_length.is_none() {
raw.clear();
let read = reader.by_ref().take(limit as u64 + 1).read_to_end(&mut raw);
if read.is_err() && (!chunked || raw.is_empty()) {
return Err(ContractError::unreachable("Company response truncated"));
if let Err(error) = &read
&& (!chunked || raw.is_empty())
{
return Err(read_failure("Company response truncated", error.kind()));
}
if raw.len() > limit {
return Err(ContractError::limit(
Expand All @@ -686,13 +681,15 @@ pub fn request(
));
}
if chunked {
raw = crate::classifier::decode_chunked(&raw)
.map_err(|_| ContractError::unreachable("Company response truncated"))?;
raw = crate::classifier::decode_chunked(&raw).map_err(|_| match &read {
Err(error) => read_failure("Company response truncated", error.kind()),
Ok(_) => ContractError::unreachable("Company response truncated"),
})?;
}
} else if !raw.is_empty() {
reader.read_exact(&mut raw).map_err(|error| {
ContractError::unreachable(format!("Company response truncated ({})", error.kind()))
})?;
reader
.read_exact(&mut raw)
.map_err(|error| read_failure("Company response truncated", error.kind()))?;
}
let body = if raw.is_empty() {
Value::Null
Expand All @@ -703,6 +700,76 @@ pub fn request(
Ok(Response { status, body, raw })
}

/// A failed read of a Company answer. Every phase (status line, headers,
/// body) waits on the same read budget, so each says whether the budget ran
/// out: a timeout surfaces as WouldBlock on macOS and TimedOut on Linux, while
/// a reset or other read error is not a spent budget.
fn read_failure(message: &str, kind: std::io::ErrorKind) -> ContractError {
ContractError::unreachable(format!("{message} ({kind})")).with_detail(serde_json::json!({
"timeout_observed": matches!(
kind,
std::io::ErrorKind::WouldBlock | std::io::ErrorKind::TimedOut
),
"omitted_count": 1
}))
}

#[cfg(test)]
mod read_budget_tests {
use super::*;
use std::net::TcpListener;

/// Answer one request with `sent`, then hold the connection open, silent.
fn stalled_after(sent: &'static [u8]) -> ContractError {
let listener = TcpListener::bind("127.0.0.1:0").expect("bind");
let port = listener.local_addr().expect("address").port();
let server = std::thread::spawn(move || {
let (mut stream, _) = listener.accept().expect("accept");
let mut head = [0u8; 4096];
let _ = stream.read(&mut head);
let _ = stream.write_all(sent);
std::thread::sleep(Duration::from_millis(600));
});
let outcome = request(
Scheme::Http,
"127.0.0.1",
port,
"GET",
"/",
&[],
&[],
Duration::from_millis(200),
);
let _ = server.join();
match outcome {
Ok(response) => panic!("a stalled answer must fail, got status {}", response.status),
Err(error) => error,
}
}

#[test]
fn a_stall_after_the_status_line_is_a_spent_read_budget() {
let sends: [&'static [u8]; 3] = [
b"HTTP/1.1 200 OK\r\n",
b"HTTP/1.1 200 OK\r\nContent-Length: 10\r\n\r\n{}",
b"HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n2\r\n{}\r\n",
];
for sent in sends {
let error = stalled_after(sent);
assert_eq!(error.code, "COMPANY_UNREACHABLE");
assert_eq!(
error
.detail
.as_ref()
.and_then(|detail| detail.get("timeout_observed")),
Some(&serde_json::Value::Bool(true)),
"{}",
String::from_utf8_lossy(sent)
);
}
}
}

#[cfg(test)]
mod error_body_tests {
use super::*;
Expand Down
2 changes: 2 additions & 0 deletions crates/kinbase/src/ingest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
asserted_at: Option<String>,
effective_from: Option<String>,
effective_until: Option<String>,
receipt_observed_at: Option<String>,

Check warning on line 25 in crates/kinbase/src/ingest.rs

View workflow job for this annotation

GitHub Actions / build (ubuntu-24.04, x86_64-unknown-linux-gnu)

fields `receipt_observed_at`, `receipt_expires_at`, and `environment_id` are never read

Check warning on line 25 in crates/kinbase/src/ingest.rs

View workflow job for this annotation

GitHub Actions / build (ubuntu-24.04, x86_64-unknown-linux-gnu)

fields `receipt_observed_at`, `receipt_expires_at`, and `environment_id` are never read
receipt_expires_at: Option<String>,
environment_id: Option<String>,
owner_id: Option<String>,
Expand Down Expand Up @@ -1200,6 +1200,8 @@
"repository_id": observation.repository_id,
"revision": observation.revision,
"branch": observation.branch,
"provenance": observation.provenance,
"standing": crate::model::observation_standing(observation.atom_kind.as_deref(), &observation.provenance),
"disposition": disposition,
"state": state,
"observation_state": state,
Expand Down
Loading
Loading