Repository navigation
Commit e866d10
ADFA-5220: Correct the version table to a single row, not an append-only log (#1729)
* ADFA-5220: Correct the version table to a single row, not an append-only log
DocumentationDatabaseVersion holds exactly one row -- the format version the
database *is*, not a history of what it has been. The comments and the doc
bullet described an append-only log, which was my reading of the ticket's
INSERT-based update example and is wrong.
resolveMajorVersion keeps ORDER BY rowid DESC, now stated as a defence rather
than a model: a file that breaks the one-row contract still reads
deterministically, and a downgrade still reads as a downgrade where MAX(major)
would report the highest version ever declared. The two tests that asserted
last-row-wins across several rows collapse into one that says what that ordering
is actually for.
The writer side is OfflineDocumentationTools#29.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* ADFA-5220: Report a version table that holds more than one row
The reader tolerates several rows on purpose -- ordering by rowid keeps the
answer deterministic -- but it did so silently, so a database built by something
that appended instead of replacing looked identical to a correct one. The count
now rides along with the version in the same query, and more than one row is
logged with the major actually used.
The doc bullet stated the one-row rule twice over nine lines; it now says it
once.
Verified: the query returns (last major, total count) against sqlite directly,
for one row, several rows, and none. The instrumented assertion for the
single-row path is added but not executed -- no device is attached at the moment.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* ADFA-5220: Restore the test that pins the ordering, and warn on the worst case
Review of this PR found that merging the two ordering tests deleted the only one
that distinguished "highest rowid" from "lowest major": every remaining
expectation happened to be the minimum major present, so MIN(major) would have
passed the whole suite while the test named for the row written last proved
nothing. Both directions are back -- the last row higher, and the last row a
downgrade.
The NULL check ran before the count was read, so a file that is both multi-row
and ends in a NULL major returned null with nothing logged: the most malformed
state there is, reported exactly like a database that has no version table. The
count is read first now, and there is a test, which needs a table created
without the shipped DDL's NOT NULL -- fitting, since this reader exists to
defend against files another producer wrote.
WebServerTest's cursor stub never answered getInt(1), so a relaxed mock returned
a row count of 0 -- a state the production code has just excluded by getting a
row back at all. It returns 1 now, so those tests exercise something reachable.
The doc claimed docdb-studio logs a warning for a multi-row file. It does not;
only this reader does. It also lost the reason highest-rowid beats MAX(major),
which is the fact that stops someone simplifying the query later. Both fixed.
Verified on device this time, not just compiled: 12 instrumented tests pass on a
Galaxy Note 20 Ultra, and the warning appears three times in logcat -- once per
multi-row case, the NULL-major one included.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* ADFA-5220: Log through SLF4J, and bind the fixture's values
This file was one of two in common/utils still using android.util.Log where ten
siblings use SLF4J, so the whole file moves rather than just the new warning --
a file mixing both would be worse than either. The duplicate-row warning takes a
{} placeholder with rows as an argument.
The malformed-table fixture built its INSERT by concatenating literals; the
values are bound now, like every other insert in this test.
Verified on device: 12 instrumented tests pass and the warning still reaches
logcat three times through the SLF4J binding.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* ADFA-5220: Order the version row by change time, and cover the reader
Review follow-ups on the single-version-row reader.
ORDER BY rowid DESC picked "the row written last" only by accident:
rowid is not insertion order, and SQLite is free to reuse the rowid of
a deleted row. The table carries a changeTime column that records
exactly what the comment claims to want, so order by that and let rowid
break ties. On a downgrade -- major 3 written, then 2 -- the old
ordering could hand back 3 and attach the shared dictionary to content
that is plain brotli.
A NULL major now logs. It still reads as "no declared version", because
that is the answer the caller is built to handle, but it and a database
predating the table are no longer indistinguishable in the log: one is
an old file behaving correctly, the other is a malformed one silently
losing dictionary decoding.
formatVersion returned "" when changeTime, set and who were all blank,
which callers stored and displayed as a stamp. Return VERSION_UNKNOWN.
The existing tests are in common/src/androidTest, which no workflow
runs -- CI assembles :app:assembleV8DebugAndroidTest and runs two named
app classes. The branch logic now has JVM tests that execute. Four of
them pin behaviour that was already correct but unproven; the ordering
test fails against the previous query.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M4sTwYg47aK8VB9kRKZicU
* 📝 Add docstrings to `task/ADFA-5220-single-version-row`
Docstrings generation was requested by @davidschachterADFA.
The following files were modified:
* `common/src/main/java/com/itsaky/androidide/utils/DatabaseVersionResolver.kt`
These files were ignored:
* `app/src/test/java/com/itsaky/androidide/localWebServer/WebServerTest.kt`
* `common/src/androidTest/java/com/itsaky/androidide/utils/DatabaseVersionResolverTest.kt`
* `common/src/test/java/com/itsaky/androidide/utils/DatabaseVersionResolverBranchTest.kt`
These file types are not supported:
* `docs/documentation-database.md`
* ADFA-5220: Address review: KDoc selection rule, doc wording, test helper dedupe
- Restore resolveMajorVersion's detailed KDoc (the docstring bot had replaced
it with a generic summary) and correct the selection rule it states: the
greatest changeTime wins, rowid only breaks ties -- matching the query.
- Fix the same stale "highest rowid" wording in docs/documentation-database.md.
- WebServerTest: sendRawGetRequestAndAwaitClose now delegates to
sendRawGetRequest instead of duplicating the socket setup, and the shared
helper documents that plaintext HTTP is intentional -- WebServer is a
loopback-only plaintext server, tested as shipped.
* ADFA-5220: Name both Tier 3 transports in the doc intro
The intro still credited Tier 3 solely to WebServer; since ADFA-5176 the
interceptor serves it in-process with WebServer as the HTTP fallback. And
DocumentationContentSource is the one *Tier 3* pipeline reading the
database -- ToolTipManager reads it too, as the section intro itself says.
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>1 parent 52038f0 commit e866d10
5 files changed
Lines changed: 210 additions & 37 deletions
File tree
- app/src/test/java/com/itsaky/androidide/localWebServer
- common/src
- androidTest/java/com/itsaky/androidide/utils
- main/java/com/itsaky/androidide/utils
- test/java/com/itsaky/androidide/utils
- docs
Lines changed: 13 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
70 | 74 | | |
71 | 75 | | |
72 | 76 | | |
| |||
435 | 439 | | |
436 | 440 | | |
437 | 441 | | |
438 | | - | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
439 | 446 | | |
440 | 447 | | |
441 | 448 | | |
| |||
450 | 457 | | |
451 | 458 | | |
452 | 459 | | |
453 | | - | |
454 | | - | |
455 | | - | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
456 | 464 | | |
457 | 465 | | |
458 | 466 | | |
459 | 467 | | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
| 468 | + | |
469 | 469 | | |
470 | 470 | | |
471 | 471 | | |
| |||
Lines changed: 26 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
90 | 92 | | |
91 | | - | |
| 93 | + | |
92 | 94 | | |
93 | 95 | | |
94 | 96 | | |
95 | 97 | | |
96 | 98 | | |
97 | 99 | | |
98 | | - | |
| 100 | + | |
| 101 | + | |
99 | 102 | | |
100 | | - | |
| 103 | + | |
101 | 104 | | |
102 | 105 | | |
103 | 106 | | |
104 | 107 | | |
105 | 108 | | |
106 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
107 | 129 | | |
108 | 130 | | |
109 | 131 | | |
| |||
Lines changed: 64 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
32 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
33 | 34 | | |
34 | | - | |
| 35 | + | |
35 | 36 | | |
36 | | - | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
47 | 53 | | |
48 | 54 | | |
49 | 55 | | |
| |||
63 | 69 | | |
64 | 70 | | |
65 | 71 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
| 72 | + | |
70 | 73 | | |
71 | 74 | | |
72 | 75 | | |
73 | 76 | | |
74 | | - | |
| 77 | + | |
75 | 78 | | |
76 | 79 | | |
77 | | - | |
| 80 | + | |
78 | 81 | | |
79 | 82 | | |
80 | 83 | | |
81 | 84 | | |
82 | 85 | | |
83 | 86 | | |
84 | | - | |
85 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
86 | 95 | | |
87 | 96 | | |
88 | 97 | | |
| |||
95 | 104 | | |
96 | 105 | | |
97 | 106 | | |
98 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
99 | 135 | | |
100 | 136 | | |
101 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
102 | 146 | | |
103 | 147 | | |
104 | 148 | | |
| |||
108 | 152 | | |
109 | 153 | | |
110 | 154 | | |
111 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
112 | 159 | | |
113 | 160 | | |
Lines changed: 104 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
0 commit comments