Skip to content

feat: temporal-validity fields on learnings (#146) - #156

Merged
jflowers merged 7 commits into
unbound-force:mainfrom
jflowers:opsx/learning-temporal-validity
Nov 7, 2026
Merged

jflowers merged 7 commits into
unbound-force:mainfrom
jflowers:opsx/learning-temporal-validity

Conversation

@jflowers

@jflowers jflowers commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Closes #146. Part of #153.

Summary

store_learning now records the code state a learning was true against, and optional provenance:

  • as_of (automatic): <repo>@<HEAD sha> for the vault's git repository, resolved via an injected resolver (git rev-parse, 2 s timeout). Omitted when the vault isn't a git repo; storing never fails because of git.
  • evidence: optional locator list (max 50, each ≤512 chars; trimmed, deduped).
  • validity: optional current | stale-unverified | superseded | historical. Absent means unknown.
  • supersedes: optional identity or learning/<identity>. The target gains superseded_by and validity: superseded in the store and in its markdown frontmatter (body untouched, tier unchanged, never deleted). One successor per learning; a second supersession is rejected. If the back-link fails after the new learning is stored, the response carries supersedes_warning.

All validation runs before any write, so an invalid call writes nothing. Fields live in the existing properties JSON (no schema change), so every read tool returns them already. They round-trip through reIngestLearnings. Legacy files re-ingest unchanged.

Spec: openspec/changes/learning-temporal-validity/ (proposal, design D1–D6, spec, tasks).

Changes

  • tools/learning_temporal.go (new): pure helpers for validation, properties, frontmatter, the as_of resolver, and in-place frontmatter key updates, plus the supersession lookup and back-link.
  • tools/learning.go: StoreLearning wiring; NewLearning defaults the resolver; WithAsOfResolver for injection.
  • main.go: learningFrontmatter fields; properties() replaces the inline map in reIngestLearnings, which now has fewer branches.
  • types/tools.go, server.go: input fields and tool description.
  • README: new "Temporal Validity" section and tool-table row.

Verification (CI parity, Go 1.26.5 locally; CI pins 1.25)

  • go build ./..., go vet ./...: clean
  • go test -race -count=1 -coverprofile=coverage.out ./...: all packages pass
  • gaze crap --max-crapload=48 --max-gaze-crapload=45: CRAPload 45/48, GazeCRAPload 41/45, unchanged from main
  • golangci-lint run: no new findings. The remaining QF1012/SA1019 findings are pre-existing on main.

Out of scope

Drift detection (#147), validity-aware retrieval (#148), supersession in compile (#150), and multi-repo pins (#106).

Before ready

  • /uf.review-council (AGENTS.md prerequisite; runs in OpenCode)
  • Website docs sync for the new store_learning fields

🤖 Generated with Claude Code

@jflowers jflowers left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: The council verdict is REQUEST CHANGES, but GitHub does not allow requesting changes on one’s own pull request — posted as a comment review instead.

Council Review — REQUEST CHANGES

The Divisor review council ran five personas (adversary, architect, curator, guard, testing) over this 13-file, 1245-line diff. Four personas returned APPROVE WITH ADVISORIES; curator requested changes. Consolidated verdict: REQUEST CHANGES, on one HIGH finding plus MEDIUM hardening items.

Blocking

  • HIGH — Website docs-sync issue missing. The Website Documentation Sync rule (AGENTS.md) requires a unbound-force/website issue for user-facing MCP tool changes; issue searches on temporal/store_learning/supersede/epistemic find no match. File gh issue create --repo unbound-force/website --title "docs: sync dewey learning temporal validity documentation" --label docs covering the new evidence/validity/supersedes inputs, automatic as_of, supersedes_warning, frontmatter keys, and supersession semantics, then record the number in tasks.md (repo precedent: dewey-distill tracked website#371/#376/#377). This matches the PR's unchecked "website docs sync" box.

Should fix before merge (MEDIUM)

  • AGENTS.md is stale — the Store Learning API section (line 442) omits the new inputs, the as_of automatic field, and supersedes_warning; ## Recent Changes has no entry for this change. (AGENTS.md is outside this diff, so no inline anchor.)
  • linkSuperseded discards the properties unmarshal error (tools/learning_temporal.go:189): unparseable properties become an empty map and store.UpdatePage replaces the column wholesale; a JSON null panics on nil-map assignment. CS-006 on a data-modifying path.
  • Path traversal in markSupersededFile (tools/learning_temporal.go:207): the store page name flows unvalidated into a filesystem write; a crafted identity in a git-synced learnings file can redirect the write outside the learnings directory. SC-003/SC-004.
  • Three test gaps (TC-009): the SourceID != SourceLearning rejection branch never executes; supersedes_warning is never observed present through StoreLearning; evidence is asserted by length only.

Advisories (LOW)

Concurrency hardening (gitOutput context, supersession check-then-act race), cross-package key↔property duplication with no combined round-trip test, writeLearningFile at 7 positional params, delta-spec missing explicit ## MODIFIED/## REMOVED sections, evidence bound in bytes vs documented characters, testing.Short() guard for git-subprocess tests, repo-wide spec FR-id numbering gap (not introduced here), and a #153-epic blog candidate for later phases. See inline comments.

What looks good

Validation-before-write ordering in prepareTemporal, supersession that never deletes and preserves tier, full round-trip through markdown re-ingestion with legacy compatibility, 412 lines of focused tests, and green CI (build-and-test, MegaLinter).

Severity Count
HIGH 1
MEDIUM 6
LOW 10

This review was generated by /uf.review-pr (AI-assisted).

Comment thread tools/learning_temporal.go Resolved
Comment thread tools/learning_temporal_test.go Resolved
Comment thread tools/learning_temporal.go Resolved
Comment thread tools/learning_temporal_test.go Resolved
Comment thread tools/learning_temporal_test.go Resolved
Comment thread tools/learning_temporal.go Resolved
Comment thread tools/learning_temporal.go Resolved
Comment thread tools/learning_temporal.go Resolved
Comment thread tools/learning.go Resolved
jflowers added a commit to jflowers/dewey that referenced this pull request Nov 5, 2026
Addresses PR unbound-force#156 review feedback from @jflowers.

- Fail closed on unreadable supersession properties: both
  resolveSupersededTarget and linkSuperseded now surface JSON unmarshal
  errors instead of silently proceeding with an empty properties map,
  which could fork supersession chains or drop the target's properties.
  A literal JSON null in stored properties no longer panics the link.
- Validate learning identities at both trust boundaries: a forged
  frontmatter identity containing path separators or ".." traversal is
  rejected by the new tools.ValidLearningIdentity check before
  resolveSupersededTarget joins it into a store lookup and before
  reIngestLearnings (main.go) ingests it, so supersession writes cannot
  escape the learnings directory (SC-004). Characters beyond [a-z0-9-]
  remain allowed because identities embed git-configured author names.
- Count the evidence length bound in characters (runes), not bytes,
  matching the spec's "at most 512 characters" (multi-byte locators no
  longer over-reject).
- Replace writeLearningFile's positional parameters with a
  learningFileOpts struct (three adjacent string arguments were a silent
  transposition risk).
- Tests: seed a non-learning page so the SourceID rejection branch
  executes; assert evidence values across result, store, and frontmatter
  surfaces; pin the supersedes_warning partial-failure field end-to-end;
  add a composed tools-to-main round-trip test for the temporal key
  mapping; cover corrupt/null properties, traversal targets, and unsafe
  re-ingested identities; guard TestProductionAsOfResolver with
  testing.Short().
- Spec: add explicit empty MODIFIED/REMOVED sections to the delta spec;
  record the website docs-sync issue (unbound-force/website#380).

Signed-off-by: John Flowers <[email protected]>
Assisted-by: glm-5
jflowers added a commit to jflowers/dewey that referenced this pull request Nov 5, 2026
Addresses PR unbound-force#156 review feedback from @jflowers.

- Fail closed on unreadable supersession properties: both
  resolveSupersededTarget and linkSuperseded now surface JSON unmarshal
  errors instead of silently proceeding with an empty properties map,
  which could fork supersession chains or drop the target's properties.
  A literal JSON null in stored properties no longer panics the link.
- Validate learning identities at both trust boundaries: a forged
  frontmatter identity containing path separators or ".." traversal is
  rejected by the new tools.ValidLearningIdentity check before
  resolveSupersededTarget joins it into a store lookup and before
  reIngestLearnings (main.go) ingests it, so supersession writes cannot
  escape the learnings directory (SC-004). Characters beyond [a-z0-9-]
  remain allowed because identities embed git-configured author names.
- Count the evidence length bound in characters (runes), not bytes,
  matching the spec's "at most 512 characters" (multi-byte locators no
  longer over-reject).
- Replace writeLearningFile's positional parameters with a
  learningFileOpts struct (three adjacent string arguments were a silent
  transposition risk).
- Tests: seed a non-learning page so the SourceID rejection branch
  executes; assert evidence values across result, store, and frontmatter
  surfaces; pin the supersedes_warning partial-failure field end-to-end;
  add a composed tools-to-main round-trip test for the temporal key
  mapping; cover corrupt/null properties, traversal targets, and unsafe
  re-ingested identities; guard TestProductionAsOfResolver with
  testing.Short().
- Spec: add explicit empty MODIFIED/REMOVED sections to the delta spec;
  record the website docs-sync issue (unbound-force/website#380).

Signed-off-by: John Flowers <[email protected]>
Assisted-by: glm-5
@jflowers
jflowers force-pushed the opsx/learning-temporal-validity branch from 63bc040 to c314f22 Compare November 5, 2026 19:01
jflowers and others added 5 commits November 5, 2026 19:19
store_learning pins as_of (<repo>@<HEAD sha>) and accepts optional
evidence locators, a validity status, and supersedes. Supersession
links both ways: the target gains superseded_by and validity:
superseded in the store and its markdown backup, never deleted.
All fields round-trip through re-ingestion.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Addresses PR unbound-force#156 review feedback from @jflowers.

- Fail closed on unreadable supersession properties: both
  resolveSupersededTarget and linkSuperseded now surface JSON unmarshal
  errors instead of silently proceeding with an empty properties map,
  which could fork supersession chains or drop the target's properties.
  A literal JSON null in stored properties no longer panics the link.
- Validate learning identities at both trust boundaries: a forged
  frontmatter identity containing path separators or ".." traversal is
  rejected by the new tools.ValidLearningIdentity check before
  resolveSupersededTarget joins it into a store lookup and before
  reIngestLearnings (main.go) ingests it, so supersession writes cannot
  escape the learnings directory (SC-004). Characters beyond [a-z0-9-]
  remain allowed because identities embed git-configured author names.
- Count the evidence length bound in characters (runes), not bytes,
  matching the spec's "at most 512 characters" (multi-byte locators no
  longer over-reject).
- Replace writeLearningFile's positional parameters with a
  learningFileOpts struct (three adjacent string arguments were a silent
  transposition risk).
- Tests: seed a non-learning page so the SourceID rejection branch
  executes; assert evidence values across result, store, and frontmatter
  surfaces; pin the supersedes_warning partial-failure field end-to-end;
  add a composed tools-to-main round-trip test for the temporal key
  mapping; cover corrupt/null properties, traversal targets, and unsafe
  re-ingested identities; guard TestProductionAsOfResolver with
  testing.Short().
- Spec: add explicit empty MODIFIED/REMOVED sections to the delta spec;
  record the website docs-sync issue (unbound-force/website#380).

Signed-off-by: John Flowers <[email protected]>
Assisted-by: glm-5
Updates the Store Learning API section with the temporal-validity
inputs (evidence, validity, supersedes), the automatic as_of pin,
and the supersedes_warning result field, and adds a Recent Changes
entry for learning-temporal-validity.

Addresses the documentation advisory from the /uf.review-council run
(correlation e178433f-e46f-47a0-b6b6-a77f5d744455) — flagged by
three reviewers independently. Documentation-only: council-exempt
per AGENTS.md; no code changes between APPROVE and push.

Signed-off-by: John Flowers <[email protected]>
Assisted-by: glm-5
Stores the knowledge artifacts produced by this address-feedback
workflow's review dispatches: Tier 2 assessment proposals for items
3, 4, 5, 6, 8, 11 and the review-council consolidation proposals
(correlation e178433f-e46f-47a0-b6b6-a77f5d744455). Credential
screened; follows the Learnings Direct-Commit Practice and the
004b1ca precedent. Older stranded learnings are left for a
deliberate 'dewey artifacts sync' sweep.

Signed-off-by: John Flowers <[email protected]>
Assisted-by: glm-5
@jflowers
jflowers force-pushed the opsx/learning-temporal-validity branch from c314f22 to 1a039d0 Compare November 6, 2026 00:19
jflowers added a commit to jflowers/dewey that referenced this pull request Nov 6, 2026
)

Port the unbound-force#156 review-council hardening to lint: markStaleUnverified
validates the identity with ValidLearningIdentity and decodes
properties before writing, so an unsafe identity or unreadable
properties fails closed and a JSON null no longer panics. Only
hexadecimal as_of pins reach git as a revision. Git subprocess tests
are skipped in short mode.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n race scope

Addresses PR unbound-force#156 review feedback from @jflowers.

- D2: record why the as_of git pin resolver deliberately runs under
  context.Background() — as_of is artifact provenance that must not
  depend on the requester's connection lifetime, the 2-second timeout
  bounds the subprocess cost, and failure only omits the pin. Threading
  a context would widen the AsOfResolver signature across every
  resolver and test double; revisit with multi-repo pinning (unbound-force#106).
- Risks: scope the concurrent-supersession window precisely — the
  store lock serializes processes, while the unserialized window is
  concurrent in-process tool calls under streamable HTTP sharing one
  store handle. Tracked in unbound-force#166; candidate fix is a compare-and-swap
  update or per-target mutex covering both write legs (store and
  markdown file).

Signed-off-by: John Flowers <[email protected]>
Assisted-by: glm-5
Stores the knowledge artifacts produced by this address-feedback
round's Tier 2 review dispatches (correlations
f34de7bb-a361-4de4-9d6f-11e16731523a and
2348ad4f-14c4-4eba-9ae2-e6c32eece3a1): as_of context-threading
deferral grounds and the concurrent-supersession race scope.
Credential screened; follows the Learnings Direct-Commit Practice
and the 1a039d0 precedent.

Signed-off-by: John Flowers <[email protected]>
Assisted-by: glm-5

@uf-divisor uf-divisor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Council Review — APPROVE WITH ADVISORIES

The Divisor review council ran five personas (adversary @heavy; architect, curator, guard, testing @standard) over the 53-file, +2035/−40 diff. All five returned APPROVE WITH ADVISORIES; consolidated verdict: APPROVE WITH ADVISORIES — 18 findings (5 MEDIUM, 13 LOW; two pairs deduplicated for display), zero CRITICAL/HIGH. Correlation 9fced223-47dd-4e5a-b6f2-a90d0ae48177.

Round-1 verification

The Nov-5 council's REQUEST CHANGES items are verified addressed: website#380 filed and recorded (tasks.md 6.4); linkSuperseded/resolveSupersededTarget fail closed on unreadable properties (JSON null no longer panics); ValidLearningIdentity rejects traversal at both trust boundaries; the evidence bound counts runes; the test gaps are covered (SourceID branch, supersedes_warning end-to-end, evidence across surfaces, composed round-trip); AGENTS.md's Store Learning API section is synced; and design D2/Risks record the as_of context and #166 race-scope grounds (2205bf1).

Advisories — MEDIUM

  1. Error-wrap breaks the chain — tools/learning_temporal.go:190 wraps the GetPage failure with %v instead of %w (go.md CS-006 MUST); one-character fix.
  2. Missing blog issue — no unbound-force/website blog issue for the first #153 increment, per the dewey-publish 7.8 convention (verified absent). Issue creation is prohibited in review; file manually.
  3. Missing tutorial issue — same convention, tutorial leg for the new supersession workflow. File manually.
  4. website#380 body misdescribes the contract — drops stale-unverified, invents a validity default, and claims a non-existent as_of fallback (recorded in committed learning documentation-pipeline-…180338). Correct before the sync executes.
  5. Seven truncated learning files — the 14:11 batch on 2026-11-05 is cut mid-sentence at ~512 chars (stored from the lossy dispatch projection). Amend or drop per the Learnings Direct-Commit Practice.

Advisories — LOW

Symlink-following rewrite and in-place truncate-write in markSupersededFile (defense-in-depth); learningsDir path duplication; gitOutput/productionGitResolver parallel with a duplicated 2s literal; validValidities package-level map (CS-007); unsafe-identity skip behavior unrecorded in the delta; FR-id pack-vs-practice divergence (repo-level decision); LookPath guard after the subprocess assertion; SHA oracle reuses gitOutput; NewLearning default resolver breaks six tests' hermeticity; evidence fixture of 51 identical entries couples the count bound to pre-dedupe semantics (tools/learning_temporal_test.go:105).

What looks good

Validation-before-write ordering; supersession that never deletes and preserves tier; full round-trip through markdown re-ingestion with legacy compatibility; 800+ lines of focused tests; clean CI (build-and-test, MegaLinter) on the head.

Severity Count
MEDIUM 5
LOW 13

This review was generated by /uf.review-pr (AI-assisted).

}
page, err := l.store.GetPage(store.LearningPrefix + identity)
if err != nil {
return nil, fmt.Errorf("supersedes: failed to look up learning %q: %v", identity, err)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MEDIUM] error-handling (CS-006) — resolveSupersededTarget wraps the store.GetPage failure with %v ("supersedes: failed to look up learning %q: %v") instead of %w, discarding the error chain. The properties-unmarshal wrap eight lines below (line 198) and gitOutput both use %w, so the mix reads as an oversight rather than a choice — go.md CS-006 [MUST] requires fmt.Errorf("context: %w", err). The error renders to a terminal MCP result string today, so nothing breaks now; the intra-file inconsistency invites copy-paste into code that inspects chains with errors.Is/errors.As. The fix is one character: %v → %w. (found independently by adversary and architect)

- [ ] 6.3 `/uf.review-council` (OpenCode), draft PR
- [x] 6.4 Website docs-sync issue filed:
unbound-force/website#380 (AGENTS.md Website Documentation
Sync rule)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MEDIUM] content-pipeline — No blog or tutorial issue exists in unbound-force/website for this capability (verified by searching open issues for "temporal validity", "supersedes", "epistemic", and the blog/tutorial label lists — only docs-sync #380 exists). The dewey-publish 7.8 convention files all three legs for capability changes, and every sibling followed it (dewey-distill → #377/#376, gateway → #374/#375, providers → #116/#114); tasks.md phase 6 models only the docs-sync leg (6.4). This is the first shipped increment of the #153 epistemic-integrity arc — a strong blog candidate (the 347-claim verification story) and a new agent-facing supersession workflow worth a tutorial. Issue creation is prohibited in this review, so file manually and record the numbers in tasks.md. (curator)

tier: draft
---

Docs-sync issue verification must cover enumerated values, defaults, and fallback claims, not just tool lists. dewey PR #156's website#380 body listed validity as "current | superseded | historical (default current)" while the shipped enum is current, stale-unverified, superseded, historical with absent meaning unknown (no default) — an invented default plus a dropped enum value, alongside a claimed as_of "wall-clock fallback" that does not exist (failure omits as_of entirely).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MEDIUM] documentation-accuracy — This learning records that website#380's body misdescribes the shipped contract: it lists validity as "current | superseded | historical (default current)" — dropping stale-unverified and inventing a default where absent means unknown — and claims an as_of "wall-clock fallback" that does not exist (resolver failure omits as_of entirely). The shipped enum lives in validValidities (tools/learning_temporal.go) and the no-default/no-fallback semantics are documented in README.md and AGENTS.md. If the website team executes the sync from the current body, public docs will misdocument store_learning against the website repo's Content Accuracy constitution. Verify and correct the issue body before merge. (guard)

tier: draft
---

In Go, silently discarding json.Unmarshal's error before a read-modify-write is destructive in two ways: (1) unmarshaling the literal JSON `null` into a map variable sets it to nil, so a subsequent `m[k] = v` panics with "assignment to entry in nil map"; (2) an unparseable payload leaves the map empty, so writing the reconstructed map back replaces the stored document wholesale (e.g., a SQLite UPDATE that sets the whole column), silently destroying the original fields. On any read-modify-write path, treat a

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MEDIUM] artifact-integrity — Seven of the 39 learning files in this PR end mid-sentence at ~512 characters, all from the 14:11:00–14:11:10 batch on 2026-11-05: error-handling-…141100, path-safety-…141102, spec-governance-…141104, yaml-frontmatter-…141105, documentation-pipeline-…141107 and …141108, and test-quality-…141110. Other batches are complete. The texts were stored from the dispatch summary projection, which caps proposal information at 512 characters. These files are the durable, non-rebuildable records the Learnings Direct-Commit Practice commits; amend the bodies before merge (identity lives in frontmatter, so body edits are re-ingestion-safe) or drop them per the practice's "not ready to be public" rule. (guard)

