From 0f3108352997ed21ac77560b8990e5ca4827651f Mon Sep 17 00:00:00 2001 From: Arthur Souza Rodrigues Date: Sun, 17 May 2026 07:30:58 -0400 Subject: [PATCH] =?UTF-8?q?idx=3D8:=20freeze=20(26=20records)=20=E2=80=94?= =?UTF-8?q?=20Allegiance=20Bancshares=20Restricted=20Stock=20Agreement:=20?= =?UTF-8?q?IWW-anchored=20sig-page=20detection=20for=20form=20templates=20?= =?UTF-8?q?without=20/s/=20marks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit idx=8 is a form/template Restricted Stock Agreement (Non-Employee Director) for Allegiance Bancshares, Inc. As a blank form it has an IWW operating clause but no /s/ signature marks — only placeholder By:/Name:/Title: fields. The existing _explode_signature_block_lines early-exited when no /s/ carrier existed, leaving party-label and By:/Name:/Title: records at L1 instead of demoting them to L2. Fix in scripts/parse_doc2dict_with_config.py: when IWW is present but no /s/ exists, treat each IWW record as the sig-page anchor. Walk siblings of the IWW carrier under the same parent (and their descendants) and apply shape detection (SIG_FIELD_RE / SIG_BLOCK_LABEL_RE / CORP_SUFFIX_LABEL_RE / bare-name) to identify sig-line records, then pin them at depth 2 + subdoc_penalty. The walk does not filter by node_id position because doc2dict's promoted-leaf ordering doesn't guarantee document order — shape detection itself filters out non-sig content. Numbered/lettered sections, IWW itself, and envelope/trailer rows are excluded. Verified: - idx=8: 26 records, levels {0: 1, 1: 16, 2: 7, 3: 2}, reconstruction word_coverage=100% char_ratio=98% - All 9 frozen idxs (0..8) regress OK --- .../level_freeze/frozen/idx_8.jsonl | 26 ++++ data/auto_parse/level_freeze/state.json | 9 +- scripts/parse_doc2dict_with_config.py | 115 +++++++++++++++++- 3 files changed, 145 insertions(+), 5 deletions(-) create mode 100644 data/auto_parse/level_freeze/frozen/idx_8.jsonl diff --git a/data/auto_parse/level_freeze/frozen/idx_8.jsonl b/data/auto_parse/level_freeze/frozen/idx_8.jsonl new file mode 100644 index 0000000..c93754c --- /dev/null +++ b/data/auto_parse/level_freeze/frozen/idx_8.jsonl @@ -0,0 +1,26 @@ +{"idx": 8, "order": 0, "level": 0, "span": "RESTRICTED STOCK AGREEMENT"} +{"idx": 8, "order": 1, "level": 1, "span": "(Non-Employee Director)\nThis Restricted Stock Agreement (\"Agreement\") effective as of the ____ day of _____________, ________, is between Allegiance Bancshares, Inc. (the \"Company\"), and _____________________, (the \"Holder\"). To carry out the purposes of the Allegiance Bancshares, Inc. 2015 Amended and Restated Stock Awards and Incentive Plan (the \"Plan\") by providing individuals upon whom the responsibilities of the successful administration and management of the Company rest additional incentive and reward opportunities designed to advance the profitable growth of the Company, the Company and Holder hereby agree as follows:"} +{"idx": 8, "order": 2, "level": 1, "span": "1.     Award of Stock\nThe Company hereby grants (the \"Grant\") to Holder _________ shares (the \"Shares\") of common stock of the Company, $1.00 par value (the \"Stock\") which shall be subject to the restrictions set forth in Section 2 hereof."} +{"idx": 8, "order": 3, "level": 1, "span": "2.    Forfeiture Restrictions\nThe Shares granted hereunder may not be sold, assigned, transferred, exchanged, pledged, hypothecated or encumbered by Holder, and no such sale, assignment, transfer, exchange, pledge, hypothecation or encumbrance, whether made or created by voluntary act of Holder or any agent of Holder or by operation of law, shall be recognized by, or be binding upon, or shall in any manner affect the rights of, the Company or any agent or any custodian holding certificates for the Shares. Holder shall be subject to an obligation to forfeit and surrender, for no consideration from the Company, the Shares to the Company upon a termination of service described in Section 3(d) of this Agreement. The prohibition against transfer and the obligation to forfeit and surrender shares of Stock to the Company (the \"Forfeiture Restrictions\") shall remain in effect until such time as such Forfeiture Restrictions shall expire under the terms of this Agreement. The Forfeiture Restrictions shall be binding upon and enforceable against any transferee of Restricted Shares."} +{"idx": 8, "order": 4, "level": 1, "span": "3.     Restricted Period\n(a)     For a period beginning on the date hereof and ending on ___________ (the \"Restricted Period\") the Shares shall be subject to the Forfeiture Restrictions and any other restrictions as set forth herein; provided, however, the Forfeiture Restrictions shall expire on a number of Shares as determined in accordance with the following schedule:\nNumber of Shares\non which\nDate\nForfeiture Restrictions Expire\nThe Shares that are subject to the Forfeiture Restrictions shall hereinafter be referred to as \"Restricted Shares.\" (b)     The Company shall effect the issuance of the Shares, and the issuance of a certificate or certificates for the Shares, in accordance with the determinations made by the Committee (as defined in the Plan). Each certificate issued for Shares to Holder shall be registered in Holder's name and shall be either deposited by the Secretary of the Company or its designee in an escrow account or held by the Secretary of the Company, together with stock powers or other instruments of transfer appropriately endorsed in blank by Holder (Holder hereby agreeing to execute such stock powers or other instruments of transfer as requested by the Company). Such certificate or certificates shall remain in such escrow account or with the Secretary of the Company until (i) the Restricted Period has terminated or (ii) the expiration of the Forfeiture Restrictions in accordance with the schedule set forth in paragraph (a) above. Certificates representing the Restricted Shares shall bear the following legend:"} +{"idx": 8, "order": 5, "level": 1, "span": "THE SHARES REPRESENTED BY THIS CERTIFICATE MAY BE TRANSFERRED ONLY IN COMPLIANCE WITH THE CONDITIONS SPECIFIED IN THE ALLEGIANCE BANCSHARES, INC. RESTRICTED STOCK AGREEMENT, DATED AS OF ____________________ BETWEEN ALLEGIANCE BANCSHARES, INC. (\"COMPANY\") AND EACH OF THE GRANTEES NAMED THEREIN. A COMPLETE AND CORRECT COPY OF THE FORM OF SUCH AGREEMENTS IS AVAILABLE FOR INSPECTION AT THE PRINCIPAL OFFICE OF THE COMPANY AND WILL BE FURNISHED WITHOUT CHARGE TO THE HOLDER OF SUCH SHARES UPON WRITTEN REQUEST.\nthe account of Holder only upon, and in the event of, a resolution of such dispute in a manner favorable to Holder, and then only with respect to such of the Shares as to which such resolution shall be so favorable, and"} +{"idx": 8, "order": 6, "level": 2, "span": "(c)     Except as otherwise provided in the Plan, Holder shall, during the Restricted Period, have all of the other rights of a stockholder with respect to the Shares including, but not limited to, the right to receive dividends, if any, as may be declared on such Shares from time to time, and the right to vote (in person or by proxy) such Shares at any meeting of stockholders of the Company."} +{"idx": 8, "order": 7, "level": 2, "span": "(d)     In the event that Holder's service as a director of the Company or an Affiliate is terminated for any reason other than death or disability prior to the expiration of the Forfeiture Restrictions as provided in Section 3(a) or 3(e), any Restricted Shares outstanding shall, upon such termination of service, be forfeited by Holder to the Company, without the payment of any consideration or further consideration by the Company, and neither Holder nor any successors, heirs, assigns, or legal representatives of Holder shall thereafter have any further rights or interest in the Restricted Shares or certificates therefor, and Holder's name shall thereupon be deleted from the list of the Company's stockholders with respect to the Restricted Shares."} +{"idx": 8, "order": 8, "level": 2, "span": "(e)    In the event of a Change of Control (as defined in the Plan), or if Holder's service as a director of the Company or an Affiliate is terminated because of Holder's death or disability, any Forfeiture Restrictions on the Restricted Shares set forth in this Agreement which have not previously been forfeited shall be deemed to have expired, and the Restricted Shares shall thereby be free of all such Forfeiture Restrictions."} +{"idx": 8, "order": 9, "level": 2, "span": "(f)     If the Holder's service as a director of the Company or an Affiliate shall terminate prior to the expiration of the Restricted Period, and there exists a dispute between Holder and the Company or the Committee as to the satisfaction of the conditions to the release of the Shares from the Forfeiture Restrictions hereunder and under the Plan or the terms and conditions of the Grant, the Shares shall remain subject to the Forfeiture Restrictions until the resolution of such dispute, regardless of any intervening expiration of the Restricted Period, except that any dividends that may be payable to the holders of record of Stock as of a date during the period from termination of Holder's service to the resolution of such dispute (the \"Suspension Period\") shall:"} +{"idx": 8, "order": 10, "level": 3, "span": "(1)     to the extent to which such dividends would have been payable to Holder on the Shares, be held by the Company as part of its general funds, and shall be paid to or for"} +{"idx": 8, "order": 11, "level": 3, "span": "(2)     be canceled upon, and in the event of, a resolution of such dispute in a manner unfavorable to Holder, and then only with respect to such of the Shares as to which such resolution shall be so unfavorable."} +{"idx": 8, "order": 12, "level": 2, "span": "(g)     Upon expiration of the Forfeiture Restrictions, by lapse of time and upon compliance by the Holder, or the legal representative of Holder, with all obligations of Holder under the Plan and this Agreement, the Restricted Shares shall be released from all further restrictions and prohibitions hereunder and all of the forfeiture provisions of the Plan, and the Committee shall thereupon deliver or cause to be delivered to Holder or Holder's legal representative the certificate or certificates for the Shares free of any legend provided in subparagraph (b) of this paragraph."} +{"idx": 8, "order": 13, "level": 1, "span": "4.     Taxes\nAny federal, state or local taxes arising by virtue of this Grant and assessed against or based on the value of the Shares awarded to Holder shall be the sole responsibility of Holder; provided that the Company shall have the right to withhold any amounts required to be so withheld for federal, state or local income tax purposes. Any such taxes and withholding must be paid or provided for according to law and in a manner satisfactory to the Company and as provided in the Plan before any Shares, or certificates therefor, can be delivered to Holder. The Committee may permit payment of any such amount to be made through the tender of cash or Stock, the withholding of Stock out of shares otherwise distributable or any other arrangement satisfactory to the Committee. The Company shall, to the extent permitted by law, have the right to withhold delivery of a stock certificate or to deduct any required taxes from any payment of any kind otherwise due to Holder. If Holder does not pay the entire amount of such taxes to the Company, if any, within thirty (30) days after the date on which the Committee notifies Holder of the amount required to meet the withholding obligation, the Committee shall withhold from the Stock to which Holder is entitled a number of shares having an aggregate fair market value equal to the amount of such taxes remaining to be paid by Holder and shall deliver a certificate for the remaining shares to the Holder. If Holder makes the election authorized by section 83(b) of the Internal Revenue Code, Holder shall submit to the Company a copy of the statement filed by Holder to make such election. The failure of Holder to notify the Company of any such election made by Holder may, in the discretion of the Committee, result in the forfeiture of the Shares."} +{"idx": 8, "order": 14, "level": 1, "span": "5.     Changes in Capital Structure\nIf the outstanding shares of Stock or other securities of the Company, or both, shall at any time be changed or ex-changed by declaration of a stock dividend, stock split, combination of shares, or recapitalization, the number and kind of shares of Stock or other securities subject to the Restricted Shares shall be appro-priately and equitably adjusted in accordance with the terms of the Plan."} +{"idx": 8, "order": 15, "level": 1, "span": "6.     Compliance With Securities Laws\nUpon the acqui-si-tion of any shares pursuant to this Agreement, Holder (or Holder's legal representative upon Holder's death or disability) will enter into such written representations, warranties and agreements as the Company may reasonably request in order to comply with applicable securities laws or with this Agreement."} +{"idx": 8, "order": 16, "level": 1, "span": "7.     Service Relationship\nHolder shall be considered to be in service as a director as long as Holder remains as a director of the Company or an Affiliate. Any questions as to whether and when there has been a termination of such service, and the cause of such termination, shall be determined by the Committee, with the advice of the applicable corporation, and its determination shall be final."} +{"idx": 8, "order": 17, "level": 1, "span": "8.     Binding Effect\nThe provisions of the Plan and the terms and conditions hereof shall, in accordance with their terms, be binding upon, and inure to the benefit of, all successors of Holder, including, without limitation, Holder's estate and the executors, administrators, or trustees thereof, heirs and legatees, and any receiver, trustee in bankruptcy, or representative of creditors of Holder. This Agreement shall be binding upon and inure to the benefit of any successors to the Company."} +{"idx": 8, "order": 18, "level": 1, "span": "9.    Agreement Subject to Plan\nThis Agreement is sub-ject to the Plan. The terms and provisions of the Plan (including any subsequent amend-ments thereto) are hereby incorporated herein by reference thereto. In the event of a conflict between any term or provision contained herein and a term or provision of the Plan, the applicable terms and provisions of the Plan will govern and prevail. All defini-tions of words and terms contained in the Plan shall be applicable to this Agreement."} +{"idx": 8, "order": 19, "level": 1, "span": "10.    Notices\nEvery notice hereunder shall be in writing and shall be given by registered or certified mail. All notices by Holder shall be directed to Allegiance Bancshares, Inc., 8847 W. Sam Houston Parkway N., Suite 200, Houston, Texas 77040, Attention: Secretary. Any notice given by the Company to Holder directed to Holder at the address on file with the Company shall be effective to bind Holder and any other person who shall acquire rights hereunder. The Company shall be under no obligation whatsoever to advise Holder of the existence, maturity or termination of any of Holder's rights hereunder and Holder shall be deemed to have familiarized himself or herself with all matters contained herein and in the Plan which may affect any of Holder's rights or privileges hereunder."} +{"idx": 8, "order": 20, "level": 1, "span": "11.    Resolution of Disputes\nAny dispute or disagreement which may arise hereunder shall be determined by the Committee in its sole discretion and judgment, and any such determination and any interpretation by the Committee of the terms of the Plan or this Restricted Stock Agreement shall be final and shall be binding and conclusive, for all purposes, upon the Company, Holder, and Holder’s heirs, personal representatives and successors."} +{"idx": 8, "order": 21, "level": 1, "span": "12.    Amendment\nAny modification of this Agreement will be effective only if it is in writing and signed by a duly authorized officer of the Company and Holder, except to the extent such modification occurs pursuant to a proper amendment of the Plan."} +{"idx": 8, "order": 22, "level": 1, "span": "13.    Jurisdiction\nThe provisions of the Plan and the terms and conditions hereof shall be construed in accordance with the laws of Texas except to the extent pre-empted by Federal law."} +{"idx": 8, "order": 23, "level": 1, "span": "IN WITNESS WHEREOF, the Company has caused this Agreement to be duly executed by one of its officers thereunto duly authorized, and Holder has executed this Agreement, all as of the day and year first above written."} +{"idx": 8, "order": 24, "level": 2, "span": "ALLEGIANCE BANCSHARES, INC.\nBy:\nName:\nTitle:"} +{"idx": 8, "order": 25, "level": 2, "span": "Holder"} diff --git a/data/auto_parse/level_freeze/state.json b/data/auto_parse/level_freeze/state.json index ea9b284..dd67e2a 100644 --- a/data/auto_parse/level_freeze/state.json +++ b/data/auto_parse/level_freeze/state.json @@ -8,7 +8,8 @@ 4, 5, 6, - 7 + 7, + 8 ], "history": [ { @@ -171,6 +172,12 @@ "action": "freeze", "idx": 7, "n_records": 25 + }, + { + "ts": "2026-05-17T07:30:15", + "action": "freeze", + "idx": 8, + "n_records": 26 } ] } diff --git a/scripts/parse_doc2dict_with_config.py b/scripts/parse_doc2dict_with_config.py index 66f9182..eba3083 100644 --- a/scripts/parse_doc2dict_with_config.py +++ b/scripts/parse_doc2dict_with_config.py @@ -3934,16 +3934,123 @@ def _chain_ancestor_node_ids(node: dict[str, Any]) -> set[int]: # Pin the IWW operating clause depth=1. iww_present = False + iww_carriers: list[dict[str, Any]] = [] for r in actives: span = _span_text(r) if _is_iww_clause(span): r["depth"] = 1 + (r.get("subdoc_penalty") or 0) iww_present = True + iww_carriers.append(r) + + has_slash_s = any(_SIGN_OFF_RE.search(_span_text(r)) for r in actives) + if not has_slash_s and not iww_present: + # No /s/ anywhere AND no IWW clause — nothing more to do. + # Without either a /s/ carrier or an IWW anchor we have no + # structural cue that a signature area exists at all. + return rows + + if not has_slash_s and iww_present: + # Form/template case: IWW is present but no /s/ marks (because + # nobody actually signed the form — only placeholder By:/Name:/ + # Title: fields). Treat IWW records as the signature-page anchor + # and demote IWW-sibling sig-shape records to L2. + # + # The walk is bounded to records that share a parent with an IWW + # record (and their descendants). We do not filter by node_id + # position because doc2dict's tree ordering for promoted leaves + # is not guaranteed to be document order — the IWW record may be + # appended at the end of the sibling list even though the + # signature page (party label + By/Name/Title fields) appears + # earlier in node-id order. Sig-shape detection (SIG_FIELD_RE, + # SIG_BLOCK_LABEL_RE, CORP_SUFFIX_LABEL_RE) does the filtering. + sig_line_node_ids: set[int] = set() + + # Build child-index for descendant walks. + children_of_local: dict[int | None, list[dict[str, Any]]] = {} + for r in rows: + children_of_local.setdefault(r.get("parent_node_id"), []).append(r) + + def _walk_descendants_local(nid: int) -> list[dict[str, Any]]: + out: list[dict[str, Any]] = [] + stack = [nid] + seen: set[int] = set() + while stack: + cur = stack.pop() + if cur in seen: + continue + seen.add(cur) + for c in children_of_local.get(cur, []): + out.append(c) + stack.append(c["node_id"]) + return out + + # Set of parent_node_ids to consider — every parent that contains + # an IWW record as a child. + sig_area_parent_ids: set[int | None] = { + iww.get("parent_node_id") for iww in iww_carriers + } + for parent_id in sig_area_parent_ids: + siblings = children_of_local.get(parent_id, []) + for sib in siblings: + if sib.get("is_envelope") or sib.get("scope") == "trailer": + continue + if _has_section_marker_title(sib): + # A numbered/lettered section is agreement content + # (a top body clause), not a sig fragment. + continue + # Skip the IWW record itself — it stays L1. + if _is_iww_clause(_span_text(sib)): + continue + sib_title = (sib.get("title") or "").strip() + sib_body = (sib.get("body_direct") or "").strip() + looks_sig = ( + _SIG_FIELD_RE.match(sib_title) + or _SIG_FIELD_RE.match(sib_body) + or (sib_title and _SIG_BLOCK_LABEL_RE.match(sib_title)) + or (sib_title and _CORP_SUFFIX_LABEL_RE.match(sib_title)) + or (not sib_title and sib_body and _SIG_FIELD_RE.match(sib_body)) + ) + if looks_sig: + sig_line_node_ids.add(sib["node_id"]) + # Walk descendants of this sig-shape sibling so + # nested labels/fields (e.g. a "Holder" child under + # a party-label parent) are also demoted to L2. + for d in _walk_descendants_local(sib["node_id"]): + if d.get("is_envelope") or d.get("scope") == "trailer": + continue + if _has_section_marker_title(d): + continue + if _is_iww_clause(_span_text(d)): + continue + d_title = (d.get("title") or "").strip() + d_body = (d.get("body_direct") or "").strip() + d_looks_sig = ( + _SIG_FIELD_RE.match(d_title) + or _SIG_FIELD_RE.match(d_body) + or (d_title and _SIG_BLOCK_LABEL_RE.match(d_title)) + or (d_title and _CORP_SUFFIX_LABEL_RE.match(d_title)) + or (d_title and not d_body) # bare name as title + or (not d_title and d_body and _SIG_FIELD_RE.match(d_body)) + ) + if d_looks_sig: + sig_line_node_ids.add(d["node_id"]) + + # PASS 3 (IWW-anchored variant): pin each identified sig-line + # record at depth 2 (+ subdoc_penalty). Same contract as the + # /s/-anchored path: preserve doc2dict's grouping at L2. + for r in rows: + if r.get("is_envelope") or r.get("scope") == "trailer": + continue + if r["node_id"] not in sig_line_node_ids: + continue + if r.get("depth") == 0: + continue + if _is_iww_clause(_span_text(r)): + continue + l2_depth = 2 + (r.get("subdoc_penalty") or 0) + r["depth"] = l2_depth + r["_sig_line"] = True - if not any(_SIGN_OFF_RE.search(_span_text(r)) for r in actives): - # No /s/ anywhere — nothing more to do. Even modern agreements - # without an IWW clause will have /s/ lines or we don't treat - # this as a signature area. return rows # Build a set of sig-line node_ids using tree-chain expansion from