भारत · ग्रहगणित
स्थान उज्जयिनी Ujjayinī · change it on a tool⌕ search the कोश ⌘Kप्रहर — · —:—:—ours, from sunriseउज्जयिनी —:—:—UTC + λ/15 h, λ = 75.7682° E (D13)IST Error −26.9 minlocal mean time − IST = 4λ − 330 min (K12)engine 3f94072the site ↗

yantra/patha/vedha-lekha.js

वेध-लेख: the owner's observation ledger, its seal and its certifier (slice 7 of the vedha-yantra

1079 lines · 0 exports

लेख · the header

The header, as the file states it

vedha-lekha.js — वेध-लेख: the owner's observation ledger, its seal and its certifier (slice 7 of the vedha-yantra design, VEDHA-YANTRA-DESIGN-2026-10-07.md §4.2 L6, §4.5, §7.6). The loop of the tradition is gaṇita → vedha → antara → saṃskāra → parīkṣā (design §0.2, §4.5). This module is the vedha and the antara of it: a ledger in which each observation is written once, in the owner's own units, chained to the one before it by a hash, so that nothing can later be changed, reordered, removed or slipped in without the chain saying so; a certifier that refuses what the owner's instruments cannot have produced; and a reduction that puts each observation beside what the text predicts for it. THE LEDGER (format "vedha-lekha/1", corpus/vedha/LEDGER.md) { format, site, shanku?, entries: [entry…], seal? } entry = { seq, prev, at, record, sealedHash } seq 1, 2, 3, … with no gap prev the sealedHash of the entry before; for the first, the hash of the header { format, site, shanku } at the Kali day (kala-dvara.js) on which the entry was written; never decreasing record one observation (the kinds below) sealedHash SHA-256 of the canonical JSON of { seq, prev, at, record } seal = { n, head, at, hash }: hash = SHA-256 of the canonical JSON of { format, genesis, n, head, at }. A sealed ledger takes no more entries. The seal is the one number the owner writes down elsewhere: with it, even a rewrite of the whole chain is caught. Canonical JSON: keys sorted, no white space, numbers as the language prints them; undefined members dropped. SHA-256 is written out here (the published algorithm, its constants derived below as integer roots), not taken from any library; the test checks it against the published vectors. THE KINDS (the five of corpus/vedha/README.md, read by ss-chaya.js, and eight that the design needs) madhyahna, vishuvat, ayananta, ishta, kapala the shadow and the bowl, exactly as "vedha-chaya/1" (SS 3, 1.12, 13.23) yamyottara a star on the meridian: the bowl's count from sunrise, and/or its meridian altitude (unnata) in aṃśa-kalā-vikalā with the side (disha) it was read from; upper or lower transit. The turn's phase against the stars (1.12, 2.63, 3.42) and, from a circumpolar star's two transits, the dhruva's elevation (12.72-12.73; dhruva.js). grahana an eclipse contact (sparsha, nimilana, madhya, unmilana, moksha; 4.16-4.17) of the Moon or the Sun, timed by the bowl from sunrise, or for the Sun by the śaṅku's shadow (3.37-3.39). The day is the civil day of the sunrise before it (Jyotirmīmāṃsā p.36). candra-darshana the Moon seen or not seen on an evening (west, first crescent) or a morning (east, last): 10.1's twelve kālāṃśa. candra-yoga the Moon on a junction star's circle through the dhruva (the conjunction of 8.14-8.15 judged by the dhruvaka), timed by the bowl from sunrise. ganita the prediction written before the event (design §4.5, step 1): what it is for, the model that made it, its values in the owner's units. An observation may cite it; the certifier makes sure it came first. yantra a reading of one of the owner's instruments (yantra.js: Jai Singh II's samrāṭ, nāḍīvalaya, jaya prakāśa, kapāla, rāma, digaṃśa, ṣaṣṭhāṃśa, dakṣiṇottara-bhitti, rāśivalaya, unnatāṃśa), in the instrument's own graduation — a nata in ghaṭī-vināḍī-prāṇa with its side, an arc in aṃśa-kalā-vikalā with its gola or disha — of the Sun or a junction star, optionally timed by the bowl from sunrise. yantra.js's checkReading is the schema; its reduceReading puts the text beside it. uttara-rekha the owner's north–south line (3.3: drawn by the shadow circle and the fish) checked by a star near the dhruva: the arc (digamsha) from that provisional line to the star at its eastern (purva) and at its western (pashcima) greatest elongation, each with its day and the side of the line it lay on, and the uncertainty (sigma) of one reading. True north is the midpoint of the two (dhruva.js northFromElongations) [theorem]. ayananta-yugma the two solstice noons at the ledger's site: the Sun's noon zenith distance (natamsha) and the side of the zenith it stood on (disha), at the karka and at the makara solstice (3.11), each with its day, and the uncertainty (sigma) of one reading. ε is half their signed difference, the latitude half their signed sum (dhruva.js fromSolsticeZenithDistances) [theorem]. These two are the FRAME kinds. Their reduction is geometric and exact (whole vikalā in, half vikalā out), with the uncertainty propagated from one reading's sigma. Refraction does not cancel in these readings, and nothing here removes it. What they give is a PREVIEW beside the text's own values — ε = arc of 1397/3438 (SS 2.28), the default — and beside the ledger's own place: never applied, never replacing a constant. Using a measured value is the owner's explicit choice, made elsewhere (dhruva.js and the pañcāṅga take an `epsilon` argument). The text tier is complete without any observation; a ledger is an optional extra. (The text tier's default, the Sūrya-Siddhānta with Parameśvara's saṃskāra [owner's decision, 2026-10-08], corrects only the Moon, its apogee and its node — the Sun gets none (parahita-madhyama.js) — so its ε is still SS 2.28's.) THE CERTIFIER refuses, with a reason each: any field outside the schema; any field of a modern clock, Julian day, equatorial or horizontal coordinate, geodetic datum or ephemeris (named so in the reason); any string naming a modern source (the frame gate's names of kala-dvara.test.js and the others listed below) or carrying a modern time stamp; entries out of order; a broken chain or seal; a gaṇita written after its day or cited before it was written; and every synthetic record unless the caller allows them — a synthetic record always needs its generator. Time. A bowl count is asus of the TURN (6 prāṇa = 1 vināḍī, 60 vināḍī = 1 ghaṭī, 60 ghaṭī = one turn: 1.11-1.12), corrected by the bowl's own count of a turn (the "kapala" records). It becomes civil time only through 1.34-1.37: one civil day is 21,600 × 1,582,237,828 ÷ 1,577,917,828 asus of the turn. Sunrise, the origin of every count here, is the instant the true Sun's hour angle is minus its half-day (2.61-2.63), the hour angle being the meridian's asus (ss-grahana.js) less the Sun's ascension (ss-udaya.js, 3.42): the zero of SSUdaya.sinceSunrise, which ss-grahana.js's clock counts from and ss-chaya.js's shadow clock (3.37-3.39) reads as half-day ∓ nata; `sunrise: "text"` takes 2.46's instead (ss-drishya.js). The crescent is judged at ss-drishya.js's own sunset and sunrise (its defaults; `drishya` passes options through). Requires only the sovereign files: kala-dvara.js, sphuta.js, dhruva.js, ss-udaya.js, ss-chaya.js, ss-grahana.js, ss-drishya.js, yantra.js. No node built-in, no modern source as computation, seed or referee. Browser: window.VedhaLekha (needs KalaDvara, Sphuta, Dhruva, SSUdaya, SSChaya, SSGrahana, SSDrishya, Yantra); node: module.exports.
आवश्यक · requires

What it loads

required by
निर्यात · exports

What it exports

पाठ · the verses it cites

SS verses named in the header

  • SS 2.28verse
    paramāpakramajyā tu saptarandhraguṇendavaḥ । tadguṇā jyā trijīvāptā taccāpaṃ krāntirucyate ।।
नलिका · channels

The channels it runs in

not on a channel
कार्य · the functions

Every function, what it calls, who calls it

70 top-level functions read from the source; the doc line is the comment above each; calls and callers are resolved across the registry’s modules by name. Line numbers are the file’s at engine 3f94072.

mod(a, m)lines 93–93
calls nothing in the registry
wrap180(a)lines 94–94
calls mod
wrapAsus(a)lines 95–95
isObj(x)lines 96–96
own(o, k)lines 97–97
calls nothing in the registry
iroot(n, k)lines 103–110

── SHA-256 ───────────────────────────────────────────────────────────────────────────────────── The constants are the first 32 bits of the fractional parts of the square roots (H) and cube roots (K) of the first 8 and 64 primes. They are derived here as integer roots in BigInt — floor(√(p·2⁶⁴)) and floor(∛(p·2⁹⁶)) mod 2³² — so no constant is typed in; the published vectors in the test decide whet

calls nothing in the registry
called by nothing in the registry
PRIMES(()lines 111–111
calls nothing in the registry
called by nothing in the registry
utf8(str)lines 116–130exported

UTF-8 bytes of a string (a lone surrogate becomes U+FFFD).

calls nothing in the registry
called by sha256
rotr(x, n)lines 131–131
calls nothing in the registry
called by sha256
sha256(input)lines 133–156exported

SHA-256 of a string (as UTF-8) or of bytes, as 64 lowercase hex digits.

calls utf8, rotr
called by hashOf
canonical(v)lines 160–172exported

Canonical JSON: object keys sorted, no white space; only strings, finite numbers, booleans, null, arrays and plain objects; undefined members are dropped (as JSON drops them).

calls nothing in the registry
called by hashOf
hashOf(v)lines 173–173
header(L)lines 174–174
calls nothing in the registry
called by genesisOf, verify
genesisOf(L)lines 175–175
calls hashOf, header
called by sealHash, append, verify
entryHash(e)lines 176–176
calls hashOf
called by append, verify
sealHash(L, s)lines 177–177
called by verify, seal
deepFreeze(x)lines 178–178
calls nothing in the registry
clone(x)lines 179–179
calls nothing in the registry
unspell(s)lines 217–217

── what the instruments cannot have produced ─────────────────────────────────────────────────── The frame gate's names (kala-dvara.test.js [FRAME]), each spelled here with a "·" so that this file itself passes that gate; the test checks that the expression rebuilt from them is the gate's own.

calls nothing in the registry
called by nothing in the registry
modernIn(s)lines 227–233

Why a string cannot stand in the ledger, or null.

calls nothing in the registry
called by scanModern
modernField(k)lines 246–246
calls nothing in the registry

Walks every key and string of a value: modern field names and modern strings.

Fields of an object outside `keys` (modern fields are reported once, by scanModern).

arcOf(a, where)lines 269–275exported

An arc { amsha, kala, vikala } (degrees, minutes, seconds) → degrees.

arcOfDegrees(deg, round)lines 277–282exported

Degrees → { amsha, kala, vikala } (vikala fractional unless `round`).

calls nothing in the registry
called by nothing in the registry
kapalaOfAsus(asus, round)lines 284–289exported

Asus → { ghati, vinadi, prana } (prana fractional unless `round`).

calls nothing in the registry
asusOfKapala(k, where)lines 290–290exported
calls nothing in the registry
called by checkKind, reduce
arcText(v)lines 311–311
calls nothing in the registry
called by lineSide, zenithSide
wholeVikala(a, where)lines 317–322

An arc read to the whole vikalā → integer vikalā (arcseconds), as dhruva.js's exact arithmetic takes it.

sigmaVikala(a, where)lines 324–330

The uncertainty (1σ) of one reading, { amsha, kala, vikala } → vikalā; more than zero.

One greatest elongation → { N, vikala }: signed vikalā on the provisional line's scale, east (purva) positive.

noonReading(x, where)lines 341–348

One solstice noon → { N, vikala }: the signed zenith distance, south of the zenith positive.

lineSide(v)lines 349–349
calls arcText
zenithSide(v)lines 350–350
calls arcText

An uttara-rekha record's readings, checked: { e, w, sigma } (vikalā). Throws, with the reason, on the first fault.

An ayananta-yugma record's readings, checked: { k, m, sigma } (vikalā). Throws, with the reason, on the first fault.

halfQuadrature(s)lines 370–370
calls nothing in the registry
northLine(record)lines 373–389exported

One uttara-rekha record → where true north lies on the owner's line, east (purva) positive, with its σ. A PREVIEW: nothing is applied. Validates the record itself before dhruva.js sees it, and throws a readable error if it fails.

solsticePair(record, place)lines 394–421exported

One ayananta-yugma record → ε and the latitude, each with its σ, beside the text's ε (SS 2.28) and the given place (placeOf; optional). A PREVIEW: nothing is applied. Validates the record itself before dhruva.js sees it, and throws a readable error if it fails. warnings: a noon that the text's own Sun puts more than 15° (about 15 days) from its solstice — a check of this module against a mis-dated

── one record, against the schema ──────────────────────────────────────────────────────────────

calls nothing in the registry
checkKind(r, shanku)lines 426–489

The kind's own fields (the chāyā kinds by ss-chaya.js's own validate). Throws on the first fault.

dayOf(r)lines 491–495

The record's day: its own, or for a frame kind the later of its two readings' days (the record is whole only then).

calls own, isObj
called by append, certify, reduce

Every fault of one record that does not need the rest of the ledger, as { where, reason }.

── the ledger ──────────────────────────────────────────────────────────────────────────────────

create(head)lines 527–535exported

A new, empty ledger for a place: { site: { name, deshantara, palabha | latitude }, shanku? }.

called by nothing in the registry
append(ledger, record, opts)lines 540–564exported

Appends one record; returns the new ledger (the old one is untouched). opts.at: the Kali day of writing (default: the record's own day, else the last entry's). Refuses a record that fails its own checks, a day after `at`, an `at` earlier than the last, a gaṇita citation that is not already in the ledger, and any sealed ledger. Synthetic records may be written (the certifier decides whether they ar

called by nothing in the registry
verify(ledger)lines 567–599exported

The chain alone: seq, prev, the hashes, the order of `at`, and the seal. { ok, n, head, genesis, problems }.

seal(ledger, opts)lines 602–612exported

Closes a ledger with its final hash. opts.at: the Kali day of sealing (default: the last entry's).

called by nothing in the registry
toJSON(ledger)lines 615–615exported

The ledger as a file (JSON, two-space indent).

calls nothing in the registry
called by nothing in the registry
fromJSON(text)lines 617–622exported

A ledger file back to a (frozen) ledger. It is not certified by being read: call certify or verify.

called by nothing in the registry
certify(ledgerOrFile, opts)lines 630–667exported

The certifier. Takes a ledger or its file (a JSON string). Refuses, with a reason each: fields outside the schema; fields of a modern clock (UTC style), Julian day, equatorial or horizontal coordinate (RA/Dec), geodetic datum (WGS84) or ephemeris; any string naming a modern source or carrying a modern time stamp; entries out of order; a broken chain or seal; a record of a day after it was written;

ayanamsha(t)lines 670–670

── the text's predictions, in the owner's units (used by reduce and by any synthetic generator) ────

calls nothing in the registry
placeOf(site, shanku, chaya)lines 672–678exported

The model's site { latitude, deshantara, palabha } from the ledger's site (palabhā by the table, 3.12b-3.17a).

calls nothing in the registry
called by reduce
modelSite(p)lines 679–679
calls nothing in the registry
called by reduce
sunriseAt(N, site, opts)lines 684–697exported

Sunrise of civil day N (days since the Kali epoch): the instant the true Sun's hour angle — the meridian's asus (ss-grahana.js) less the Sun's ascension (ss-udaya.js, 3.42) — is minus its half-day (2.61-2.63): the zero of SSUdaya.sinceSunrise, so the same instant ss-grahana.js's clock counts from. opts.ascension is passed to it; opts.sunrise "text" takes 2.46's sunrise instead (ss-drishya.js).

sunsetAt(N, site, opts)lines 700–713exported

Sunset of day N by the same rule as sunriseAt: the instant the Sun's own time since rising equals its whole day, twice the half-day of 2.61-2.63 (council G-3: one rule for both ends of the day).

called by nothing in the registry
turnAsusBetween(t0, t1)lines 715–715exported

Asus of the turn between two instants (civil days): 1.34-1.37.

calls nothing in the registry
afterTurnAsus(t0, asus)lines 717–717exported

The instant `asus` of the turn after t0.

calls nothing in the registry

A star on the meridian on the night after the sunrise of day N: { name, dhruvaka, vikshepa } (sidereal degrees, from ch.8). It crosses when the meridian's asus (mean Sun's turn, as ss-grahana.js) equal its own ascension: 3.42's rule at its dhruvaka, which is the foot of its circle through the dhruva (2.63, ch.8). Its declination is the dhruvaka's with the vikṣepa (2.58, 2.63); its meridian altitud

eclipseFor(body, N, site, opts)lines 742–745exported

The text's eclipse whose contacts follow the sunrise of day N (ss-grahana.js: 4.1-4.26, 5 for the Sun).

calls nothing in the registry

One contact of the text's eclipse, counted from the sunrise of day N in asus of the turn.

The śaṅku's shadow at the instant `asus` of the turn after the sunrise of day N, by the text (3.34b-3.36): the Sun's own asus by 2.59 (ss-chaya.js), its nata from the meridian, the shadow and the side. For synthetic records and for checking a shadow-timed contact.

called by nothing in the registry

The reverse: asus of the turn from sunrise of day N, from a shadow and its side (3.37-3.39, 2.62-2.63, 2.59). The Sun's place is taken at the instant found, again until it holds.

The crescent on the evening (horizon "pashcima", the default: 10.1-10.4 at ss-drishya.js's sunset) or the morning ("purva": 10.1's east, at its sunrise) of day N: the text's kālāṃśa and its verdict (seen at twelve or more).

calls mod
called by reduce
moonPolarAt(t)lines 799–802exported

The Moon's polar longitude (sidereal degrees): its sāyana place less 7.10's āyana part (latitude′ × the declination of λ + 90° in degrees, as seconds) — the foot of its own circle through the dhruva — less the ayanāṃśa.

calls ayanamsha, mod
called by predictYuti
predictYuti(N, star, site, opts)lines 806–822exported

The instant after the sunrise of day N at which the Moon's polar longitude reaches the star's dhruvaka (8.14-8.15), in asus of the turn from that sunrise; null when it does not on that civil day. The text's yoga has no lambana: what the observer sees carries the Moon's parallax, which the reduction reports and does not remove.

stats(xs)lines 825–825

── the reduction ───────────────────────────────────────────────────────────────────────────────

calls nothing in the registry
called by reduce
starMap(opts)lines 827–830

The catalogue (corpus/surya-siddhanta/yogatara.json, or a list of { name, dhruvaka, vikshepa }) as a name → star map.

calls nothing in the registry
called by reduce
reduce(ledgerOrFile, opts)lines 838–1066exported

Reduces a certified ledger. The chāyā records go, as a "vedha-chaya/1" file, to ss-chaya.js's reduce; each of the other observations comes back with what it measured [measured], the text's prediction beside it, and the antara. The frame kinds (uttara-rekha, ayananta-yugma) come back as a preview (northLine, solsticePair) beside the text's ε and the ledger's place, applied to nothing; summary.uttar