knowledge: clock-duration assertions, path-valued config, call-site enumeration, guard sharpening - #23
Open
choiyounggi wants to merge 1 commit into
Open
knowledge: clock-duration assertions, path-valued config, call-site enumeration, guard sharpening#23choiyounggi wants to merge 1 commit into
choiyounggi wants to merge 1 commit into
Conversation
4 new pages, 5 amendments, 1 new category (backend/common/refactoring). - testing/quality/injected-clock-duration-assertions — one-sided tolerance on duration bounds; start the fake clock at 0.0 (PEP 564 records CPython doing the same for monotonic()/perf_counter()). Measured start-value table. - infrastructure/config/path-valued-config — reject a non-absolute path key at startup; a missing directory globs to an empty result, not an error. Verified by a launchd probe: no WorkingDirectory key => cwd=/. - backend/common/refactoring/call-site-enumeration — enumerate by callee or find-references, not by parameter name; positional calls carry no name. - testing/quality/guard-shape-vs-consequence — sharpen an artifact guard from shape S to "S and consequence C" instead of exempting (field-tested). Amendments: environment-config and background-services edge rows plus the systemd.exec WorkingDirectory default; reciprocal related-links on three testing pages.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Drained 4 pending candidates from
~/.dev-loop/queue. All four survived research and are ingested: 4 new pages, 5 amendments, 1 new category. Three areconfidence: verified; one isfield-testedand says so.testing/quality/injected-clock-duration-assertions.md(new)infrastructure/config/path-valued-config.md(new)backend/common/refactoring/call-site-enumeration.md(new)testing/quality/guard-shape-vs-consequence.md(new)Verified best-practice
1 — Duration assertions against an injected float clock
Claim as queued: with a fake monotonic clock started at a large value (e.g.
1000.0),assert gap >= intervalfails on correct code; add a small tolerance or start the clock at0.0.Verified — and the claim was too narrow. Reproduced locally (CPython 3.14.6, macOS) across start values for a
1.05step:start + 1.05 - start>= 1.05?0.01.051.01.0499999999999998100.01.04999999999999721000.01.04999999999995451e61.05000000004656611e91.0499999523162842Two corrections folded into the page: a start of
1.0already breaks the exact comparison (not just "large" values), and the error is not always negative — at1e6the gap came out larger than the interval, so equality and upper-bound assertions need tolerance on both sides. Every listed start satisfiesgap >= 1.05 - 1e-6.Sources checked:
monotonic()andperf_counter()clocks at zero on some platforms which indirectly reduce the precision loss." Also "thefloattype starts to lose nanoseconds after 104 days."math.isclose— signature(a, b, *, rel_tol=1e-09, abs_tol=0.0); symmetric, which is why the page routes it to the equality row only: on a lower boundisclosealso accepts a gap that is too short, the exact defect a rate-limit test guards.pytest.approx— default rel tol1e-6, abs tol1e-12; justifies the page's1e-6default.2 — A path-valued config key must be absolute
Claim as queued: when a launcher owns the CWD, reject a relative path env var with
ValueErrorrather than resolving it against CWD; a missing dir globs to[]and looks like "no work today".Verified by controlled experiment. Installed a LaunchAgent with
ProgramArguments+RunAtLoadand noWorkingDirectorykey; it recordedcwd=/,PWD=/, and a relative./data/signalslookup reported "No such file or directory". Plist booted out and removed afterwards. Independently, launchd-spawnedloginwindowalso reports cwd/underlsof.The silent-failure half also reproduced:
glob.glob("/nonexistent-xyz/*.json")returns[]andPath(...).glob(...)yields nothing — neither raises — whileos.listdiron the same path raisesFileNotFoundError. AndPath("~/data").expanduser().is_absolute()isTruewhilePath("./data").expanduser().is_absolute()isFalse, which is what makes the queued implementation'sexpanduser()-then-is_absolute()order correct.Sources checked:
WorkingDirectory=: "If not set, defaults to the root directory when systemd is running as a system instance and the respective user's home directory if run as user." This adds a nuance the candidate did not have: systemd user units default to$HOME, not/— so the same relative path resolves to three different places across launchd / systemd-system / systemd-user. That nuance is now in the page and in thebackground-servicesedge row.launchd.plist(5)(local man page) —WorkingDirectoryis "This optional key is used to specify a directory to chdir(2) to before running the job": optional, nothing inherited from the installer.3 — Enumerate call sites by callee, not parameter name
Claim as queued: grep the callee (
verify(), not the parameter name (repo_rows=), because positional calls carry no parameter name; sweep test helpers separately.Verified, mechanism reproduced. For a file holding both a keyword call and a positional call,
grep -n "repo_rows"returns 2 hits (definition + keyword call) whilegrep -n "verify("returns 3 (definition + both calls) — the positional call is invisible to the parameter-name search.Two additions the candidate did not have, both verified:
textDocument/referencesresolves the symbol, so it returns positional and keyword calls alike and does not over-match a same-named function on another type. Callee grep is now the documented fallback.TypeError: verify() takes 3 positional arguments but 4 were giveninstead of silently binding into a neighbouring parameter. Verified locally.Also cited: Python calls reference for the positional/keyword binding rules. The original field evidence (linkly: 13 keyword hits →
Ran 472 tests / FAILED (failures=11), plus arows_for()helper feeding 5 more sites) is preserved in the page's Sources.4 — Sharpen an artifact guard from shape to consequence
Claim as queued: when a repo-wide guard asserting "no artifact has shape S" fires on a legitimate artifact, rewrite it as "no artifact has S and the consequence C", computing C via the production derivation.
Kept
confidence: field-tested, deliberately. The failure mode is sourced — Google Testing Blog, Change-Detector Tests Considered Harmful (Alex Eagle, 2015-01-27): "Change-detector tests do not add clarity, and you cannot safely refactor code if you know you need to adapt the tests afterwards to get them passing again." A shape-only guard needing an exemption per legitimate artifact is that failure at repo scope. Step 4's required-red fixture rests on pitest.org's mutation mechanic (already cited elsewhere in this wiki).But the specific technique — compute C from the production derivation, assert the exemption's reason — rests on one real case (linkly #35: the guard fired on
examples/checkout.lnpl; sharpening to "guarded call that could actually fail" via_lnpl_ops'seeded_entities/repository_callsreturned the suite toRan 518 tests / OKwhile a guarded-and-can-fail fixture still drove it red). One case is field evidence, not verification, so the page saysfield-testedand describes that context.Honest caveat on this source: the change-detector article's body would not render through fetch (only header/comments returned). The quoted sentence is the one confirmed via search snippet; the URL itself is already cited by
testing-quality-behavior-not-implementationin this wiki. No other sentence from that article is quoted.Existing-layer check
Pages read in full for overlap:
testing/index.md,infrastructure/index.md,platforms/index.md,qa/index.md,debugging/index.md,backend/index.md,testing/quality/tests-that-cannot-fail.md,testing/quality/spec-artifact-checks.md,testing/quality/behavior-not-implementation.md,testing/async/async-testing.md,infrastructure/config/environment-config.md,platforms/processes/background-services.md, plus a repo-wide grep forfloating.point|tolerance|isclose|approx|monotonic|fake clockandabsolute path|is_absolute|working directory|launchd|relative path|fail-fast.test-data-and-isolationalready says "refactor the code to accept an injected clock; that seam is the fix".async-testingcovers fake timers vs condition waits.environment-configalready mandates full-schema startup validation + "required keys get NO default".background-servicescovers minimal environment and absolute paths for binaries — but nowhere states the CWD default./fact went tobackground-services(platforms owns it). The validation directive is a new sibling page underinfrastructure/config/.behavior-not-implementationcovers "a refactor broke tests";qa/process/regression-scopecovers what to re-test.tests-that-cannot-fail(a test that can't detect) andspec-artifact-checks(per-check negative controls) are close cousins.Conflicts flagged: none. No new directive contradicts an existing one. Insight 2's directive sharpens
environment-configrule 3 ("crash on any missing or invalid key") for the path case rather than opposing it.Amendments to existing pages (5):
infrastructure/config/environment-config.md— new edge row (path-valued keys) +related:link.platforms/processes/background-services.md— new edge row (working directory defaults per manager),systemd.exec(5)added tosources:with the verbatim default quote,last_verified→ 2026-08-04,related:link.testing/quality/tests-that-cannot-fail.md— reciprocalrelated:links.testing/quality/behavior-not-implementation.md— reciprocalrelated:links.testing/async/async-testing.md— reciprocalrelated:link.Routing decision
testing/quality/injected-clock-duration-assertionstests-that-cannot-fail. Consideredasync(fake timers) anddata(time-dependent fixtures); both own adjacent concerns and are linked instead.infrastructure/config/path-valued-configenvironment-config. Distinct trigger ("a config value is a path and the CWD is not mine" vs "config differs per environment"), and AGENTS.md rule 1 is one case per page. The platform fact (CWD default) was merged intoplatforms/processes/background-servicesinstead of duplicated.backend/ new categoryrefactoring/call-site-enumerationbackend, and it is language-agnostic →common/. New category justified: the 11 existingbackend/commoncategories are all runtime concerns (api-design, reliability, caching, jobs, errors, auth, orm, concurrency, llm, integrations, storage); none covers changing existing code. Filed undercommon/because positional/keyword argument binding is not Python-specific.testing/quality/guard-shape-vs-consequenceNew categories created: 1 (
backend/common/refactoring/).INDEX.mdandwiki/backend/index.mdupdated for it;INDEX.mdandwiki/infrastructure/index.mdupdated for insight 2.Verification of the change itself
A structural lint over all 143 pages passes: no duplicate ids, no id/path mismatch, no page over 120 body lines, every page carries
sources:and the required sections, everyrelated:id and inline[page-id]reference resolves, and every page is listed in its domain index. One vague-qualifier hit in a new page was fixed; the two remaining hits are pre-existing and untouched.