var updated string
updated, err = setFrontmatterKeys(string(content), [][2]string{{"superseded_by", successor}, {"validity", "superseded"}})
if err == nil {
err = os.WriteFile(path, []byte(updated), 0o644)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[LOW] path-safety / resilience — Two defense-in-depth gaps in markSupersededFile's rewrite of the backup: (1) os.ReadFile + os.WriteFile both follow symlinks, so a symlink planted at .uf/dewey/learnings/<identity>.md routes the frontmatter rewrite to its target — ValidLearningIdentity closes the identifier channel but not the file-type channel, while writeLearningFile's O_CREATE|O_EXCL refuses symlinks by construction; an os.Lstat/IsRegular() guard (or O_NOFOLLOW) closes it. (2) The in-place os.WriteFile truncates before writing, so a crash or disk-full mid-rewrite corrupts the file-backed copy whose purpose is surviving graph.db loss; write-temp-then-os.Rename restores atomicity. Practical exploitability is low. (adversary)


// gitOutput runs `git -C dir args...` with a 2-second timeout and returns
// its trimmed stdout.
func gitOutput(dir string, args ...string) (string, error) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[LOW] dry — gitOutput parallels the pre-existing productionGitResolver (tools/learning.go:161-171), including the 2*time.Second bound duplicated as a magic literal in both. Delegating (with empty-dir handling, since git -C "" is not equivalent to running in CWD) or sharing a named gitSubprocessTimeout constant gives the bounded-subprocess policy one definition. (architect)

@@ -0,0 +1,87 @@
## ADDED Requirements

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[LOW] spec-conventions — The delta uses the repo's id-less requirement format while the always-loaded meta-prompt pack requires FR ids (MP-002), id lines (MP-013), and a numbering allocation header (MP-014). The id-less format is uniform across every sibling delta — the committed learning spec-governance-…141104 documents the same deviation across 25 changes — so this change matches established practice; the divergence is pack-vs-practice, not this PR. Codifying the exception in meta-prompt-custom.md (or one migration change adopting ids) stops every future review from re-litigating it. (architect + guard)

t.Errorf("as_of = %q, want %q", got, want)
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[LOW] assertion-depth — The expected SHA is computed via gitOutput(repo, "rev-parse", "HEAD") — the same helper productionAsOfResolver calls internally — so a regression inside gitOutput (trimming, argument order) alters both sides equally and cannot fail the test. The basename and repo@sha format are independently asserted; computing the expected SHA with a direct exec.Command makes the oracle independent. (testing)


// validValidities is the closed set of validity statuses a learning may
// carry. Absent validity means unknown.
var validValidities = map[string]bool{

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[LOW] conventions (CS-007) — validValidities is a package-level map in a package whose convention reserves package-level state for the logger (go.md CS-007 [MUST]). The map never mutates, so the risk is latent; a switch in validateValidity — which already enumerates the values in its error message — or a function-scoped map complies and removes the mutability surface. (architect)

Comment thread tools/learning.go
maxChunkChars: maxChunkChars,
asOfResolver: productionAsOfResolver(vaultPath),
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[LOW] test-isolation — NewLearning now defaults asOfResolver to productionAsOfResolver(vaultPath), so pre-existing vault-backed tests constructing the handler without WithAsOfResolver (tools/learning_test.go lines 625, 949, 1030, 1079, 1138, 1189) spawn a git subprocess per StoreLearning call, probing TMPDIR's git state. The probe fails fast and is bounded, and the assertions are substring/regex-based, so no failure is constructible — but those tests now depend on environment state for a path they don't exercise. WithAsOfResolver(nil) on those constructions restores hermeticity; the new tests already model the injection pattern. (testing)

@uf-divisor
uf-divisor self-requested a review November 7, 2026 21:42
@jflowers
jflowers merged commit c4ad758 into unbound-force:main Nov 7, 2026
2 checks passed
jflowers added a commit that referenced this pull request Nov 7, 2026
Addresses PR #156 review feedback from @jflowers.

- Fail closed on unreadable supersession properties: both
  resolveSupersededTarget and linkSuperseded now surface JSON unmarshal
  errors instead of silently proceeding with an empty properties map,
  which could fork supersession chains or drop the target's properties.
  A literal JSON null in stored properties no longer panics the link.
- Validate learning identities at both trust boundaries: a forged
  frontmatter identity containing path separators or ".." traversal is
  rejected by the new tools.ValidLearningIdentity check before
  resolveSupersededTarget joins it into a store lookup and before
  reIngestLearnings (main.go) ingests it, so supersession writes cannot
  escape the learnings directory (SC-004). Characters beyond [a-z0-9-]
  remain allowed because identities embed git-configured author names.
- Count the evidence length bound in characters (runes), not bytes,
  matching the spec's "at most 512 characters" (multi-byte locators no
  longer over-reject).
- Replace writeLearningFile's positional parameters with a
  learningFileOpts struct (three adjacent string arguments were a silent
  transposition risk).
- Tests: seed a non-learning page so the SourceID rejection branch
  executes; assert evidence values across result, store, and frontmatter
  surfaces; pin the supersedes_warning partial-failure field end-to-end;
  add a composed tools-to-main round-trip test for the temporal key
  mapping; cover corrupt/null properties, traversal targets, and unsafe
  re-ingested identities; guard TestProductionAsOfResolver with
  testing.Short().
- Spec: add explicit empty MODIFIED/REMOVED sections to the delta spec;
  record the website docs-sync issue (unbound-force/website#380).

Signed-off-by: John Flowers <[email protected]>
Assisted-by: glm-5
jflowers added a commit that referenced this pull request Nov 7, 2026
…n race scope

Addresses PR #156 review feedback from @jflowers.

- D2: record why the as_of git pin resolver deliberately runs under
  context.Background() — as_of is artifact provenance that must not
  depend on the requester's connection lifetime, the 2-second timeout
  bounds the subprocess cost, and failure only omits the pin. Threading
  a context would widen the AsOfResolver signature across every
  resolver and test double; revisit with multi-repo pinning (#106).
- Risks: scope the concurrent-supersession window precisely — the
  store lock serializes processes, while the unserialized window is
  concurrent in-process tool calls under streamable HTTP sharing one
  store handle. Tracked in #166; candidate fix is a compare-and-swap
  update or per-target mutex covering both write legs (store and
  markdown file).

Signed-off-by: John Flowers <[email protected]>
Assisted-by: glm-5
jflowers added a commit to jflowers/dewey that referenced this pull request Nov 8, 2026
)

Port the unbound-force#156 review-council hardening to lint: markStaleUnverified
validates the identity with ValidLearningIdentity and decodes
properties before writing, so an unsafe identity or unreadable
properties fails closed and a JSON null no longer panics. Only
hexadecimal as_of pins reach git as a revision. Git subprocess tests
are skipped in short mode.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
jflowers added a commit to jflowers/dewey that referenced this pull request Nov 10, 2026
)

Port the unbound-force#156 review-council hardening to lint: markStaleUnverified
validates the identity with ValidLearningIdentity and decodes
properties before writing, so an unsafe identity or unreadable
properties fails closed and a JSON null no longer panics. Only
hexadecimal as_of pins reach git as a revision. Git subprocess tests
are skipped in short mode.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
jflowers added a commit to jflowers/dewey that referenced this pull request Nov 10, 2026
)

Port the unbound-force#156 review-council hardening to lint: markStaleUnverified
validates the identity with ValidLearningIdentity and decodes
properties before writing, so an unsafe identity or unreadable
properties fails closed and a JSON null no longer panics. Only
hexadecimal as_of pins reach git as a revision. Git subprocess tests
are skipped in short mode.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
jflowers added a commit that referenced this pull request Nov 10, 2026
Port the #156 review-council hardening to lint: markStaleUnverified
validates the identity with ValidLearningIdentity and decodes
properties before writing, so an unsafe identity or unreadable
properties fails closed and a JSON null no longer panics. Only
hexadecimal as_of pins reach git as a revision. Git subprocess tests
are skipped in short mode.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jflowers
jflowers deleted the opsx/learning-temporal-validity branch November 15, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: temporal-validity fields on learnings (as_of, evidence, validity, supersedes)

2 participants