docs: regenerate rules from documentation@7e373fa#70
docs: regenerate rules from documentation@7e373fa#70harper-skills-sync[bot] wants to merge 1 commit into
Conversation
kriszyp
left a comment
There was a problem hiding this comment.
Nice work on this regeneration — the vast majority of it is a faithful, verified-accurate resync. I checked several claims directly against ~/dev/harper source (allowFullScan, the exact HdbError text, FIQL type-prefix coercion, the ==<value>* wildcard) and they all check out. The @relation → @relationship typo fix in querying-rest-apis.md in particular is a genuine, valuable correction — good catch by the generator there.
That said, I found two real API-accuracy bugs that made it into this PR, both regressions vs. the previously-synced text:
1. Many-to-many example points from at a field that doesn't exist
defining-relationships.md:100 (also AGENTS.md:300):
type Product @table @export {
id: Long @primaryKey
name: String
resellerIds: [Long] @indexed
resellers: [Reseller] @relationship(from: "resellerId")
}The schema declares resellerIds (array), but the relationship is wired to the singular resellerId, which doesn't exist on the record. Verified against resources/graphql.ts:216-221 (no name normalization on directive args) and resources/search.ts:578 (record[attribute.relationship.from]?.filter?.(...) — literal property lookup). An agent copying this verbatim gets a relationship that silently resolves to nothing. The pre-PR skill text had this right (from: resellerIds, matching the array attribute).
2. Foreign-key-to-foreign-key join mislabeled as "many-to-many"
defining-relationships.md:59 (also AGENTS.md:259) now reads "...useful for many-to-many relationships joining on non-primary-key attributes," but the accompanying example (OrderItem.product: Product @relationship(from: productSku, to: sku)) is a scalar field — one-to-one/many-to-one, not many-to-many. An agent following this rule for a genuine many-to-many case would produce a relationship that can't hold multiple related records.
Root cause is upstream, not in this PR. Both bugs trace directly to documentation@dbb3c18 itself:
- Bug 1:
reference/rest/querying.md:227-228has the sameresellerIds/resellerIdmismatch — while that same repo'sreference/database/schema.md:378-382has the correct, internally-consistent version (networkIds/@relationship(from: networkIds)). The generator just happened to pull the buggy copy instead of the correct one sitting right there in the same source set. - Bug 2:
reference/database/schema.md:398-400states the identical "useful for many-to-many relationships" claim against the same scalar OrderItem/sku example.
This regeneration faithfully reproduced what's in the source docs — it's not a generator hallucination. The durable fix belongs in HarperFast/documentation so it doesn't keep re-propagating into every future skill regen (this would be at least the second consecutive regen cycle reintroducing a relationship-example bug). Worth noting the same resellerId/resellerIds bug also already exists unchanged in querying-rest-apis.md:100 and AGENTS.md:1042 from prior syncs, so a doc-repo fix would need a follow-up regen to fully clear it everywhere.
Reviewer's call on how to sequence this: hold this PR for the upstream documentation fix and let the next regen pick it up clean, or take a quick manual patch here now (swap in the networkIds-style example / soften the many-to-many claim) and accept it'll need reconciling again once upstream is fixed. Either way, flagging so it doesn't quietly ship as agent-facing guidance.
— Claude (Sonnet 5), reviewed via review-queue
9ad4d62 to
ffc7a48
Compare
kriszyp
left a comment
There was a problem hiding this comment.
Re-review of the regen (now documentation@de2aaf1)
Thanks for the regen — one real fix landed, but a known blocker not only persisted, it regressed. Recommend holding this (do not merge) until the upstream doc is corrected, since merging ships a known agent-facing rule bug.
What's good
The @relation → @relationship directive typo is now fixed and correctly propagated (querying-rest-apis.md:204). @relationship is the only registered directive (graphql.ts:45, dispatched at :216); @relation was silently ignored. This is the genuine, valuable change in the PR.
Blocker — regressed: many-to-many array example wires a nonexistent attribute
The array declares resellerIds but the directive now says from: "resellerId" (singular), across all 4 locations:
defining-relationships.md:100querying-rest-apis.md:192AGENTS.md:300andAGENTS.md:1065
Worse: last pass defining-relationships.md still carried one correct copy (@relationship(from: resellerIds)). This regen deleted it and replaced it with the broken singular form in a new "How It Works" step 6 — so now every copy is wrong.
Why it's really broken (verified against live ~/dev/harper 17ab8efd8): graphql.ts:216-221 stores directive args verbatim (relationshipDefinition[arg.name.value] = arg.value.value) with no name normalization, and search.ts resolves the array many-to-many path by literal property lookup — record[attribute.relationship.from]?.filter?.(...) at search.ts:578 and { attribute: attribute.relationship.from, value: relatedEntry } at search.ts:187. With from: "resellerId" that reads record.resellerId, which is undefined since the schema only defines resellerIds. An agent copying this gets a relationship that silently resolves to nothing.
Significant — scalar from+to join still mislabeled as many-to-many
defining-relationships.md:59,AGENTS.md:259
The rule now claims @relationship(from: attribute, to: attribute) "supports many-to-many relationships on non-primary-key attributes", but the paired example (OrderItem.product: Product @relationship(from: productSku, to: sku)) uses two scalar fields — that's many-to-one. Cardinality in Harper is decided by whether the referenced attribute is an array: search.ts:180 sets isManyToMany = Boolean(findAttribute(relatedTable.attributes, attribute.relationship.to)?.elements). A scalar from/to join can't be many-to-many.
Root cause is upstream — fix in documentation, not here
Both issues are faithfully propagated from the canonical source. A skill-side patch would just drift back on the next regen. The fix needs to land in HarperFast/documentation:
reference/rest/querying.md— theresellerId/resellerIdsmismatch- align with the correct many-to-many pattern already in
reference/database/schema.md
This is the second consecutive regen (skills#69, now #70) to ship a relationship-example inaccuracy. Worth adding a generator-side lint before regeneration: "every attribute referenced in a from:/to: example must appear in the adjacent schema block" would have caught the blocker mechanically, and an "array-vs-scalar" heuristic could flag the many-to-many mislabel.
— Claude (Sonnet 5), on behalf of Kris, via review-queue
ffc7a48 to
2644ebe
Compare
- v5-migration.md: the polling-loop example was missing await on delay(100), turning the intended ~10Hz poll into a tight loop (delay() returns a promise from node:timers/promises). - querying.md: the resellers relationship example pointed `from` at the singular `resellerId`, which the schema never declares — the indexed field is plural `resellerIds`. Both found by a cross-model review on HarperFast/skills#70 (which regenerates its rules from this repo). A third finding from that review — recommending `allowReadRecord` over `allowRead` for record-scoped authorization — was not applied: `allowReadRecord` doesn't exist in Harper; a synchronous `allowRead` override already is the correct record-scoped hook, so that example was correct as written.
kriszyp
left a comment
There was a problem hiding this comment.
I think the upstream doc fixes have been merged, think you can re-generate?
| id: Long @primaryKey | ||
| name: String | ||
| resellerIds: [Long] @indexed | ||
| resellers: [Reseller] @relationship(from: "resellerId") |
There was a problem hiding this comment.
This is the same resellerId/resellerIds mismatch flagged in the last two review rounds on this PR, and it's regressed further: the schema declares the array resellerIds, but from: references the singular resellerId, which doesn't exist on the record. This regen actually deleted the one remaining correct copy of this example (from: resellerIds, unquoted) that survived in a prior sync, and replaced it with this broken form in the new "How It Works" step 6 — so now every copy in the repo is wrong. An agent copying this verbatim gets a relationship that silently resolves to nothing.
Root cause is upstream: HarperFast/documentation reference/rest/querying.md:227-228 has this exact mismatch, while reference/database/schema.md:378-382 has the correct pattern (networkIds / @relationship(from: networkIds)) right next to it. Recommend fixing upstream and re-running the regen rather than patching here, since this file is mode: generate.
| class MyResource { | ||
| static async get(target) { | ||
| await getContext().transaction.commit(); | ||
| while ((await transaction(() => Table.get(target))).status !== 'ready') { |
There was a problem hiding this comment.
This code block calls transaction(() => Table.get(target)) but the import above (line 75) only imports getContext — transaction is undefined here, so this throws ReferenceError if copied as-is. origin/main (pre-PR) had import { getContext, transaction } from 'harper';; this regen dropped transaction from the import while keeping the call, which is a real regression versus the previously-synced text. Same issue repeats at line 182 in this file and in AGENTS.md:2639 / AGENTS.md:2741.
Root cause is upstream: HarperFast/documentation release-notes/v5-lincoln/v5-migration.md:87,95 has the identical incomplete import + undeclared call. The old skill text had silently corrected this; this regen overwrote the fix with the faithful (broken) copy.
| ``` | ||
|
|
||
| 3. **Use `@relationship(from: attribute, to: attribute)` for foreign key to foreign key joins**: Specify both `from` and `to` when neither side uses the primary key. This is useful for joining on non-primary-key attributes. | ||
| 3. **Use `@relationship(from: attribute, to: attribute)` for foreign key-to-foreign key joins**: Specify both `from` and `to` when neither side of the join uses the primary key. This is useful for many-to-many relationships that join on non-primary-key attributes. |
There was a problem hiding this comment.
This step describes @relationship(from: attribute, to: attribute) as "useful for many-to-many relationships," but the paired example (OrderItem.product: Product @relationship(from: productSku, to: sku)) uses two scalar fields — that's many-to-one, not many-to-many (cardinality is determined by whether the to-side attribute is an array). Flagged in the prior review round on this PR and still unresolved. Root cause: documentation reference/database/schema.md:398-400 makes the same claim against the same scalar example.
| - The array order of foreign key values in many-to-many relationships is preserved when resolving the relationship. | ||
| - See [automatic-apis.md](automatic-apis.md) for how Harper tables are automatically exposed as REST endpoints. | ||
| - The queried attribute must be indexed for basic attribute filtering to execute. For multi-attribute queries, only one attribute needs to be indexed. | ||
| - Query for null values with `?discount=null`. Only indexes created with null indexing support support this; existing indexes must be removed and re-added. |
There was a problem hiding this comment.
Typo: "support support" (duplicate word) — "Only indexes created with null indexing support support this".
2644ebe to
597ea44
Compare
597ea44 to
80eb5f4
Compare
Automated regeneration of docs-driven skill rules, now synced to
HarperFast/documentation@7e373fa.Why these rules changed
Each rule regenerated because its source content differs from the docs commit it was last synced from. The trigger commit is not necessarily what changed a given rule — drift accumulates across every docs commit since the rule’s recorded baseline (below).
defining-relationships— last synced from docs@4fe4c9cvector-indexing— last synced from docs@4fe4c9cquerying-rest-apis— last synced from docs@b7fbddaprogrammatic-table-requests— last synced from docs@be709f9v5-upgrade— last synced from docs@de2aaf1Docs commits since baseline (
4fe4c9c..7e373fa)Produced by
.github/workflows/generate.yaml. Review the diff as you would any rule change — the generator reads the docs build output and rewritesmode: generate/ importsmode: directrule bodies, then reassembles AGENTS.md. See docs/plans/docs-driven-skills.md.🤖 Generated with Claude Code