Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
212c330
tbKMode 0.3.0.5, an Experimental package: its landing page (building …
KubaO Nov 15, 2026
b0bacdb
tbKMode: a WARNING on the package's own settings (a driver that calls…
KubaO Nov 17, 2026
8f4137c
tbKMode verifier, first part: verify.mjs kernels downloads ntoskrnl.e…
KubaO Nov 17, 2026
d6d84e4
tbKMode verifier: x86 exports from WDK 10.0.22621's import libraries …
KubaO Nov 17, 2026
830af86
tbKMode verifier: verify.mjs check reads the package's .twin files wi…
KubaO Nov 17, 2026
e28b2b9
A contributed package's tool is published as a zip beside its section…
KubaO Nov 17, 2026
423a2db
tbKMode Verifier: its page in the package's section, linked from the …
KubaO Nov 17, 2026
35270e3
WIP.tbKMode.md: what tbKMode's section decided, its tools (wdk, exe, …
KubaO Nov 17, 2026
0c3bacc
The dot task leaves an SVG that comes out as on disk, line ends aside…
KubaO Nov 17, 2026
c25a947
tbKMode verifier: verify.mjs wdk writes a database of each WDK's head…
KubaO Nov 17, 2026
3073ce4
tbKMode cases: wdk/wdkcheck.mjs writes the layout and value cases fro…
KubaO Nov 17, 2026
6aa089d
tbKMode pages: the verifier's page and card say what check compares w…
KubaO Nov 17, 2026
8b62e7e
WIP.tbKMode.md: the WDK databases (22621 deciding, owner), wdk/ reduc…
KubaO Nov 17, 2026
91678e1
tbKMode verifier: imports names the kernel-mode file that does export…
KubaO Nov 17, 2026
d0bdd83
tbKMode modWDM: a 32-bit driver does not load if it calls a Declare o…
KubaO Nov 17, 2026
9b893e2
tbKMode: CHAR_MIN and CHAR_MAX are not compared (owner): the package'…
KubaO Nov 17, 2026
f3c334e
tbKMode verifier: a constant expression keeps twinBASIC's widths (a s…
KubaO Nov 17, 2026
16753a9
tbKMode verifier: WDK database format 2, a pointer's kind names what …
KubaO Nov 17, 2026
3a75759
tbKMode verifier: check compares a ByRef parameter with what the rout…
KubaO Nov 17, 2026
bccb467
tbKMode verifier: check reports a Sub for a Try routine that returns …
KubaO Nov 17, 2026
2d7f1dc
tbKMode verifier: a Sub is reported for every Try routine whose resul…
KubaO Nov 17, 2026
7eb250c
tbKMode: issues #3 and #4 filed and the 0.3.0.5 pages reviewed (owner…
KubaO Nov 17, 2026
0ead7ca
tbKMode writer: the six module pages are written from a frame and a d…
KubaO Nov 17, 2026
802754f
WIP.tbKMode: the old page scripts are deleted; no gate runs writer.mj…
KubaO Nov 17, 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
19 changes: 19 additions & 0 deletions WIP.BugHunt.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,25 @@ Seen on BETA 1042 by the `commonctls` setup (fixture `test/shots/commonctls`).
raises -2147467262 at the grid's first property. BETA 1042, the samples' template project.
May be twinBASIC's implicit form instance rather than the package.

### tbKMode

tbKMode 0.3.0.5, BETA 1042, met while moving its section to that version. Neither is checked.

- **Are the 16-bit limits a defect at all?** **MAXUINT16**, **MAXUSHORT**, **MAXWORD**,
**USHRT_MAX** and **_UI16_MAX** are `&HFFFF`, an Integer literal, so -1 where C has 65535;
**MINSHORT** is -32768 where C's `&H8000` is the int 32768. modWDM's constants NOTE states
them as wrong, with failing checks in `WDMValueTests.Constants_Values` (the five through
`values` in `wdk/modWDM.json`). But the package declares a USHORT field as an Integer, and -1
equals such a field that holds 65535, so the Integer values may be the right ones for the
package and C's the wrong expectation; MINSHORT's -32768 is the real minimum of a SHORT.
**Page affected** if they are not defects: the NOTE's bullets, the `values` entries and the
generated expectations change.
- **SE_SELF_RELATIVE** (`SECURITY_DESCRIPTOR_CONTROL`, modWDM.twin line 4724) is `&H8000&`, a
Long 32768, which an Integer cannot hold: **SECURITY_DESCRIPTOR.Control** (line 233) and the
*Control* of RtlGetControlSecurityDescriptor and RtlSetControlSecurityDescriptor (lines
4949-4950) are Integers, so assigning the flag to one may raise overflow, and comparing one with
it is never true. Not run.

### User-defined types (from the GdiPlus work)

Seen on BETA 1005, 32-bit, by the agents documenting GdiPlus; not seen again since. Check on
Expand Down
10 changes: 10 additions & 0 deletions WIP.Contributed.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ what it is, in [WIP.PackageTests.md](WIP.PackageTests.md).

- `package-tests.bat` --- runs the test projects of the contributed packages named (in any case: `tbregexp`), or of every one with `--all-packages`, which is never the default and leaves out GdiPlus, run only when named (owner; `ALL_PACKAGES_SKIP` in `lib/package-tests.mjs`, which np4 in the launcher repository reads too) (`scripts/package_tests.mjs`): each project under `test/package-tests/` is staged with its package embedded and run with `tbrun --tests` as 32-bit and 64-bit, and each case is judged against `expect.json` as *documented*, *fixed* (the callout goes) or *changed* (a claim of the page is no longer true). `--update` writes `expect.json` from the run; read every entry it writes, since each is a claim that the package is defective. A case that never returns is caught and run alone. It also rewrites the generated `RunAll.twin`. Outside every gate and CI, as `examples.bat` is. The build publishes each project, referencing the package as a linked package and carrying none of its code, as `tB/Packages/Contributed/<Package>/<Package>-tests.twinproj` in the online tree (the `packageTests` task, `builder/package-tests.mjs`, `_config.yml`'s `package_tests`; the publish allowlist exempts those paths, and the offline tree's links go to the website).

- **A package's own tools are run when its section is updated, never in a gate** (owner,
2026-11-17): they live in its folder under `test/package-tests/`, each with a README, and are in
no wrapper gate, not in CI and not on the developer Tools pages under `docs/Documentation/`. They
are documented with the package: a tool published for readers has a page in the package's
section, is linked from its landing page and has a card on the Downloads page, and its folder's
`publish.json` makes the build zip it beside the section with everything it needs
([test/package-tests/README.md, Tools of one package](test/package-tests/README.md#tools-of-one-package);
tbKMode's verifier).

## Per package

BigNumberLib's section documents its main class only. What a package's section decided, and what
Expand All @@ -34,6 +43,7 @@ is known about the package beyond its pages, is in a file of its own:
- [TBMANLIB_ListBoxHScroll](WIP.TBMANLIB_ListBoxHScroll.md)
- [TBMANLIB_Xml](WIP.TBMANLIB_Xml.md)
- [tbProjPacker](WIP.tbProjPacker.md)
- [tbKMode](WIP.tbKMode.md)
- [tbRegExp](WIP.tbRegExp.md)
- [tsJson](WIP.tsJson.md)
- [tsPwGen](WIP.tsPwGen.md)
Expand Down
107 changes: 107 additions & 0 deletions WIP.tbKMode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# tbKMode --- working notes

The contributed tbKMode package (fafalone, GitHub `fafalone/tbKMode`), documented at
`docs/Reference/Contributed/tbKMode/`. This file holds what its section decided and what is known
about the package beyond its pages; the rules for every contributed package are in
[WIP.Contributed.md](WIP.Contributed.md).

## What the section decided (owner)

- **Experimental**, with no second-agent reproduction (owner waived it): `parent: Experimental
Packages`, its line in `Experimental.md`, its folder in `_book.yml`'s `left_out:`.
- **No driver is ever loaded, installed, signed or started.** Building one is allowed (the probe
does), and so is reading a built one. Samples are compiled only (`check_build`), never run.
- **Pages**: the landing page and one per module (modWDM, modFltMgr, modSysInfo, modDisk, modImage,
modKmOpaque), each `parent: tbKMode Package` at `/tB/Packages/Contributed/tbKMode/<Module>`, the
verifier's page, `Verifier.md`, and the writer's, `Writer.md`, after it. Tables of two columns (Constants three), rows alphabetical, the
name cell `**Name**{: #Name }` or `[**Name**](<checked Microsoft URL>){: #Name }`, one-sentence
descriptions, enum members not listed. modWDM's procedures are `###` sections. An object-type
function (0.3.0.5 returns the object type itself) is plain prose. modWDM has an `## Aliases` table
(CBoolean, KIRQL, KPROCESSOR_MODE); modImage's aliases are commented out in the package.
- **Callouts** are labelled with the package version (`0.3.0.5`) or `timeless`, each backed by
cases or the probe.
- The owner reviewed the 0.3.0.5 pages, the verifier's included (2026-11-17).
- **A declaration right for the kit the package was written from is no defect**: modSysInfo follows
the 10.0.22621 SDK (`POLICY_AUDIT_SUBCATEGORY_COUNT` 59, no `FileFsGuidInformation`), and its cases
check that kit's values (`wdk/modSysInfo.json`, `values` and `sizes`).

## How the pages are written

**The six module pages are written by `test/package-tests/tbKMode/writer/writer.mjs`** (owner,
2026-11-17: generated from sources, documented after the verifier's page, `Writer.md`): each from
its folder's `frame.md`, `names.json` and, for modWDM, `procedures.md`. Edit those, never the
page, then run the writer; `--check` says whether a page differs. Its README says how. The landing
page, `Verifier.md` and `Writer.md` are written by hand. The writer's sources were extracted from
the pages as they were reviewed (2026-11-17); the earlier per-module scripts are deleted. **No
gate runs `writer.mjs --check`** (owner, 2026-11-17): the package is small and the owner alone
maintains its section. It needs only the repository's files, so it can join `test.bat` once others
edit the section.

## The package's tools (test/package-tests/tbKMode/)

Run when the section is updated, never in a gate (test/package-tests/README.md, *Tools of one
package*). Each folder's README says how.

- `wdk/`: writes the layout and value cases from the verifier's WDK database of the deciding kit
(`wdkcheck.mjs`, configured by `verifier/config/tbKMode.json`), and finds Microsoft Learn's pages
(`learn.mjs`, committed `learn/<Module>.json`). Needs neither Visual Studio nor the WDK. The cases
stay beside the verifier's own check because the compiler is the authority on a Type's layout.
- `exe/`: cases run in a built exe against a stand-in `ntoskrnl.exe` built with MSVC
(`fake-kernel/`). A routine a new exe case calls is added to the stand-in and its `.def`. A
routine called in the wrong convention gets an x86 naked stand-in that pops what the defective
caller pushed; its comment says what to change once fixed.
- `probe/`: builds small drivers with `tbbuild --build` and judges their import tables with the
verifier's `checkDriver`; it backs the landing page's warning on the package's own settings.
- `verifier/`: published as `tbKMode-verifier.zip` (its page, `Verifier.md`). `check` checks each
Declare per arch against `db/kernels.json`, and the whole package against the WDK databases;
`imports` checks a built driver. The kernel database holds the x64 exports of each Windows version
from the symbol server (keys from Winbindex) and the x86 exports and decorated symbols of WDK
10.0.22621's import libraries, read from its installer as data (never run). `kernels` updates it,
fetching only what it lacks (owner: past WDKs and builds do not change); `--refresh` after a
Windows update.
- The WDK databases, `verifier/db/wdk-<kit>.json`, one for each kit of `verifier/config/wdk.json`,
written by `verify.mjs wdk` with Visual Studio: every structure's layout, value and prototype of
the headers, x86 and x64. **Kits (owner, 2026-11-17): 10.0.22621 and the newest, 22621
deciding**: a difference from it is an error, the newest's differences are notes. 22621's kernel
headers come from its bundle's headers-and-libraries package (its MSI names the CAB entries); its
SDK must be installed. `check` lays each Type out as twinBASIC does (`lib/tblayout.mjs`), a model
that agreed with every layout check of the compiled cases (3764, BETA 1042), and its findings
reproduce every failing layout and value check of `expect.json`. A pointer's kind names what it
points to (database format 2), so `check` compares a `ByRef` parameter with it: a structure where
C takes the address of a pointer (IoCreateDevice, SeLocateProcessImageName), or a variable
smaller than the pointee (ExInitializeNPagedLookasideList), is an error. It cannot find
CmCallbackReleaseKeyObjectIDEx: a `ByRef UNICODE_STRING` is a `PCUNICODE_STRING`, and the defect
is that the Get routine gives a pointer. A `Sub` is accepted for a routine that returns a result,
except a Try routine's (owner, 2026-11-17): its `BOOLEAN`, `LOGICAL` or `ULONG` says whether it
succeeded (ExTryToAcquireFastMutex).

Lessons: a case's failure message holds no address and no list longer than 100 characters; a
compile case's record holds its line number, so new ones go at the end of a file. A field or type
named like a WDK macro breaks the generated C++ unless guarded (the WDK program hides such macros
with push_macro). Never pin `NTDDI_VERSION`. A layout case compares offsets and sizes only; the
verifier's check also compares field sizes. The source closes one `#If` with `#endif` (no space), so
a reader of `#If` blocks takes `#End\s*If`.

From writing the WDK databases: on x86 the headers need `/Gz` (most routines have no convention in
their declaration); `cl /d1PP` loses the name of a `#define` whose comment runs on to the next line,
so macro names come from the included headers' text (`/showIncludes`); MSVC accepts a dllimport
function's address as `constexpr`, so a value must be asserted arithmetic, an enum or an array; a
`static_assert` inside a template reports once per instantiation, so a refusal belongs on the
item's own line; a part of 100 items keeps the compiler under its 100 errors. A twinBASIC Type is
laid out like C (natural alignment, LongLong 8 on x86 too); the scanner gives a Type no `#If`
condition and its attributes no arguments' conditions, so `readPackage` reads both from the text,
and each file's `#Const` (an undefined constant is Empty).

## Upstream

Issues for fafalone's repository are drafted in the main checkout's `.claude/drafts/`; the owner
posts them. #1 (modFltMgr, modDisk) and #2 (modSysInfo) were answered by 0.3.0.5 (comment for #2:
`tbkmode-issue-2-comment.md`). #3 (the package's Settings) and #4 (the declarations of modWDM and modImage) are filed
(2026-11-17), from `tbkmode-issue-3.md` and `tbkmode-issue-4.md`.

## Leads, not on the pages

In [WIP.BugHunt.md](WIP.BugHunt.md#tbkmode): the 16-bit limits (perhaps no defect) and
`SE_SELF_RELATIVE` `&H8000&` against the Integer `Control` field. Omissions, not defects: newer
members missing from `IMAGE_DEBUG_EX_CH` and `ImageMachineType`, `SYMBOLIC_LINK_SET`; optional
pointers declared `ByRef` (the `ByVal vbNullPtr` paragraph covers them).
7 changes: 5 additions & 2 deletions builder/counts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,11 @@ export function deriveDownloads(state, { tests = null, addinDest = null }) {
else files.set(rel, f.size);
}
if (addinDest) refused.set(addinDest, HELP_ADDIN_REFUSAL);
const packages = (tests?.packed ?? []).map(({ pkg, rel, bytes }) => ({ pkg, rel, bytes: bytes.length }));
for (const t of packages) files.set(t.rel, t.bytes);
// Every packed file can be sized; only the test projects are rows of the table.
for (const { rel, bytes } of tests?.packed ?? []) files.set(rel, bytes.length);
const packages = (tests?.packed ?? [])
.filter((t) => t.kind !== "tool")
.map(({ pkg, rel, bytes }) => ({ pkg, rel, bytes: bytes.length }));
return { files, refused, tests: { dest: tests?.dest ?? "", packages } };
}

Expand Down
20 changes: 18 additions & 2 deletions builder/dot.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
// independent, so a source is never published wherever it lives.
//
// Idempotent: a second build with no source changes is a no-op (mtime
// check). The `.dot` is the canonical source; the SVG is a build
// check), and an SVG that comes out the same as the file on disk, line ends
// aside, is not rewritten, only touched; a changed one keeps the file's line
// ends. So a checkout's mtimes cause no change git sees, with or without
// core.autocrlf. The `.dot` is the canonical source; the SVG is a build
// artifact -- editing the .dot by one character regenerates the SVG on
// the next build.
//
Expand Down Expand Up @@ -106,7 +109,20 @@ export async function regenerateDot(srcRoot) {
try {
const source = await fs.readFile(src, "utf8");
const svgXml = stripXmlPrologue(gv.dot(source), path.basename(src));
await fs.writeFile(svg, svgXml, "utf8");
// A checkout sets the mtimes of a .dot and its SVG in no particular order, so an SVG is
// often found stale that is not. One that comes out as the file already holds, line ends
// aside, is left as it is, and only its time moves past its source's. One that did change
// is written with the line ends the file on disk has: CRLF in a checkout with
// core.autocrlf, LF in one without (CI), so that git sees the change and nothing else. A new
// one is written LF, as Graphviz gives it; git takes either when it is added.
const lf = svgXml.replace(/\r\n/g, "\n");
const old = await fs.readFile(svg, "utf8").catch(() => null);
if (old !== null && old.replace(/\r\n/g, "\n") === lf) {
const now = new Date();
await fs.utimes(svg, now, now);
continue;
}
await fs.writeFile(svg, old?.includes("\r\n") ? lf.replace(/\n/g, "\r\n") : lf, "utf8");
regenerated++;
} catch (err) {
console.warn(`dot: skipped ${path.basename(src)} (${err.message}); existing SVG retained`);
Expand Down
62 changes: 56 additions & 6 deletions builder/package-tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,60 @@
// (addin-project.mjs). Line ends are LF in the files, which impexp packs with CRLF, so a
// Windows and a Linux checkout write the same bytes.

//
// A package's published tool (a folder of the package's with a publish.json, packageTools in
// lib/package-tests.mjs; test/package-tests/README.md, "Tools of one package") is zipped beside
// the test project, as <dest>/<Package>/<zip>, its files under one folder: every file of the tool's
// folder but publish.json, `rewrite` replacing a file's text, and `vendor` adding files from
// outside the folder (a path relative to the tool's folder), so that the zip needs nothing else.
// Text files are written with LF and every entry with one fixed time, so the same files give the
// same zip on any checkout.

import { readdirSync, readFileSync } from "node:fs";
import { promises as fs } from "node:fs";
import path from "node:path";
import {
downloadName,
packageTestNames,
packageTools,
resourceFiles,
TOOL_MANIFEST,
templateSettings,
testSettings,
testSources,
} from "../lib/package-tests.mjs";
import { zipFiles } from "../lib/zip.mjs";
import { packFiles } from "../scripts/impexp.mjs";
import { posix } from "./paths.mjs";

// Every entry's time: a fixed one, so the zip's bytes follow its files alone.
const ZIP_TIME = new Date(2000, 0, 1, 0, 0, 0);

/** A file's bytes as published: a text file (no NUL byte) with LF line ends. */
function published(bytes) {
return bytes.includes(0) ? bytes : Buffer.from(bytes.toString("utf8").replace(/\r\n/g, "\n"), "utf8");
}

/** One published tool's zip, in memory. */
export function packPackageTool({ dir, manifest }) {
const files = new Map();
const walk = (d, rel) => {
for (const e of readdirSync(d, { withFileTypes: true })) {
const r = rel ? `${rel}/${e.name}` : e.name;
if (e.isDirectory()) walk(path.join(d, e.name), r);
else if (r !== TOOL_MANIFEST) files.set(r, published(readFileSync(path.join(d, e.name))));
}
};
walk(dir, "");
for (const [rel, text] of Object.entries(manifest.rewrite ?? {})) {
if (!files.has(rel)) throw new Error(`${dir}: ${TOOL_MANIFEST} rewrites ${rel}, which the folder does not hold`);
files.set(rel, Buffer.from(text, "utf8"));
}
for (const { from, to } of manifest.vendor ?? []) files.set(to, published(readFileSync(path.resolve(dir, from))));
const names = [...files.keys()].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
return zipFiles(names.map((n) => ({ name: `${manifest.folder}/${n}`, data: files.get(n), mtime: ZIP_TIME })));
}

/**
* What _config.yml's package_tests declares, resolved against the source tree, or null when it
* declares none (the test fixtures' configs do not).
Expand All @@ -45,10 +86,13 @@ export function packageTestsOf(config, srcRoot) {
};
}

/** The path of each package's download in the online tree. */
/** The path of each package's download in the online tree: test projects, then tools. */
export function packageTestRels(cfg) {
if (!cfg) return [];
return packageTestNames(cfg.src).map((pkg) => `${cfg.dest}/${pkg}/${downloadName(pkg)}`);
return [
...packageTestNames(cfg.src).map((pkg) => `${cfg.dest}/${pkg}/${downloadName(pkg)}`),
...packageTools(cfg.src).map((t) => `${cfg.dest}/${t.pkg}/${t.manifest.zip}`),
];
}

/** One package's project file, in memory. */
Expand All @@ -66,14 +110,18 @@ export async function packPackageTests(cfg, pkg) {
* that a page can state a download's size ({{tbdocs:size:...}}, counts.mjs), and the
* packageTests task writes these same bytes.
*
* @returns {Promise<{packed: {pkg: string, rel: string, bytes: Buffer}[], ms: number}>}
* @returns {Promise<{packed: {pkg: string, rel: string, bytes: Buffer, kind: "tests" | "tool"}[], ms: number}>}
*/
export async function packAllPackageTests(cfg) {
const t0 = Date.now();
const packed = [];
for (const pkg of packageTestNames(cfg.src)) {
const rel = `${cfg.dest}/${pkg}/${downloadName(pkg)}`;
packed.push({ pkg, rel, bytes: await packPackageTests(cfg, pkg) });
packed.push({ pkg, rel, bytes: await packPackageTests(cfg, pkg), kind: "tests" });
}
for (const tool of packageTools(cfg.src)) {
const rel = `${cfg.dest}/${tool.pkg}/${tool.manifest.zip}`;
packed.push({ pkg: tool.pkg, rel, bytes: packPackageTool(tool), kind: "tool" });
}
return { packed, ms: Date.now() - t0 };
}
Expand Down Expand Up @@ -101,6 +149,8 @@ export function formatPackageTests(r, indent = "") {
if (r.failed) return `${indent}package tests: not written: ${r.error}\n`;
if (!r.written.length) return "";
const kb = Math.round(r.written.reduce((n, w) => n + w.bytes, 0) / 1024);
const n = r.written.length;
return `${indent}package tests: ${n} project${n === 1 ? "" : "s"}, ${kb} KB, in the online tree (${r.ms} ms)\n`;
const tools = r.written.filter((w) => w.rel.endsWith(".zip")).length;
const n = r.written.length - tools;
const also = tools ? ` and ${tools} tool${tools === 1 ? "" : "s"}` : "";
return `${indent}package tests: ${n} project${n === 1 ? "" : "s"}${also}, ${kb} KB, in the online tree (${r.ms} ms)\n`;
}
2 changes: 1 addition & 1 deletion builder/page-baseline.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"src": "docs",
"pages": 1540,
"pages": 1549,
"staticFiles": 1347
}
Loading
Loading